]> git.donarmstrong.com Git - lilypond.git/commitdiff
Adds vertical skylines to slurs.
authorMike Solomon <mike@apollinemike.com>
Wed, 28 Dec 2011 08:15:41 +0000 (09:15 +0100)
committerMike Solomon <mike@apollinemike.com>
Wed, 28 Dec 2011 08:18:31 +0000 (09:18 +0100)
This assures that objects with an outside staff priority higher than
that of slurs are placed directly above the slur at their horizontal
position instead of above the slur's extrema in a given direction.

This is done by giving slurs vertical skylines that are the integral of
their curve.  Because the axis-group-interface automatically uses
vertical-skylines, no extra check for this property has to be added.

input/regression/slur-vertical-skylines.ly [new file with mode: 0644]
lily/general-scheme.cc
lily/include/lily-guile.hh
lily/include/slur.hh
lily/lily-guile.cc
lily/slur.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/lily.scm
scm/safe-lily.scm

diff --git a/input/regression/slur-vertical-skylines.ly b/input/regression/slur-vertical-skylines.ly
new file mode 100644 (file)
index 0000000..3fd5183
--- /dev/null
@@ -0,0 +1,16 @@
+\version "2.15.22"
+
+\header {
+  texidoc = "Slurs do not force grobs with outside-staff-priority
+too high.
+"
+}
+
+\relative c' {
+  f8^"rit"( c' f c' f) r8 r4 |
+  c2( c,2 |
+  g1)~\startTrillSpan
+  g1\stopTrillSpan
+  g1(\f
+  g,1)
+}
\ No newline at end of file
index 8a84062bb62ff780a56920f7c41fa3ec2957dd29..e73ab0b9272d7bdf1d3f07d5d7e35d24367ba4e2 100644 (file)
@@ -114,6 +114,18 @@ LY_DEFINE (ly_dir_p, "ly:dir?",
   return SCM_BOOL_F;
 }
 
+LY_DEFINE (ly_vsize_p, "ly:vsize?",
+           1, 0, 0, (SCM s),
+           "Is @var{s} a vsize?")
+{
+  if (scm_is_integer (s))
+    {
+      int i = scm_to_int (s);
+      return i >= 0 ? SCM_BOOL_T : SCM_BOOL_F;
+    }
+  return SCM_BOOL_F;
+}
+
 LY_DEFINE (ly_assoc_get, "ly:assoc-get",
            2, 2, 0,
            (SCM key, SCM alist, SCM default_value, SCM strict_checking),
index 8e6999ca1aa63ae23ebe5ae7f9d749796660df52..0690b073dceb96c522c2ec274efbb7343a83704b 100644 (file)
@@ -72,6 +72,7 @@ char *ly_scm2str0 (SCM str);
 
 Real robust_scm2double (SCM, double);
 int robust_scm2int (SCM, int);
+vsize robust_scm2vsize (SCM, vsize);
 Direction robust_scm2dir (SCM, Direction);
 Drul_array<Real> robust_scm2drul (SCM, Drul_array<Real>);
 Drul_array<bool> robust_scm2booldrul (SCM, Drul_array<bool>);
index 78659c93171a84162cebc92e9ad0231b244f4891..70b68213157db167c540aaa8e6334752268a4e68 100644 (file)
@@ -36,6 +36,7 @@ public:
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
   DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM));
   DECLARE_SCHEME_CALLBACK (height, (SCM));
+  DECLARE_SCHEME_CALLBACK (vertical_skylines, (SCM));
   DECLARE_SCHEME_CALLBACK (outside_slur_callback, (SCM, SCM));
   DECLARE_SCHEME_CALLBACK (pure_outside_slur_callback, (SCM, SCM, SCM, SCM));
   DECLARE_SCHEME_CALLBACK (outside_slur_cross_staff, (SCM, SCM));
index 6aa40f78048eb12c71012e39efdae3f46019bf95..6035a91983303d6284e83d4660c4ada853ef7514 100644 (file)
@@ -565,6 +565,18 @@ robust_scm2int (SCM k, int o)
   return o;
 }
 
+vsize
+robust_scm2vsize (SCM k, vsize o)
+{
+  if (scm_integer_p (k) == SCM_BOOL_T)
+    {
+      o = scm_to_int (k);
+      if (o >= 0)
+        return (vsize) o;
+    }
+  return o;
+}
+
 SCM
 ly_rational2scm (Rational r)
 {
index 91b4e2bb2cd232c10a2f4be46d817cca24b5e23b..6fdbb41d1b68b9361f13796bfd362b058b7d8b33 100644 (file)
@@ -32,6 +32,7 @@
 #include "note-column.hh"
 #include "output-def.hh"
 #include "spanner.hh"
+#include "skyline-pair.hh"
 #include "staff-symbol-referencer.hh"
 #include "stem.hh"
 #include "text-interface.hh"
@@ -373,6 +374,29 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm)
   return scm_from_double (offset + avoidance_offset);
 }
 
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, vertical_skylines, 1, 0, "");
+SCM
+Slur::vertical_skylines (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  vector<Box> boxes;
+
+  if (!me)
+    return Skyline_pair (boxes, 0.0, X_AXIS).smobbed_copy ();
+
+  Bezier curve = Slur::get_curve (me);
+  vsize box_count = robust_scm2vsize (me->get_property ("skyline-quantizing"), 10);
+  for (vsize i = 0; i < box_count; i++)
+    {
+      Box b;
+      b.add_point (curve.curve_point (i * 1.0 / box_count));
+      b.add_point (curve.curve_point ((i + 1) * 1.0 / box_count));
+      boxes.push_back (b);
+    }
+
+  return Skyline_pair (boxes, 0.0, X_AXIS).smobbed_copy ();
+}
+
 /*
  * Used by Slur_engraver:: and Phrasing_slur_engraver::
  */
@@ -546,8 +570,10 @@ ADD_INTERFACE (Slur,
                "inspect-index "
                "line-thickness "
                "note-columns "
+               "skyline-quantizing "
                "positions "
                "ratio "
                "thickness "
+               "vertical-skylines "
               );
 
index b8c4ecc900d1f4485d39e12b96e6e1aa6fcf81b7..cef87c6254021f29da318a7e543788b166ed5d7e 100644 (file)
@@ -1098,6 +1098,8 @@ relevant for finding the @code{pure-Y-extent}.")
 
      (side-support-elements ,ly:grob-array? "The side support, an array of
 grobs.")
+     (skyline-quantizing ,ly:vsize? "The number of boxes to break a
+slur into when calculating its skyline.")
      (slur ,ly:grob? "A pointer to a @code{Slur} object.")
      (spacing ,ly:grob? "The spacing spanner governing this section.")
      (spacing-wishes ,ly:grob-array? "An array of note spacing or staff spacing
index 4c61c7c7fef73f9f19ded1e15fa846d7cf0af91f..0a9a0e73856fb73a67f5f8b91af35ded7426144e 100644 (file)
        (springs-and-rods . ,ly:spanner::set-spacing-rods)
        (stencil . ,ly:slur::print)
        (thickness . 1.1)
+       (vertical-skylines . ,ly:slur::vertical-skylines)
        (Y-extent . ,ly:slur::height)
        (meta . ((class . Spanner)
                 (interfaces . (slur-interface))))))
        (springs-and-rods . ,ly:spanner::set-spacing-rods)
        (stencil . ,ly:slur::print)
        (thickness . 1.2)
+       (vertical-skylines . ,ly:slur::vertical-skylines)
        (Y-extent . ,ly:slur::height)
        (meta . ((class . Spanner)
                 (interfaces . (slur-interface))))))
index e9f728f85416b8b2e6650c4f1765aaf8e295f6af..63582939c545240bd04de3b158fafd506d29661a 100644 (file)
@@ -551,6 +551,7 @@ messages into errors.")
     (,ly:translator? . "translator")
     (,ly:translator-group? . "translator group")
     (,ly:unpure-pure-container? . "unpure/pure container")
+    (,ly:vsize? . "vsize")
     ))
 
 
index 269e99c27023b3aefd69dc0d5c32714510672716..0be4f8c558ea1d98854c4644e3fc49f3637ce007 100644 (file)
    ly:unit
    ly:usage
    ly:version
+   ly:vsize?
    ly:warning
 
    ;; FIXME: cannot change staff size in --safe-mode