lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix for Issue 620. (issue4814041)


From: mtsolo
Subject: Fix for Issue 620. (issue4814041)
Date: Wed, 20 Jul 2011 15:02:07 +0000

Reviewers: ,

Description:
Fix for Issue 620.

Well, kinda...  It fixes all of the issues merged into it, but this
could be more generic.

Please review this at http://codereview.appspot.com/4814041/

Affected files:
  M lily/axis-group-interface.cc
  M lily/hairpin.cc
  M lily/include/axis-group-interface.hh
  M lily/line-spanner.cc
  M scm/define-grob-properties.scm
  M scm/define-grobs.scm


Index: lily/axis-group-interface.cc
diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc
index 0b399fd2482e5fa8ef9da603a416471dd9281ac8..9d9001f85181222d5db91c4b73960add9cb3ea99 100644
--- a/lily/axis-group-interface.cc
+++ b/lily/axis-group-interface.cc
@@ -73,7 +73,14 @@ Axis_group_interface::has_axis (Grob *me, Axis a)

 Interval
 Axis_group_interface::relative_group_extent (vector<Grob*> const &elts,
-                                            Grob *common, Axis a)
+                                             Grob *common, Axis a)
+{
+  return relative_maybe_core_group_extent (elts, common, a, false);
+}
+
+Interval
+Axis_group_interface::relative_maybe_core_group_extent (vector<Grob*> const &elts, + Grob *common, Axis a, bool core)
 {
   Interval r;
   for (vsize i = 0; i < elts.size (); i++)
@@ -81,7 +88,9 @@ Axis_group_interface::relative_group_extent (vector<Grob*> const &elts,
       Grob *se = elts[i];
       if (!to_boolean (se->get_property ("cross-staff")))
        {
-         Interval dims = se->extent (common, a);
+         Interval dims = (core && has_interface (se)
+                          ? generic_core_extent (se, common, a)
+                          : se->extent (common, a));
          if (!dims.is_empty ())
            r.unite (dims);
        }
@@ -401,6 +410,29 @@ Axis_group_interface::generic_group_extent (Grob *me, Axis a)
   return ly_interval2scm (r - my_coord);
 }

+Interval
+Axis_group_interface::generic_core_extent (Grob *me, Grob *common, Axis a)
+{
+  /* trigger the callback to do skyline-spacing on the children */
+  if (a == Y_AXIS)
+    (void) me->get_property ("vertical-skylines");
+
+  extract_grob_set (me, "elements", elts);
+  vector<Grob*> new_elts;
+
+  SCM interfaces = me->get_property ("core-interfaces");
+
+  for (vsize i = 0; i < elts.size (); i++)
+    for (SCM l = interfaces; scm_is_pair (l); l = scm_cdr (l))
+      if (elts[i]->internal_has_interface (scm_car (l)))
+        new_elts.push_back (elts[i]);
+
+  if (!common)
+    common = common_refpoint_of_array (new_elts, me, a);
+
+  return relative_maybe_core_group_extent (new_elts, common, a, true);
+}
+
 /* 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. */
@@ -804,6 +836,7 @@ ADD_INTERFACE (Axis_group_interface,
               "adjacent-pure-heights "
               "axes "
               "default-staff-staff-spacing "
+              "core-interfaces "
               "elements "
               "max-stretch "
               "no-alignment "
Index: lily/hairpin.cc
diff --git a/lily/hairpin.cc b/lily/hairpin.cc
index 399b5d995e8876f37aec2622a947435bcdc35507..0d06270f3d773845529f812d38ee63d247ed5306 100644
--- a/lily/hairpin.cc
+++ b/lily/hairpin.cc
@@ -19,6 +19,7 @@

 #include "hairpin.hh"

+#include "axis-group-interface.hh"
 #include "dimensions.hh"
 #include "international.hh"
 #include "line-interface.hh"
@@ -140,7 +141,9 @@ Hairpin::print (SCM smob)
                    }
                }

