]> git.donarmstrong.com Git - lilypond.git/blob - lily/time-signature-engraver.cc
b7a2b26448318962d36fa3b153010627d1697b48
[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 {
22   Item * time_signature_p_;
23   SCM last_time_fraction_;
24
25 protected:
26   virtual void stop_translation_timestep ();
27   virtual void create_grobs ();
28 public:
29   TRANSLATOR_DECLARATIONS(Time_signature_engraver);
30
31 };
32
33
34 Time_signature_engraver::Time_signature_engraver ()
35
36   time_signature_p_ =0;
37   last_time_fraction_ = SCM_BOOL_F;
38 }
39
40 void
41 Time_signature_engraver::create_grobs ()
42 {
43   /*
44     not rigorously safe, since the value might get GC'd and
45     reallocated in the same spot */
46   SCM fr= get_property ("timeSignatureFraction");
47   if (!time_signature_p_ && last_time_fraction_ != fr)
48     {
49       last_time_fraction_ = fr; 
50       time_signature_p_ = new Item (get_property ("TimeSignature"));
51       time_signature_p_->set_grob_property ("fraction",fr);
52
53       if (time_signature_p_)
54         announce_grob (time_signature_p_, 0);
55     }
56   
57 }
58
59
60
61 void
62 Time_signature_engraver::stop_translation_timestep ()
63 {
64   if (time_signature_p_) 
65     {
66       typeset_grob (time_signature_p_);
67       time_signature_p_ =0;
68     }
69 }
70
71
72
73  
74
75 ENTER_DESCRIPTION(Time_signature_engraver,
76 /* descr */       "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
77 /* creats*/       "TimeSignature",
78 /* acks  */       "",
79 /* reads */       "",
80 /* write */       "");