lilypond-1.3.12
[lilypond.git] / lily / bar-grav.cc
blob33e62ad6a9f28ed39b32f65baa03e700f08dcfa7
1 /*
2 bar-reg.cc -- implement Bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "bar-grav.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"
17 Bar_engraver::Bar_engraver()
19 bar_p_ =0;
20 do_post_move_processing();
23 bool
24 Bar_engraver::do_try_request (Request*r_l)
26 Command_req* c_l = r_l->command();
27 if (!c_l|| !c_l->bar())
28 return false;
29 Bar_req * b= c_l->bar();
30 if (bar_req_l_ && bar_req_l_->equal_b (b))
31 return false;
33 bar_req_l_ = b;
35 return true;
38 void
39 Bar_engraver::create_bar ()
41 if (!bar_p_)
43 bar_p_ = new Bar;
44 bar_p_->break_priority_i_ = 0;
45 announce_element (Score_elem_info (bar_p_, bar_req_l_));
50 void
51 Bar_engraver::do_creation_processing ()
53 create_bar ();
54 bar_p_->type_str_ = "";
57 void
58 Bar_engraver::do_removal_processing ()
60 if (bar_p_)
62 typeset_element (bar_p_);
63 bar_p_ =0;
67 void
68 Bar_engraver::do_process_requests()
70 if (bar_req_l_)
72 if (!bar_p_)
73 create_bar ();
75 bar_p_->type_str_ = bar_req_l_->type_str_;
77 else
79 Time_description const *time = get_staff_info().time_C_;
80 if (time && !time->whole_in_measure_)
81 create_bar ();
84 if (!bar_p_)
86 Break_req r;
87 r.penalty_i_ = Break_req::DISALLOW;
88 daddy_grav_l ()->try_request (&r);
93 void
94 Bar_engraver::do_pre_move_processing()
96 if (bar_p_)
98 typeset_element (bar_p_);
99 bar_p_ =0;
103 void
104 Bar_engraver::do_post_move_processing()
106 bar_req_l_ = 0;
110 IMPLEMENT_IS_TYPE_B1(Bar_engraver,Engraver);
111 ADD_THIS_TRANSLATOR(Bar_engraver);