X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbar-engraver.cc;h=a70b89db352289ecb2c0d6b22417b4ead155e1b6;hb=e7d84e6728ecfdf74d8f214486a29c2aca199819;hp=e38ad23499bbc842f100535a1ad7105752756e7a;hpb=d6048913c2c793a6298a3e16a1a25c76711463b1;p=lilypond.git diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index e38ad23499..a70b89db35 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -3,17 +3,19 @@ source file of the GNU LilyPond music typesetter - (c) 1997, 1998, 1999 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys 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 "timing-engraver.hh" +#include "engraver-group-engraver.hh" +#include "warn.hh" Bar_engraver::Bar_engraver() { @@ -21,74 +23,63 @@ 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; - -} - - - void Bar_engraver::create_bar () { if (!bar_p_) { bar_p_ = new Staff_bar; - bar_p_->set_elt_property (break_priority_scm_sym, gh_int2scm (0)); - + bar_p_->property_alist_ = get_property ("basicBarlineProperties"); + // urg: "" != empty... - String default_type = get_property ("defaultBarType", 0); - if (default_type.length_i ()) - { - bar_p_->type_str_ = default_type; - } - /* - urg. Why did I implement this? + TODO: use symbol. */ - Scalar prop = get_property ("barAtLineStart", 0); - if (prop.to_bool ()) + SCM default_type = get_property ("defaultBarType"); + if (gh_string_p (default_type)) { - bar_p_->set_elt_property (at_line_start_scm_sym, SCM_BOOL_T); + bar_p_->set_elt_property ("glyph", default_type); // ugh } - announce_element (Score_element_info (bar_p_, bar_req_l_)); + + 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 ()) { - Scalar prop = get_property ("barAtLineStart", 0); - if (!prop.to_bool ()) + SCM prop = get_property ("barAtLineStart"); + if (!to_boolean (prop)) return; } + bool bar_existed = bar_p_; create_bar (); - if (((type_str == "|:") && (bar_p_->type_str_ == ":|")) - || ((type_str == ":|") && (bar_p_->type_str_ == "|:"))) - bar_p_->type_str_ = ":|:"; - else - bar_p_->type_str_ = type_str; + if (bar_existed && requested_type == "") + { + return; + } + + String current = ly_scm2string (bar_p_->get_elt_property ("glyph")); + + if ((requested_type == "|:" && current== ":|") + || (requested_type == ":|" && current == "|:")) + requested_type = ":|:"; + + + bar_p_->set_elt_property ("glyph", + ly_str02scm (requested_type.ch_C ())); } void Bar_engraver::do_creation_processing () { - create_bar (); - bar_p_->type_str_ = ""; } void @@ -102,35 +93,32 @@ Bar_engraver::do_removal_processing () } void -Bar_engraver::do_process_requests() +Bar_engraver::do_process_music() { - 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_->set_elt_property ("glyph", ly_str02scm (which.ch_C ())); } 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 (); } } @@ -145,14 +133,7 @@ Bar_engraver::do_pre_move_processing() } } -void -Bar_engraver::do_post_move_processing() -{ - bar_req_l_ = 0; -} - - - ADD_THIS_TRANSLATOR(Bar_engraver); +