[Moving the discussion to lilypond-devel.] >> A loop?
Attached a new version of the patch, now using a loop. Werner
diff --git a/lily/horizontal-bracket-engraver.cc b/lily/horizontal-bracket-engraver.cc index 608af35965..a42268a357 100644 --- a/lily/horizontal-bracket-engraver.cc +++ b/lily/horizontal-bracket-engraver.cc @@ -56,10 +56,23 @@ Horizontal_bracket_engraver::listen_note_grouping (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); + // Allow one single-moment bracket. Abbreviating a horizontal bracket's + // `START' span-direction with `L' and `STOP' with `R', this means that we + // can have + // + // LLL...LLR + // + // or + // + // LRRR...RR + // + // events attached to a single moment (we don't take care of the order of + // `L' and `R' events). + if (d == STOP) { pop_count_++; - if (pop_count_ > bracket_stack_.size ()) + if (pop_count_ > bracket_stack_.size () + 1) ev->origin ()->warning (_ ("do not have that many brackets")); } else @@ -68,22 +81,33 @@ Horizontal_bracket_engraver::listen_note_grouping (Stream_event *ev) events_.push_back (ev); } - if (pop_count_ && push_count_) + if (pop_count_ >= 2 && push_count_ >= 2) ev->origin ()->warning (_ ("conflicting note group events")); } void Horizontal_bracket_engraver::acknowledge_note_column (Grob_info gi) { + bool process_single_moment_bracket = pop_count_ && push_count_; + for (vsize i = 0; i < bracket_stack_.size (); i++) { - Side_position_interface::add_support (bracket_stack_[i], gi.grob ()); - Pointer_group_interface::add_grob (bracket_stack_[i], - ly_symbol2scm ("columns"), gi.grob ()); - add_bound_item (bracket_stack_[i], - gi.grob ()); - add_bound_item (text_stack_[i], - gi.grob ()); + // For a single-moment horizontal bracket (which is the most recently + // pushed element on the stack), use the current note column for both + // the left and right bound of the bracket. + int count = (process_single_moment_bracket + && i + 1 == bracket_stack_.size ()) ? 2 : 1; + + for (int j = 0; j < count; j++) + { + Side_position_interface::add_support (bracket_stack_[i], + gi.grob ()); + Pointer_group_interface::add_grob (bracket_stack_[i], + ly_symbol2scm ("columns"), + gi.grob ()); + add_bound_item (bracket_stack_[i], gi.grob ()); + add_bound_item (text_stack_[i], gi.grob ()); + } } }
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel