]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fixes issue 307 (intersection between slurs and extra objects).
authorMike Solomon <mike@apollinemike.com>
Sat, 15 Oct 2011 09:47:37 +0000 (11:47 +0200)
committerMike Solomon <mike@apollinemike.com>
Sat, 15 Oct 2011 09:47:37 +0000 (11:47 +0200)
Does this by increasing the slur region based on the height of the
extremal extra encompass object plus a padding controled by
encompass-object-range-overshoot.

input/regression/slur-shift-region.ly [new file with mode: 0644]
lily/include/misc.hh
lily/include/slur-score-parameters.hh
lily/slur-score-parameters.cc
lily/slur-scoring.cc
scm/layout-slur.scm

diff --git a/input/regression/slur-shift-region.ly b/input/regression/slur-shift-region.ly
new file mode 100644 (file)
index 0000000..a563391
--- /dev/null
@@ -0,0 +1,10 @@
+\version "2.15.12"
+
+\header {
+  texidoc = "A slur's shift region is automatically made
+higher to accommodate extra encompass elements."
+}
+
+\relative c' {
+  c'2( \times 2/3 { g4 e c) }
+}
index 0491b5b4a91cd2f90d98a1edbea2d4d00eaea7ac..ce4f4c838b49674a656e985dbd632410e8f2524b 100644 (file)
@@ -53,6 +53,12 @@ linear_interpolate (Real x, Real x1, Real x2, Real y1, Real y2)
          + (x - x1) / (x2 - x1) * y2;
 }
 
+inline Real
+normalize (Real x, Real x1, Real x2)
+{
+  return (x - x1) / (x2 - x1);
+}
+
 Real directed_round (Real f, Direction d);
 
 Real peak_around (Real epsilon, Real threshold, Real x);
index 866de050f4b63e363045d7f79098afb5f186eb4d..a56b9018d85aaa7d21c216c38f81ddb44ac7d353 100644 (file)
@@ -45,6 +45,7 @@ struct Slur_score_parameters
   Real close_to_edge_length_;
   Real head_slur_distance_max_ratio_;
   Real head_slur_distance_factor_;
+  Real encompass_object_range_overshoot_;
 
   void fill (Grob *him);
 };
index fe0a7828e2a44fc68e8d86d7d3924ff9f4367162..8d392ff1dcff49ed235dc08114a43ec07a697c52 100644 (file)
@@ -76,4 +76,6 @@ Slur_score_parameters::fill (Grob *me)
     = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
   close_to_edge_length_
     = get_detail (details, ly_symbol2scm ("close-to-edge-length"));
-}
+  encompass_object_range_overshoot_
+    = get_detail (details, ly_symbol2scm ("encompass-object-range-overshoot"));
+  }
index 5413c047c2cc219f71773a211aa426d0385d4198..d8c7655185fd082796e3b20461faad75cde719a7 100644 (file)
 
 #include "accidental-interface.hh"
 #include "beam.hh"
+#include "clef.hh"
 #include "directional-element-interface.hh"
 #include "libc-extension.hh"
 #include "main.hh"
+#include "misc.hh"
 #include "note-column.hh"
 #include "output-def.hh"
 #include "paper-column.hh"
@@ -38,6 +40,7 @@
 #include "staff-symbol-referencer.hh"
 #include "staff-symbol.hh"
 #include "stem.hh"
+#include "time-signature.hh"
 #include "warn.hh"
 
 /*
@@ -262,15 +265,54 @@ Slur_score_state::fill (Grob *me)
   Drul_array<Real> end_ys
     = get_y_attachment_range ();
 
+  extra_encompass_infos_ = get_extra_encompass_infos ();
+
+  Interval additional_ys (0.0,0.0);
+
+  for (vsize i = 0; i < extra_encompass_infos_.size (); i++)
+    {
+      if (extra_encompass_infos_[i].extents_[X_AXIS].is_empty ())
+        continue;
+
+      Real y_place = linear_interpolate (extra_encompass_infos_[i].extents_[X_AXIS].center (),
+                                         base_attachments_[RIGHT][X_AXIS],
+                                         base_attachments_[LEFT][X_AXIS],
+                                         end_ys[RIGHT],
+                                         end_ys[LEFT]);
+      Real encompass_place = extra_encompass_infos_[i].extents_[Y_AXIS][dir_];
+      if (extra_encompass_infos_[i].type_ == ly_symbol2scm ("inside")
+          && minmax (dir_, encompass_place, y_place) == encompass_place
+          && (!extra_encompass_infos_[i].grob_->internal_has_interface (ly_symbol2scm ("key-signature-interface"))
+              && !Clef::has_interface (extra_encompass_infos_[i].grob_)
+              && !Time_signature::has_interface (extra_encompass_infos_[i].grob_)))
+        {
+          Direction d = LEFT;
+          do
+            additional_ys[d] = minmax (dir_,
+                                       additional_ys[d],
+                                       (dir_
+                                        * (parameters_.encompass_object_range_overshoot_
+                                           + (y_place - encompass_place)
+                                              * (normalize (extra_encompass_infos_[i].extents_[X_AXIS].center (),
+                                                            base_attachments_[RIGHT][X_AXIS],
+                                                            base_attachments_[LEFT][X_AXIS])
+                                               + (dir_ == LEFT ? 0 : -1)))));
+          while (flip (&d) != LEFT);
+        }
+    }
+
+  Direction d = LEFT;
+  do
+    end_ys[d] += additional_ys[d];
+  while (flip (&d) != LEFT);
+
   configurations_ = enumerate_attachments (end_ys);
   for (vsize i = 0; i < columns_.size (); i++)
     encompass_infos_.push_back (get_encompass_info (columns_[i]));
 
-  extra_encompass_infos_ = get_extra_encompass_infos ();
   valid_ = true;
 
   musical_dy_ = 0.0;
-  Direction d = LEFT;
   do
     {
       if (!is_broken_
index 391582bdf6f25dadeac25c0dedb23f7ea40191ba..d0ffe78e0ff1bb65864629cf99a4636b451b6ce0 100644 (file)
@@ -37,4 +37,5 @@
     (absolute-closeness-measure . 0.3)
     (edge-slope-exponent . 1.7)
     (close-to-edge-length . 2.5)
+    (encompass-object-range-overshoot . 0.5)
     ))