]> git.donarmstrong.com Git - lilypond.git/blob - lily/time-signature-engraver.cc
* scm/engraver-documentation-lib.scm
[lilypond.git] / lily / time-signature-engraver.cc
1 /*
2   time-signature-engraver.cc -- implement Time_signature_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "time-signature.hh"
10
11 #include "engraver.hh"
12 #include "engraver-group-engraver.hh"
13
14 /**
15   generate time_signatures. 
16   */
17 class Time_signature_engraver : public Engraver
18 {
19   Item * time_signature_;
20   SCM last_time_fraction_;
21
22 protected:
23   virtual void stop_translation_timestep ();
24   virtual void process_music ();
25 public:
26   TRANSLATOR_DECLARATIONS(Time_signature_engraver);
27 };
28
29
30 Time_signature_engraver::Time_signature_engraver ()
31
32   time_signature_ =0;
33   last_time_fraction_ = SCM_BOOL_F;
34 }
35
36 void
37 Time_signature_engraver::process_music ()
38 {
39   /*
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)
44     {
45       last_time_fraction_ = fr; 
46       time_signature_ = new Item (get_property ("TimeSignature"));
47       time_signature_->set_grob_property ("fraction",fr);
48
49       if (time_signature_)
50         announce_grob(time_signature_, SCM_EOL);
51     }
52 }
53
54 void
55 Time_signature_engraver::stop_translation_timestep ()
56 {
57   if (time_signature_) 
58     {
59       typeset_grob (time_signature_);
60       time_signature_ =0;
61     }
62 }
63  
64
65 ENTER_DESCRIPTION(Time_signature_engraver,
66 /* descr */       "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
67 /* creats*/       "TimeSignature",
68 /* accepts */     "",
69 /* acks  */      "",
70 /* reads */       "",
71 /* write */       "");