From b8514b0fc731eb5a53b83d23cbb175e294c38bee Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Fri, 6 Jul 2007 10:19:28 +1000 Subject: [PATCH] better fix for 366 make the VoltaBracketSpanner stuff a bit less hacky --- lily/accidental.cc | 22 +++++++++++++++++++++- lily/axis-group-interface.cc | 1 + lily/include/accidental-interface.hh | 6 +++--- lily/vertical-align-engraver.cc | 1 + lily/volta-engraver.cc | 10 ++-------- scm/define-grob-properties.scm | 2 ++ scm/define-grobs.scm | 2 ++ 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lily/accidental.cc b/lily/accidental.cc index 3e5d0475f7..c22e7af3ce 100644 --- a/lily/accidental.cc +++ b/lily/accidental.cc @@ -41,6 +41,20 @@ Accidental_interface::height (SCM smob) return Grob::stencil_height (smob); } +/* If this gets called before line breaking, we will return a non-trivial + width even if we belong to a tie and won't actually get printed. */ +MAKE_SCHEME_CALLBACK (Accidental_interface, width, 1); +SCM +Accidental_interface::width (SCM smob) +{ + Grob *me = unsmob_grob (smob); + Stencil *s = unsmob_stencil (get_stencil (me)); + + if (s) + return ly_interval2scm (s->extent (X_AXIS)); + return ly_interval2scm (Interval ()); +} + MAKE_SCHEME_CALLBACK (Accidental_interface, pure_height, 3); SCM Accidental_interface::pure_height (SCM smob, SCM start_scm, SCM) @@ -148,7 +162,13 @@ Accidental_interface::print (SCM smob) me->suicide (); return SCM_EOL; } - + + return get_stencil (me); +} + +SCM +Accidental_interface::get_stencil (Grob *me) +{ Font_metric *fm = Font_interface::get_default_font (me); SCM alist = me->get_property ("glyph-name-alist"); diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index b9641d41c3..bd00b28307 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -620,6 +620,7 @@ ADD_INTERFACE (Axis_group_interface, "elements " "keep-fixed-while-stretching " "max-stretch " + "no-alignment " "pure-Y-common " "pure-relevant-items " "pure-relevant-spanners " diff --git a/lily/include/accidental-interface.hh b/lily/include/accidental-interface.hh index a90680537f..93951236cf 100644 --- a/lily/include/accidental-interface.hh +++ b/lily/include/accidental-interface.hh @@ -19,14 +19,14 @@ class Accidental_interface { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_SCHEME_CALLBACK (calc_stencils, (SCM)); DECLARE_SCHEME_CALLBACK (height, (SCM)); + DECLARE_SCHEME_CALLBACK (width, (SCM)); DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM)); DECLARE_GROB_INTERFACE(); static string get_fontcharname (string style, int alteration); - static vector accurate_boxes (Grob *me, - Grob **common); + static vector accurate_boxes (Grob *me, Grob **common); + static SCM get_stencil (Grob *me); }; #endif diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index fe214ac48d..f3cc50d6cf 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -92,6 +92,7 @@ Vertical_align_engraver::qualifies (Grob_info i) const return sz > 0 && Axis_group_interface::has_interface (i.grob ()) && !i.grob ()->get_parent (Y_AXIS) + && !to_boolean (i.grob ()->get_property ("no-alignment")) && Axis_group_interface::has_axis (i.grob (), Y_AXIS); } diff --git a/lily/volta-engraver.cc b/lily/volta-engraver.cc index dad57ca7f4..279eb5eb64 100644 --- a/lily/volta-engraver.cc +++ b/lily/volta-engraver.cc @@ -130,13 +130,7 @@ Volta_engraver::process_music () volta_bracket_->set_property ("text", start_string_); if (!volta_spanner_) - { - volta_spanner_ = make_spanner ("VoltaBracketSpanner", SCM_EOL); - /* ensure that we don't get spanned up by VerticalAlignment. - ugh. this could cause problems if we get moved to Staff context */ - Axis_group_interface::add_element (unsmob_grob (get_property ("rootSystem")), - volta_spanner_); - } + volta_spanner_ = make_spanner ("VoltaBracketSpanner", SCM_EOL); Axis_group_interface::add_element (volta_spanner_, volta_bracket_); } @@ -188,6 +182,6 @@ Volta_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Volta_engraver, bar_line); ADD_TRANSLATOR (Volta_engraver, /* doc */ "Make volta brackets.", - /* create */ "VoltaBracket", + /* create */ "VoltaBracket VoltaBracketSpanner", /* read */ "repeatCommands voltaSpannerDuration stavesFound", /* write */ ""); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index e8ea8998ad..3a6a583f80 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -360,6 +360,8 @@ center of the staff.") to flip the direction of custos stem.") (next ,ly:grob? "Object that is next relation (e.g., the lyric syllable following an extender.") + (no-alignment ,boolean? "If set, don't place this grob in a +VerticalAlignment; rather, place it using its own Y-offset callback") (no-ledgers ,boolean? "If set, don't draw ledger lines on this object.") (no-stem-extend ,boolean? "If set, notes with ledger lines do not diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 0a9b30766f..daacad59d3 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -24,6 +24,7 @@ (alteration . ,accidental-interface::calc-alteration) (stencil . ,ly:accidental-interface::print) (Y-extent . ,ly:accidental-interface::height) + (X-extent . ,ly:accidental-interface::width) (meta . ((class . Item) (interfaces . (accidental-interface font-interface)))))) @@ -2120,6 +2121,7 @@ (outside-staff-priority . 100) (Y-extent . ,ly:axis-group-interface::height) (X-extent . ,ly:axis-group-interface::width) + (no-alignment . ,#t) (meta . ((class . Spanner) (interfaces . (side-position-interface axis-group-interface))) -- 2.39.5