lilypond-1.3.122
[lilypond.git] / lily / time-signature-engraver.cc
blob9a4e2b4ee428b0a58b689715be0bf5153b38081a
1 /*
2 time_signature-reg.cc -- implement Time_signature_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "time-signature.hh"
10 #include "command-request.hh"
11 #include "engraver.hh"
14 #include "engraver-group-engraver.hh"
17 /**
18 generate time_signatures.
20 class Time_signature_engraver : public Engraver {
21 protected:
22 virtual void stop_translation_timestep();
23 virtual void create_grobs ();
24 public:
25 VIRTUAL_COPY_CONS(Translator);
26 Item * time_signature_p_;
27 SCM last_time_fraction_;
28 Time_signature_engraver();
32 Time_signature_engraver::Time_signature_engraver()
34 time_signature_p_ =0;
35 last_time_fraction_ = SCM_BOOL_F;
38 void
39 Time_signature_engraver::create_grobs()
42 not rigorously safe, since the value might get GC'd and
43 reallocated in the same spot */
44 SCM fr= get_property ("timeSignatureFraction");
45 if (!time_signature_p_ && last_time_fraction_ != fr)
47 last_time_fraction_ = fr;
48 time_signature_p_ = new Item (get_property ("TimeSignature"));
49 time_signature_p_->set_grob_property ("fraction",fr);
51 if (time_signature_p_)
52 announce_grob (time_signature_p_, 0);
59 void
60 Time_signature_engraver::stop_translation_timestep()
62 if (time_signature_p_)
64 typeset_grob (time_signature_p_);
65 time_signature_p_ =0;
70 ADD_THIS_TRANSLATOR(Time_signature_engraver);