]> git.donarmstrong.com Git - lilypond.git/blob - lily/timing-engraver.cc
95b68d0369885b807299b9e71a9d65699bc5ae36
[lilypond.git] / lily / timing-engraver.cc
1 /*
2   timing-grav.cc -- implement Timing_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "translator-group.hh"
10 #include "command-request.hh"
11 #include "score-element-info.hh"
12 #include "multi-measure-rest.hh"
13 #include "timing-translator.hh"
14 #include "engraver.hh"
15
16 /**
17   Do time bookkeeping
18  */
19 class Timing_engraver : public Timing_translator, public Engraver
20 {   
21   Bar_req * bar_req_l_;
22 protected:
23   virtual bool do_try_music (Music * );
24   virtual void do_post_move_processing ();
25   virtual void do_process_music ();
26 public:
27   String which_bar (); 
28   VIRTUAL_COPY_CONS(Translator);
29 };
30
31 ADD_THIS_TRANSLATOR(Timing_engraver);
32
33 void
34 Timing_engraver::do_post_move_processing( )
35 {
36   bar_req_l_ = 0;
37   Timing_translator::do_post_move_processing ();
38
39   SCM nonauto = get_property ("barNonAuto");
40   SCM which = now_mom () ? SCM_UNDEFINED : ly_str02scm ("|");
41   
42   if (which == SCM_UNDEFINED && !to_boolean (nonauto))
43     {
44       SCM always = get_property ("barAlways");
45       if (!measure_position ()
46           || (to_boolean (always)))
47         {
48           which=get_property ("defaultBarType" );
49         }
50     }
51
52   daddy_trans_l_->set_property ("whichBar", which);
53 }
54
55 bool
56 Timing_engraver::do_try_music (Music*m)
57 {
58   if (Bar_req  * b= dynamic_cast <Bar_req *> (m))
59     {
60       if (bar_req_l_ && !bar_req_l_->equal_b (b)) 
61         return false;
62       
63       bar_req_l_ = b;
64       return true;
65     }
66   
67   return Timing_translator::do_try_music (m);
68 }
69
70 void
71 Timing_engraver::do_process_music ()
72 {
73   if (bar_req_l_)
74     daddy_trans_l_->set_property ("whichBar", bar_req_l_->get_mus_property ("type"));
75 }
76