]> git.donarmstrong.com Git - lilypond.git/blob - lily/time-signature-engraver.cc
release: 1.3.131
[lilypond.git] / lily / time-signature-engraver.cc
1 /*
2   time_signature-reg.cc -- implement Time_signature_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "time-signature.hh"
10 #include "command-request.hh"
11 #include "engraver.hh"
12
13
14 #include "engraver-group-engraver.hh"
15
16
17 /**
18   generate time_signatures. 
19   */
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();
29 };
30
31
32 Time_signature_engraver::Time_signature_engraver()
33
34   time_signature_p_ =0;
35   last_time_fraction_ = SCM_BOOL_F;
36 }
37
38 void
39 Time_signature_engraver::create_grobs()
40 {
41   /*
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)
46     {
47       last_time_fraction_ = fr; 
48       time_signature_p_ = new Item (get_property ("TimeSignature"));
49       time_signature_p_->set_grob_property ("fraction",fr);
50
51       if (time_signature_p_)
52         announce_grob (time_signature_p_, 0);
53     }
54   
55 }
56
57
58
59 void
60 Time_signature_engraver::stop_translation_timestep()
61 {
62   if (time_signature_p_) 
63     {
64       typeset_grob (time_signature_p_);
65       time_signature_p_ =0;
66     }
67 }
68
69
70 ADD_THIS_TRANSLATOR(Time_signature_engraver);
71  
72