]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 426.
authorJoe Neeman <joeneeman@gmail.com>
Tue, 28 Aug 2007 21:51:59 +0000 (07:51 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Tue, 28 Aug 2007 21:51:59 +0000 (07:51 +1000)
Ensure that ties only consider grobs in a NonMusicalColumn if those grobs
belong to the same staff as the ties.

lily/axis-group-interface.cc
lily/include/axis-group-interface.hh
lily/include/tie-formatting-problem.hh
lily/tie-formatting-problem.cc

index 959043274665b2c12916e1a56442dbbf6bf8ea83..b589ff671ec52d8e34db78f10ce5196b1fc1866a 100644 (file)
@@ -323,6 +323,22 @@ Axis_group_interface::generic_group_extent (Grob *me, Axis a)
   return ly_interval2scm (r - my_coord);
 }
 
+/* This is like generic_group_extent, but it only counts the grobs that
+   are children of some other axis-group. This is uncached; if it becomes
+   commonly used, it may be necessary to cache it somehow. */
+Interval
+Axis_group_interface::staff_extent (Grob *me, Grob *refp, Axis ext_a, Grob *staff, Axis parent_a)
+{
+  extract_grob_set (me, "elements", elts);
+  vector<Grob*> new_elts;
+
+  for (vsize i = 0; i < elts.size (); i++)
+    if (elts[i]->common_refpoint (staff, parent_a) == staff)
+      new_elts.push_back (elts[i]);
+
+  return relative_group_extent (new_elts, refp, ext_a);
+}
+
 
 Grob *
 Axis_group_interface::calc_pure_elts_and_common (Grob *me)
index c9b1a58eb09f8b924bcfd57b41da165a1dc100d8..95c4901f34229261facf30338a72dc9b1c651771 100644 (file)
@@ -39,6 +39,7 @@ struct Axis_group_interface
   static void set_axes (Grob *, Axis, Axis);
   static bool has_axis (Grob *, Axis);
   static void get_children (Grob *, vector<Grob*> *);
+  static Interval staff_extent (Grob *me, Grob *ref, Axis, Grob *staff, Axis);
   DECLARE_GROB_INTERFACE();
 };
 
index cb7d8c6e1632b51c3bc61db0af335c5d38b4f558..69b49322b01c9073525b067cfd2bece76d5e02a1 100644 (file)
@@ -47,6 +47,7 @@ class Tie_formatting_problem
   Tie_configuration_map possibilities_;
 
   Grob *x_refpoint_;
+  Grob *y_refpoint_;
 
   
   Tie_configuration *get_configuration (int position, Direction dir, Drul_array<int> cols, bool tune_y) const;
index 51bee1b6cf3b555f23eb9feb342e98af2871759d..c9e2e30fbbbce5e5ee6622ce68eafc4fcb9013c4 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "tie-formatting-problem.hh"
 
+#include "axis-group-interface.hh"
 #include "paper-column.hh"
 #include "bezier.hh" 
 #include "directional-element-interface.hh"
@@ -61,6 +62,7 @@ Tie_formatting_problem::get_attachment (Real y, Drul_array<int> columns) const
 Tie_formatting_problem::Tie_formatting_problem ()
 {
   x_refpoint_ = 0;
+  y_refpoint_ = 0;
   use_horizontal_spacing_ = true;
 }
 
@@ -231,9 +233,11 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds,
   chord_outlines_[key] = Skyline (boxes, details_.skyline_padding_, Y_AXIS, -dir);
   if (bounds[0]->break_status_dir ())
     {
-      Real x = robust_relative_extent (bounds[0],  x_refpoint_, X_AXIS)[-dir];
-      
-      chord_outlines_[key].set_minimum_height (x);
+      Interval iv (Axis_group_interface::staff_extent (bounds[0], x_refpoint_, X_AXIS, y_refpoint_, Y_AXIS));
+      if (iv.is_empty ())
+       iv.add_point (bounds[0]->relative_coordinate (x_refpoint_, X_AXIS));
+
+      chord_outlines_[key].set_minimum_height (iv[-dir]);
     }
   else
     {
@@ -303,10 +307,20 @@ Tie_formatting_problem::from_ties (vector<Grob*> const &ties)
     return;
   
   x_refpoint_ = ties[0];
+  y_refpoint_ = ties[0];
   for (vsize i = 0; i < ties.size (); i++)
     {
-      x_refpoint_ = dynamic_cast<Spanner*> (ties[i])->get_bound (LEFT)->common_refpoint (x_refpoint_, X_AXIS); 
-      x_refpoint_ = dynamic_cast<Spanner*> (ties[i])->get_bound (RIGHT)->common_refpoint (x_refpoint_, X_AXIS); 
+      Spanner *tie = dynamic_cast<Spanner*> (ties[i]);
+      Item *l = tie->get_bound (LEFT);
+      Item *r = tie->get_bound (RIGHT);
+
+      x_refpoint_ = l->common_refpoint (x_refpoint_, X_AXIS); 
+      x_refpoint_ = r->common_refpoint (x_refpoint_, X_AXIS);
+
+      if (!l->break_status_dir ())
+       y_refpoint_ = l->common_refpoint (y_refpoint_, Y_AXIS); 
+      if (!r->break_status_dir ())
+       y_refpoint_ = r->common_refpoint (y_refpoint_, Y_AXIS); 
     }
 
   details_.from_grob (ties[0]);
@@ -378,11 +392,19 @@ Tie_formatting_problem::from_semi_ties (vector<Grob*> const &semi_ties, Directio
       specifications_.push_back (spec);
     }
 
-  x_refpoint_ = semi_ties [0];
+  x_refpoint_ = semi_ties[0];
+  y_refpoint_ = semi_ties[0];
+
   for (vsize i = 0; i < semi_ties.size (); i++)
-    x_refpoint_ = semi_ties[i]->common_refpoint (x_refpoint_, X_AXIS); 
+    {
+      x_refpoint_ = semi_ties[i]->common_refpoint (x_refpoint_, X_AXIS); 
+      y_refpoint_ = semi_ties[i]->common_refpoint (y_refpoint_, Y_AXIS); 
+    }
   for (vsize i = 0; i < heads.size (); i++)
-    x_refpoint_ = heads[i]->common_refpoint (x_refpoint_, X_AXIS); 
+    {
+      x_refpoint_ = heads[i]->common_refpoint (x_refpoint_, X_AXIS); 
+      y_refpoint_ = heads[i]->common_refpoint (y_refpoint_, Y_AXIS) ;
+    }
 
   set_chord_outline (heads, head_dir);