-             Interval e = robust_relative_extent (b, common, X_AXIS);
+             Interval e = (Axis_group_interface::has_interface (b)
+ ? Axis_group_interface::generic_core_extent (b, common, X_AXIS)
+                            : robust_relative_extent (b, common, X_AXIS));
              if (neighbor_found)
                {
                  if (Hairpin::has_interface (adjacent))
Index: lily/include/axis-group-interface.hh
diff --git a/lily/include/axis-group-interface.hh b/lily/include/axis-group-interface.hh index fa662020967bfbe57f6234c2ef9cded251b94225..fddf77e3477cdf11415bf21663effd5fd2197754 100644
--- a/lily/include/axis-group-interface.hh
+++ b/lily/include/axis-group-interface.hh
@@ -28,6 +28,7 @@
 struct Axis_group_interface
 {
   static SCM generic_group_extent (Grob *me, Axis a);
+  static Interval generic_core_extent (Grob *me, Grob *common, Axis a);
   static Interval pure_group_height (Grob *me, int start, int end);
   DECLARE_SCHEME_CALLBACK (width, (SCM smob));
   DECLARE_SCHEME_CALLBACK (calc_x_common, (SCM smob));
@@ -46,6 +47,8 @@ struct Axis_group_interface
   DECLARE_SCHEME_CALLBACK (calc_pure_y_common, (SCM));
   static Interval relative_group_extent (vector<Grob*> const &list,
                                         Grob *common, Axis);
+ static Interval relative_maybe_core_group_extent (vector<Grob*> const &list,
+                                                   Grob *common, Axis, bool);
   static Interval relative_pure_height (Grob *me, int start, int end);
   static Interval combine_pure_heights (Grob *me, SCM, int, int);
   static Interval sum_partial_pure_heights (Grob *me, int, int);
Index: lily/line-spanner.cc
diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc
index d55c01ff45b8e391bcb45ffa91970a164d8d35a2..04f7bd6b173b5485be3f17b882473e59a025e448 100644
--- a/lily/line-spanner.cc
+++ b/lily/line-spanner.cc
@@ -25,6 +25,7 @@
 #include "lily-proto.hh"
 #include "line-interface.hh"
 #include "output-def.hh"
+#include "paper-column.hh"
 #include "pointer-group-interface.hh"
 #include "spanner.hh"
 #include "staff-symbol-referencer.hh"
@@ -108,9 +109,11 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir)
              ? columns[0] : columns.back();
        }

+      Interval extent = (Paper_column::has_interface (bound_item)
+ ? Axis_group_interface::generic_core_extent (bound_grob, commonx, X_AXIS) + : robust_relative_extent (bound_grob, commonx, X_AXIS));
       details = scm_acons (ly_symbol2scm ("X"),
-                          scm_from_double (robust_relative_extent (bound_grob, 
commonx, X_AXIS)
-                                           .linear_combination (attach)),
+                          scm_from_double (extent.linear_combination (attach)),
                           details);
     }

Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index 40732d0e9d10997850ade1bc6b85a168fad765f8..538b613f4a8735668f531835029c592f2c502cdb 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -997,6 +997,7 @@ bounds are spaced.")

      (columns ,ly:grob-array? "An array of grobs, typically containing
 @code{PaperColumn} or @code{NoteColumn} objects.")
+     (core-interfaces ,list "Core interfaces to be used for positioning.")
      (conditional-elements ,ly:grob-array? "Internal use only.")
      (covered-grobs ,ly:grob-array? "Grobs that could potentially collide
 with a beam.")
Index: scm/define-grobs.scm
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 393bc7c187ebaf3d165070c7713431aeb18a2295..5b27782320e00c9b10dbae95d821fd26d803369a 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -1413,6 +1413,7 @@
     (NoteColumn
      . (
        (axes . (,X ,Y))
+       (core-interfaces . (rhythmic-head-interface stem-interface))
        (horizontal-skylines . ,ly:separation-item::calc-skylines)
        (skyline-vertical-padding . 0.15)
        (X-extent . ,ly:axis-group-interface::width)
@@ -1517,6 +1518,7 @@
        (allow-loose-spacing . #t)
        (axes . (,X))
        (before-line-breaking . ,ly:paper-column::before-line-breaking)
+       (core-interfaces . (note-column-interface))
        (horizontal-skylines . ,ly:separation-item::calc-skylines)
        (keep-inside-line . #t)
        ;; (stencil . ,ly:paper-column::print)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]