From 0b032b61be1224b2cce061df60aa89ea5aa89c07 Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Thu, 31 Oct 2013 08:40:23 +0100 Subject: [PATCH] Adds ly:generic-bound-extent function. This allows for spanner functions written in Scheme to use bound extents instead of the full extents of their bounds. Adds a regtest to show this at work with BendAfter. Note that this can likely be replaced in the future with horizontal skylines. --- input/regression/bend-bound.ly | 23 +++++++++++++++++++++++ lily/axis-group-interface-scheme.cc | 14 ++++++++++++++ scm/output-lib.scm | 6 +++--- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 input/regression/bend-bound.ly diff --git a/input/regression/bend-bound.ly b/input/regression/bend-bound.ly new file mode 100644 index 0000000000..bceb10564e --- /dev/null +++ b/input/regression/bend-bound.ly @@ -0,0 +1,23 @@ +\version "2.17.30" + +\header { + texidoc = "Bends should not be effected by the full width of a +@code{NonMusicalPaperColumn}. The bends should have identical X +spans in the two examples. +" +} + +music = \repeat unfold 16 { c''4\bendAfter #-4 } +sixteens = \repeat unfold 64 { c'16 } + +\new Score { + << \music \sixteens >> +} + +\new Score \with { + currentBarNumber = #200 + barNumberVisibility = #(every-nth-bar-number-visible 1) + \override BarNumber.break-visibility = #end-of-line-invisible +} { + << \music \sixteens >> +} diff --git a/lily/axis-group-interface-scheme.cc b/lily/axis-group-interface-scheme.cc index 69b7c82fdf..68b3dd3746 100644 --- a/lily/axis-group-interface-scheme.cc +++ b/lily/axis-group-interface-scheme.cc @@ -46,6 +46,20 @@ LY_DEFINE (ly_relative_group_extent, "ly:relative-group-extent", return ly_interval2scm (ext); } +LY_DEFINE (ly_generic_bound_extent, "ly:generic-bound-extent", + 2, 0, 0, (SCM grob, SCM common), + "Determine the extent of @var{grob} relative to @var{common} along" + " the X axis, finding its extent as a bound when it a has" + " @code{bound-alignment-interfaces} property list set and" + " otherwise the full extent.") +{ + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_SMOB (Grob, common, 2); + + Interval ext = Axis_group_interface::generic_bound_extent (unsmob_grob (grob), unsmob_grob (common), X_AXIS); + return ly_interval2scm (ext); +} + LY_DEFINE (ly_axis_group_interface__add_element, "ly:axis-group-interface::add-element", 2, 0, 0, (SCM grob, SCM grob_element), "Set @var{grob} the parent of @var{grob-element} on all axes of" diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 02170918a1..89d20b9550 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -912,8 +912,8 @@ and duration-log @var{log}." (left-x (+ padding (max - (interval-end (ly:grob-robust-relative-extent - left-span common X)) + (interval-end (ly:generic-bound-extent + left-span common)) (if (and dots (close @@ -923,7 +923,7 @@ and duration-log @var{log}." (ly:grob-robust-relative-extent dots common X)) (- INFINITY-INT))))) (right-x (max (- (interval-start - (ly:grob-robust-relative-extent right-span common X)) + (ly:generic-bound-extent right-span common)) padding) (+ left-x minimum-length))) (self-x (ly:grob-relative-coordinate spanner common X)) -- 2.39.5