]> git.donarmstrong.com Git - lilypond.git/commitdiff
Adds ly:generic-bound-extent function.
authorMike Solomon <mike@mikesolomon.org>
Thu, 31 Oct 2013 07:40:23 +0000 (08:40 +0100)
committerMike Solomon <mike@mikesolomon.org>
Thu, 31 Oct 2013 07:40:23 +0000 (08:40 +0100)
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 [new file with mode: 0644]
lily/axis-group-interface-scheme.cc
scm/output-lib.scm

diff --git a/input/regression/bend-bound.ly b/input/regression/bend-bound.ly
new file mode 100644 (file)
index 0000000..bceb105
--- /dev/null
@@ -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 >>
+}
index 69b7c82fdf430dbcf8382e0ada7361b20892d2d9..68b3dd3746fcf97ebd33d826dfbdc327dc0b2680 100644 (file)
@@ -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"
index 02170918a1bec6af6e72481c9f7256c59ba651fc..89d20b95509febf0f89ce443f0bd26282f9d5c29 100644 (file)
@@ -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))