X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbar-engraver.cc;h=2aa490405442f7d750a4c35584544871e8043b80;hb=8002fa018c81f70585c25232247c6dcba7f5cba0;hp=434f5bb88da82269816579573415ab56cbce8f23;hpb=67a763d2c94cf4e24c01186d9f2df06b31778778;p=lilypond.git diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index 434f5bb88d..2aa4904054 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -7,14 +7,15 @@ Jan Nieuwenhuizen */ +#include "score-engraver.hh" #include "bar-engraver.hh" #include "staff-bar.hh" #include "musical-request.hh" #include "multi-measure-rest.hh" #include "command-request.hh" -#include "time-description.hh" -#include "engraver-group.hh" -#include "repeated-music.hh" +#include "timing-engraver.hh" +#include "engraver-group-engraver.hh" +#include "warn.hh" Bar_engraver::Bar_engraver() { @@ -22,21 +23,6 @@ Bar_engraver::Bar_engraver() do_post_move_processing(); } -bool -Bar_engraver::do_try_music (Music*r_l) -{ - if (Bar_req * b= dynamic_cast (r_l)) - { - if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh? - return false; - - bar_req_l_ = b; - return true; - } - - return false; - -} @@ -63,12 +49,23 @@ Bar_engraver::create_bar () { bar_p_->set_elt_property (at_line_start_scm_sym, SCM_BOOL_T); } - announce_element (Score_element_info (bar_p_, bar_req_l_)); + prop = get_property ("barSize", 0); + if (prop.isnum_b ()) + { + bar_p_->set_elt_property (bar_size_scm_sym, + gh_double2scm (Real(prop))); + } + announce_element (Score_element_info (bar_p_, 0)); } } +/** + Make a barline. If there are both |: and :| requested, merge them + to :|:. + +*/ void -Bar_engraver::request_bar (String type_str) +Bar_engraver::request_bar (String requested_type) { Scalar prop = get_property ("barAtLineStart", 0); if (!now_mom ()) @@ -77,19 +74,22 @@ Bar_engraver::request_bar (String type_str) if (!prop.to_bool ()) return; } + bool bar_existed = bar_p_; create_bar (); - if (((type_str == "|:") && (bar_p_->type_str_ == ":|")) - || ((type_str == ":|") && (bar_p_->type_str_ == "|:"))) + if (bar_existed && requested_type == "") + { + return; + } + else if (((requested_type == "|:") && (bar_p_->type_str_ == ":|")) + || ((requested_type == ":|") && (bar_p_->type_str_ == "|:"))) bar_p_->type_str_ = ":|:"; else - bar_p_->type_str_ = type_str; + bar_p_->type_str_ = requested_type; } void Bar_engraver::do_creation_processing () { - create_bar (); - bar_p_->type_str_ = ""; } void @@ -105,33 +105,30 @@ Bar_engraver::do_removal_processing () void Bar_engraver::do_process_requests() { - Time_description const *time = get_staff_info().time_C_; - if (bar_req_l_) - { - create_bar (); - bar_p_->type_str_ = bar_req_l_->type_str_; - } - else if (!now_mom ()) - { - create_bar (); - bar_p_->type_str_ = "|"; - } - else + Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver"); + + Timing_engraver * te = dynamic_cast(t); + String which = (te) ? te->which_bar () : ""; + + if (which.length_i ()) { - Scalar nonauto = get_property ("barNonAuto", 0); - if (!nonauto.to_bool ()) - { - Scalar always = get_property ("barAlways", 0); - if ((time && !time->whole_in_measure_) || always.to_bool ()) - create_bar (); - } + create_bar(); + bar_p_->type_str_ = which; } if (!bar_p_) { - Break_req r; - r.penalty_i_ = Break_req::DISALLOW; - daddy_grav_l ()->try_music (&r); + Score_engraver * e = 0; + Translator * t = daddy_grav_l (); + for (; !e && t; t = t->daddy_trans_l_) + { + e = dynamic_cast (t); + } + + if (!e) + programming_error ("No score engraver!"); + else + e->forbid_breaks (); } } @@ -146,14 +143,6 @@ Bar_engraver::do_pre_move_processing() } } -void -Bar_engraver::do_post_move_processing() -{ - bar_req_l_ = 0; -} - - - ADD_THIS_TRANSLATOR(Bar_engraver);