(all-grob-descriptions): remove gap from
[lilypond.git] / lily / time-signature-engraver.cc
blob017dd42b7bea566146f464a293f6bbc5cf40716a
1 /*
2 time-signature-engraver.cc -- implement Time_signature_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "time-signature.hh"
10 #include "warn.hh"
12 #include "engraver.hh"
13 #include "engraver-group-engraver.hh"
14 #include "misc.hh"
16 /**
17 generate time_signatures.
19 class Time_signature_engraver : public Engraver
21 Item * time_signature_;
22 SCM last_time_fraction_;
24 protected:
25 virtual void stop_translation_timestep ();
26 virtual void process_music ();
27 public:
28 TRANSLATOR_DECLARATIONS (Time_signature_engraver);
32 Time_signature_engraver::Time_signature_engraver ()
34 time_signature_ =0;
35 last_time_fraction_ = SCM_BOOL_F;
38 void
39 Time_signature_engraver::process_music ()
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_
46 && last_time_fraction_ != fr
47 && gh_pair_p (fr))
49 int den = gh_scm2int (gh_cdr (fr));
50 if (den != (1 << intlog2 (den)))
53 Todo: should make typecheck?
55 OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
57 warning (_f ("Found strange time signature %d/%d.",
58 den,
59 gh_scm2int (gh_car (fr))
60 ));
64 last_time_fraction_ = fr;
65 time_signature_ = make_item ("TimeSignature");
66 time_signature_->set_property ("fraction",fr);
68 if (time_signature_)
69 announce_grob (time_signature_, SCM_EOL);
73 void
74 Time_signature_engraver::stop_translation_timestep ()
76 if (time_signature_)
78 typeset_grob (time_signature_);
79 time_signature_ =0;
84 ENTER_DESCRIPTION (Time_signature_engraver,
85 /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
86 /* creats*/ "TimeSignature",
87 /* accepts */ "",
88 /* acks */ "",
89 /* reads */ "",
90 /* write */ "");