]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-engraver.cc
release: 1.1.7
[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 #include "repeated-music.hh"
17
18 Bar_engraver::Bar_engraver()
19 {
20   bar_p_ =0;
21   do_post_move_processing();
22 }
23
24 bool
25 Bar_engraver::do_try_music (Music*r_l)
26 {
27   if (Bar_req  * b= dynamic_cast <Bar_req *> (r_l))
28     {
29       if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
30         return false;
31       
32       bar_req_l_ = b;
33
34       return true;
35     }
36   
37   return false;
38
39 }
40
41 void
42 Bar_engraver::create_bar ()
43 {
44   if (!bar_p_)
45     {
46       bar_p_ = new Bar;
47       bar_p_->break_priority_i_  = 0;
48       String default_type = get_property ("defaultBarType");
49       if (default_type.length_i ())
50         {
51           bar_p_->type_str_ = default_type;
52         }
53       announce_element (Score_element_info (bar_p_, bar_req_l_));
54     }
55 }
56
57
58 void 
59 Bar_engraver::do_creation_processing ()
60 {
61   create_bar ();
62   bar_p_->type_str_ = "";
63 }
64
65 void
66 Bar_engraver::do_removal_processing ()
67 {
68   if (bar_p_) 
69     {
70       typeset_element (bar_p_);
71       bar_p_ =0;
72     }
73 }
74
75 void
76 Bar_engraver::do_process_requests()
77 {  
78   if (bar_req_l_) 
79     {
80       if (!bar_p_)
81         create_bar ();    
82
83       bar_p_->type_str_ = bar_req_l_->type_str_;
84     }
85   else 
86     {
87       Time_description const *time = get_staff_info().time_C_;
88       String always = get_property ("barAlways");
89       if ((time && !time->whole_in_measure_) || always.length_i ()) 
90         create_bar ();
91     }
92
93   
94   
95   if (!bar_p_)
96     {
97       Break_req r;
98       r.penalty_i_ = Break_req::DISALLOW;
99       daddy_grav_l ()->try_music (&r);
100     }
101 }
102
103
104 void 
105 Bar_engraver::do_pre_move_processing()
106 {
107   if (bar_p_) 
108     {
109       typeset_element (bar_p_);
110       bar_p_ =0;
111     }
112 }
113
114 void
115 Bar_engraver::do_post_move_processing()
116 {
117   bar_req_l_ = 0;
118 }
119
120
121
122 ADD_THIS_TRANSLATOR(Bar_engraver);
123
124