lilypond-0.1.16
[lilypond.git] / lily / bar-grav.cc
blob0e34557667f75a487e47ad924444b48bfba10960
1 /*
2 bar-reg.cc -- implement Bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "bar-grav.hh"
10 #include "bar.hh"
11 #include "command-request.hh"
12 #include "time-description.hh"
13 #include "engraver-group.hh"
15 Bar_engraver::Bar_engraver()
17 do_post_move_processing();
20 bool
21 Bar_engraver::do_try_request (Request*r_l)
23 Command_req* c_l = r_l->command();
24 if (!c_l|| !c_l->bar())
25 return false;
26 Bar_req * b= c_l->bar();
27 if (bar_req_l_ && bar_req_l_->equal_b (b))
28 return false;
30 bar_req_l_ = b;
32 return true;
35 void
36 Bar_engraver::do_process_requests()
38 if (bar_p_)
39 return ;
41 if (bar_req_l_)
43 bar_p_ = new Bar;
44 bar_p_->type_str_=bar_req_l_->type_str_;
46 else
48 Time_description const *time = get_staff_info().time_C_;
49 if (time && !time->whole_in_measure_)
50 bar_p_ = new Bar;
53 if (bar_p_)
55 announce_element (Score_elem_info (bar_p_, bar_req_l_));
57 else
59 Disallow_break_req r;
60 daddy_grav_l()->try_request (&r);
65 void
66 Bar_engraver::do_pre_move_processing()
68 if (bar_p_)
70 typeset_element (bar_p_);
71 bar_p_ =0;
75 void
76 Bar_engraver::do_post_move_processing()
78 bar_req_l_ = 0;
79 bar_p_ =0;
83 IMPLEMENT_IS_TYPE_B1(Bar_engraver,Engraver);
84 ADD_THIS_TRANSLATOR(Bar_engraver);