* lily/music-iterator.cc (quit, do_quit): new function: break link
[lilypond.git] / lily / time-signature-engraver.cc
blob5d3d7a6fb7b2044c2e16141b18d09869a2f6e663
1 /*
2 time-signature-engraver.cc -- implement Time_signature_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "time-signature.hh"
10 #include "command-request.hh"
11 #include "engraver.hh"
12 #include "engraver-group-engraver.hh"
14 /**
15 generate time_signatures.
17 class Time_signature_engraver : public Engraver
19 Item * time_signature_;
20 SCM last_time_fraction_;
22 protected:
23 virtual void stop_translation_timestep ();
24 virtual void process_music ();
25 public:
26 TRANSLATOR_DECLARATIONS(Time_signature_engraver);
30 Time_signature_engraver::Time_signature_engraver ()
32 time_signature_ =0;
33 last_time_fraction_ = SCM_BOOL_F;
36 void
37 Time_signature_engraver::process_music ()
40 not rigorously safe, since the value might get GC'd and
41 reallocated in the same spot */
42 SCM fr= get_property ("timeSignatureFraction");
43 if (!time_signature_ && last_time_fraction_ != fr)
45 last_time_fraction_ = fr;
46 time_signature_ = new Item (get_property ("TimeSignature"));
47 time_signature_->set_grob_property ("fraction",fr);
49 if (time_signature_)
50 announce_grob(time_signature_, SCM_EOL);
54 void
55 Time_signature_engraver::stop_translation_timestep ()
57 if (time_signature_)
59 typeset_grob (time_signature_);
60 time_signature_ =0;
65 ENTER_DESCRIPTION(Time_signature_engraver,
66 /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
67 /* creats*/ "TimeSignature",
68 /* acks */ "",
69 /* reads */ "",
70 /* write */ "");