From f1188a31fa289d58c0b7e7c5a97ab45478571668 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Thu, 5 Jul 2007 18:20:25 +1000 Subject: [PATCH] fix hairpinToBarline --- input/regression/spacing-stem-direction.ly | 3 +++ .../regression/spacing-stem-same-direction.ly | 3 +++ lily/bar-engraver.cc | 20 +++++++++++++++++ lily/dynamic-engraver.cc | 22 +++++++++---------- lily/spanner.cc | 1 + scm/define-grob-properties.scm | 2 ++ 6 files changed, 40 insertions(+), 11 deletions(-) diff --git a/input/regression/spacing-stem-direction.ly b/input/regression/spacing-stem-direction.ly index 5b36a754c1..b36cc2c8ea 100644 --- a/input/regression/spacing-stem-direction.ly +++ b/input/regression/spacing-stem-direction.ly @@ -17,6 +17,9 @@ much to correct." \context Voice \relative c { + \override Score.PaperColumn #'layer = #1 + \override Score.PaperColumn #'stencil = #ly:paper-column::print + %% make sure neutral is down. \override Stem #'neutral-direction = #down \time 16/4 c''4 c c, c' d, c' e, c' f, c' g c a c b c diff --git a/input/regression/spacing-stem-same-direction.ly b/input/regression/spacing-stem-same-direction.ly index 835f53feb3..fd98cac213 100644 --- a/input/regression/spacing-stem-same-direction.ly +++ b/input/regression/spacing-stem-same-direction.ly @@ -9,6 +9,9 @@ two chords have no common head-positions range." \layout { ragged-right = ##t} \relative c'' { + \override Score.PaperColumn #'layer = #1 + \override Score.PaperColumn #'stencil = #ly:paper-column::print + \stemDown \time 12/4 f8[ diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index f480d2624d..2357c087b5 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -12,6 +12,7 @@ #include "score-engraver.hh" #include "warn.hh" #include "item.hh" +#include "spanner.hh" #include "translator.icc" @@ -28,10 +29,13 @@ protected: void stop_translation_timestep (); void process_acknowledged (); + DECLARE_END_ACKNOWLEDGER (spanner); + private: void create_bar (); Item *bar_; + vector spanners_; }; Bar_engraver::Bar_engraver () @@ -67,6 +71,10 @@ Bar_engraver::process_acknowledged () { if (!bar_ && scm_is_string (get_property ("whichBar"))) create_bar (); + + if (bar_) + for (vsize i = 0; i < spanners_.size (); i++) + spanners_[i]->set_bound (RIGHT, bar_); } /* @@ -79,8 +87,20 @@ Bar_engraver::stop_translation_timestep () context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T); bar_ = 0; + spanners_.clear (); +} + +void +Bar_engraver::acknowledge_end_spanner (Grob_info gi) +{ + Grob *g = gi.grob (); + + if (to_boolean (g->get_property ("to-barline"))) + spanners_.push_back (dynamic_cast (g)); } +ADD_END_ACKNOWLEDGER (Bar_engraver, spanner); + ADD_TRANSLATOR (Bar_engraver, /* doc */ "Create barlines. This engraver is controlled through the " "@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point", diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 5de7516024..63536d1193 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -176,6 +176,15 @@ Dynamic_engraver::process_music () } finished_cresc_ = cresc_; + + /* backwards compatibility with hairpinToBarline */ + bool use_bar = to_boolean (get_property ("hairpinToBarline")) + && scm_is_string (get_property ("whichBar")) + && !script_ev_; + + finished_cresc_->set_property ("to-barline", scm_from_bool (use_bar)); + + announce_end_grob (finished_cresc_, SCM_EOL); cresc_ = 0; current_cresc_ev_ = 0; } @@ -335,18 +344,10 @@ Dynamic_engraver::typeset_all () { if (finished_cresc_) { - bool use_bar = to_boolean (get_property ("hairpinToBarline")) - && scm_is_string (get_property ("whichBar")) - && !script_ev_; - - - if (!finished_cresc_->get_bound (RIGHT) - || use_bar) + if (!finished_cresc_->get_bound (RIGHT)) { - Grob *column_bound = unsmob_grob (use_bar - ? get_property ("currentCommandColumn") - : get_property ("currentMusicalColumn")); + Grob *column_bound = unsmob_grob (get_property ("currentMusicalColumn")); finished_cresc_->set_bound (RIGHT, script_ ? script_ @@ -390,7 +391,6 @@ Dynamic_engraver::typeset_all () finished_line_spanner_->set_bound (RIGHT, ci); finished_line_spanner_->set_bound (LEFT, ci); } - finished_line_spanner_ = 0; } } diff --git a/lily/spanner.cc b/lily/spanner.cc index 77ee01074e..53d6693654 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -428,5 +428,6 @@ ADD_INTERFACE (Spanner, "also the X-reference point of the spanner.\n", "minimum-length " + "to-barline " ); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 0cdcf8f825..e8ea8998ad 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -521,6 +521,8 @@ should use @code{LEFT}.") (thin-kern ,number? "The space after a hair-line in a bar line.") (threshold ,number-pair? "@code{(@var{min} . @var{max})}, where @var{min} and @var{max} are dimensions in staff space.") + (to-barline ,boolean? "If true, the spanner will stop at that barline +just before it would otherwise stop.") (tie-configuration ,list? "List of @code{(@var{position} . @var{dir})} pairs, indicating the desired tie configuration, where @var{position} is the offset from the center of the staff in staff -- 2.39.5