2 bar-engraver.cc -- implement Bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997, 1998, 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "score-engraver.hh"
10 #include "bar-engraver.hh"
11 #include "staff-bar.hh"
12 #include "musical-request.hh"
13 #include "multi-measure-rest.hh"
14 #include "command-request.hh"
15 #include "time-description.hh"
16 #include "engraver-group-engraver.hh"
19 Bar_engraver::Bar_engraver()
22 do_post_move_processing();
26 Bar_engraver::do_try_music (Music*r_l)
28 if (Bar_req * b= dynamic_cast <Bar_req *> (r_l))
30 if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
43 Bar_engraver::create_bar ()
47 bar_p_ = new Staff_bar;
48 bar_p_->set_elt_property (break_priority_scm_sym, gh_int2scm (0));
50 // urg: "" != empty...
51 String default_type = get_property ("defaultBarType", 0);
52 if (default_type.length_i ())
54 bar_p_->type_str_ = default_type;
58 urg. Why did I implement this?
60 Scalar prop = get_property ("barAtLineStart", 0);
63 bar_p_->set_elt_property (at_line_start_scm_sym, SCM_BOOL_T);
65 prop = get_property ("barSize", 0);
68 bar_p_->set_elt_property (bar_size_scm_sym,
69 gh_double2scm (Real(prop)));
71 announce_element (Score_element_info (bar_p_, bar_req_l_));
76 Make a barline. If there are both |: and :| requested, merge them
81 Bar_engraver::request_bar (String requested_type)
83 Scalar prop = get_property ("barAtLineStart", 0);
86 Scalar prop = get_property ("barAtLineStart", 0);
90 bool bar_existed = bar_p_;
92 if (bar_existed && requested_type == "")
96 else if (((requested_type == "|:") && (bar_p_->type_str_ == ":|"))
97 || ((requested_type == ":|") && (bar_p_->type_str_ == "|:")))
98 bar_p_->type_str_ = ":|:";
100 bar_p_->type_str_ = requested_type;
104 Bar_engraver::do_creation_processing ()
107 bar_p_->type_str_ = "";
111 Bar_engraver::do_removal_processing ()
115 typeset_element (bar_p_);
121 Bar_engraver::do_process_requests()
123 Time_description const *time = get_staff_info().time_C_;
127 bar_p_->type_str_ = bar_req_l_->type_str_;
129 else if (!now_mom ())
132 bar_p_->type_str_ = "|";
136 Scalar nonauto = get_property ("barNonAuto", 0);
137 if (!nonauto.to_bool ())
139 Scalar always = get_property ("barAlways", 0);
140 if ((time && !time->whole_in_measure_) || always.to_bool ())
147 Score_engraver * e = 0;
148 Translator * t = daddy_grav_l ();
149 for (; !e && t; t = t->daddy_trans_l_)
151 e = dynamic_cast<Score_engraver*> (t);
155 programming_error ("No score engraver!");
163 Bar_engraver::do_pre_move_processing()
167 typeset_element (bar_p_);
173 Bar_engraver::do_post_move_processing()
180 ADD_THIS_TRANSLATOR(Bar_engraver);