]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-engraver.cc
release: 1.1.6
[lilypond.git] / lily / bar-engraver.cc
1 /*
2   bar-reg.cc -- implement Bar_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "bar-engraver.hh"
10 #include "bar.hh"
11 #include "musical-request.hh"
12 #include "multi-measure-rest.hh"
13 #include "command-request.hh"
14 #include "time-description.hh"
15 #include "engraver-group.hh"
16
17 Bar_engraver::Bar_engraver()
18 {
19   bar_p_ =0;
20   do_post_move_processing();
21 }
22
23 bool
24 Bar_engraver::do_try_music (Music*r_l)
25 {
26   if (Bar_req  * b= dynamic_cast <Bar_req *> (r_l))
27     {
28       if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
29         return false;
30       
31       bar_req_l_ = b;
32
33       return true;
34     }
35   
36   return false;
37
38 }
39
40 void
41 Bar_engraver::create_bar ()
42 {
43   if (!bar_p_)
44     {
45       bar_p_ = new Bar;
46       bar_p_->break_priority_i_  = 0;
47       String default_type = get_property ("defaultBarType");
48       if (default_type.length_i ())
49         {
50           bar_p_->type_str_ = default_type;
51         }
52       announce_element (Score_element_info (bar_p_, bar_req_l_));
53     }
54 }
55
56
57 void 
58 Bar_engraver::do_creation_processing ()
59 {
60   create_bar ();
61   bar_p_->type_str_ = "";
62 }
63
64 void
65 Bar_engraver::do_removal_processing ()
66 {
67   if (bar_p_) 
68     {
69       typeset_element (bar_p_);
70       bar_p_ =0;
71     }
72 }
73
74 void
75 Bar_engraver::do_process_requests()
76 {  
77   if (bar_req_l_) 
78     {
79       if (!bar_p_)
80         create_bar ();    
81
82       bar_p_->type_str_ = bar_req_l_->type_str_;
83     }
84   else 
85     {
86       Time_description const *time = get_staff_info().time_C_;
87       String always = get_property ("barAlways");
88       if ((time && !time->whole_in_measure_) || always.length_i ()) 
89         create_bar ();
90     }
91
92   
93   
94   if (!bar_p_)
95     {
96       Break_req r;
97       r.penalty_i_ = Break_req::DISALLOW;
98       daddy_grav_l ()->try_music (&r);
99     }
100 }
101
102
103 void 
104 Bar_engraver::do_pre_move_processing()
105 {
106   if (bar_p_) 
107     {
108       typeset_element (bar_p_);
109       bar_p_ =0;
110     }
111 }
112
113 void
114 Bar_engraver::do_post_move_processing()
115 {
116   bar_req_l_ = 0;
117 }
118
119
120
121 ADD_THIS_TRANSLATOR(Bar_engraver);
122
123