]> git.donarmstrong.com Git - lilypond.git/commitdiff
Move rehearsal marks, etc. to the top staff.
authorJoe Neeman <joeneeman@gmail.com>
Mon, 10 Aug 2009 00:21:42 +0000 (10:21 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Mon, 10 Aug 2009 12:30:01 +0000 (22:30 +1000)
input/regression/page-spacing-rehearsal-mark.ly [new file with mode: 0644]
lily/grob.cc
lily/include/grob.hh
lily/include/page-layout-problem.hh
lily/include/side-position-interface.hh
lily/include/system.hh
lily/page-layout-problem.cc
lily/side-position-interface.cc
lily/system.cc
lily/vertically-spaced-context-engraver.cc
scm/define-grobs.scm

diff --git a/input/regression/page-spacing-rehearsal-mark.ly b/input/regression/page-spacing-rehearsal-mark.ly
new file mode 100644 (file)
index 0000000..7603d93
--- /dev/null
@@ -0,0 +1,22 @@
+\version "2.13.4"
+
+\header {
+  texidoc = "The space taken up by rehearsal marks is correctly
+accounted for, even though they live in the Score context."
+}
+
+#(set-default-paper-size "a6")
+
+\book {
+  \paper {
+    oddHeaderMarkup = "header"
+    ragged-last-bottom = ##f
+  }
+  \score {
+    <<
+      \new Staff { \mark \markup \column { T A L L M A R K } c'1 \break
+                  \mark \markup \column { T A L L M A R K } c'1 }
+      \new Staff { c'1 \break c'1 }
+    >>
+  }
+}
index ce3e41c76dbcbf826d9191c9e27511edd23f1209..540f279b44d109fcb8679eb4ac7fe176756b2132 100644 (file)
@@ -11,6 +11,7 @@
 #include <cstring>
 
 #include "align-interface.hh"
+#include "axis-group-interface.hh"
 #include "input.hh"
 #include "international.hh"
 #include "item.hh"
@@ -761,3 +762,4 @@ Grob::check_cross_staff (Grob *commony)
 
   return false;
 }
+
index 3a724c8d95ac5141e233584d2752d50bdc51a840..9ff7613561f3b92b62bc88fc4641c00d9a7d8df7 100644 (file)
@@ -54,8 +54,8 @@ public:
   friend SCM ly_grob_basic_properties (SCM);
 
   /* standard callbacks */
-  DECLARE_SCHEME_CALLBACK(x_parent_positioning, (SCM));
-  DECLARE_SCHEME_CALLBACK(y_parent_positioning, (SCM));
+  DECLARE_SCHEME_CALLBACK (x_parent_positioning, (SCM));
+  DECLARE_SCHEME_CALLBACK (y_parent_positioning, (SCM));
   DECLARE_SCHEME_CALLBACK (stencil_height, (SCM smob));
   DECLARE_SCHEME_CALLBACK (stencil_width, (SCM smob));
 
index f5039821f7cefe88f508d977969190c55563b415..74c6ca440f0c49b4cf3d10722b6165dfeee5d254 100644 (file)
@@ -34,7 +34,6 @@ protected:
   SCM find_system_offsets ();
   void distribute_loose_lines (vector<Grob*> const&, vector<Real> const&, Real, Real);
 
-  static Grob* find_vertical_alignment (System*);
   static void build_system_skyline (vector<Grob*> const&, vector<Real> const&, Skyline* up, Skyline* down);
   static vector<Grob*> filter_dead_elements (vector<Grob*> const&);
 
index 0febd15be3ce6d6094cf64a47f9477147d49d0f0..030403572055197c7afe111f382aa20de4b7fcb8 100644 (file)
@@ -27,6 +27,7 @@ public:
   DECLARE_SCHEME_CALLBACK (y_aligned_side, (SCM element, SCM current));
   DECLARE_SCHEME_CALLBACK (pure_y_aligned_side, (SCM element, SCM start, SCM end, SCM current));
   DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM element));
+  DECLARE_SCHEME_CALLBACK (move_to_extremal_staff, (SCM));
 
   static SCM aligned_side (Grob*me, Axis a, bool pure, int start, int end, Real *current_off_ptr);
 
index 3fc805a959c1ea6ca6ad1ab16397ef2b3b3b404e..f69a3cee67b6e1ff4273a6414c9ff3bb53772ed1 100644 (file)
@@ -26,6 +26,8 @@ class System : public Spanner
   
 public:
   Paper_score *paper_score () const;
+  Grob *get_vertical_alignment ();
+  Grob *get_extremal_staff (Direction dir, Interval const&);
   int get_rank () const;
   void do_break_substitution_and_fixup_refpoints ();
   void post_processing ();
index 07013aa2b71a904aabc3d8fb990bbf5e9fba1b81..fb9e27d12bb95f8bf5faa1561af1a5acabf7334d 100644 (file)
@@ -160,26 +160,12 @@ Page_layout_problem::set_footer_height (Real height)
   footer_height_ = height;
 }
 
-Grob*
-Page_layout_problem::find_vertical_alignment (System *sys)
-{
-  extract_grob_set (sys, "elements", elts);
-  for (vsize i = 0; i < elts.size (); ++i)
-    if (Align_interface::has_interface (elts[i]))
-      return elts[i];
-
-  return 0;
-}
-
 void
 Page_layout_problem::append_system (System *sys, Spring const& spring, Real padding)
 {
-  Grob *align = find_vertical_alignment (sys);
+  Grob *align = sys->get_vertical_alignment ();
   if (!align)
-    {
-      sys->programming_error ("no VerticalAlignment in system: can't do vertical spacing");
-      return;
-    }
+    return;
 
   align->set_property ("positioning-done", SCM_BOOL_T);
 
index ed3af0577a8a0e726adfb86f079a58d513a06dda..61ab61f5d4f14990191d6c924c85394fc5611b80 100644 (file)
@@ -13,6 +13,7 @@
 
 using namespace std;
 
+#include "axis-group-interface.hh"
 #include "directional-element-interface.hh"
 #include "grob.hh"
 #include "main.hh"
@@ -23,6 +24,7 @@ using namespace std;
 #include "staff-symbol.hh"
 #include "stem.hh"
 #include "string-convert.hh"
+#include "system.hh"
 #include "warn.hh"
 
 void
@@ -309,6 +311,35 @@ Side_position_interface::get_axis (Grob *me)
   return NO_AXES;
 }
 
+MAKE_SCHEME_CALLBACK (Side_position_interface, move_to_extremal_staff, 1);
+SCM
+Side_position_interface::move_to_extremal_staff (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  System *sys = dynamic_cast<System*> (me->get_system ());
+  Direction dir = Side_position_interface::get_direction (me);
+  if (dir != DOWN)
+    dir = UP;
+
+  Grob *top_staff = sys->get_extremal_staff (dir, me->extent (sys, X_AXIS));
+
+  if (!top_staff)
+    return SCM_BOOL_F;
+
+  // Only move this grob if it is a direct child of the system.  We
+  // are not interested in moving marks from other staves to the top
+  // staff; we only want to move marks from the system to the top
+  // staff.
+  if (sys != me->get_parent (Y_AXIS))
+    return SCM_BOOL_F;
+
+  me->set_parent (top_staff, Y_AXIS);
+  me->flush_extent_cache (Y_AXIS);
+  Axis_group_interface::add_element (top_staff, me);
+  return SCM_BOOL_T;
+}
+
+
 ADD_INTERFACE (Side_position_interface,
               "Position a victim object (this one) next to other objects"
               " (the support).  The property @code{direction} signifies where"
index e0964482fcf91373fb73aaf07aebac53844d7ce3..a43c1b4aacdbe265f81779af44b1cb1a3c08229a 100644 (file)
 #include "all-font-metrics.hh"
 #include "axis-group-interface.hh"
 #include "grob-array.hh"
+#include "hara-kiri-group-spanner.hh"
 #include "international.hh"
 #include "lookup.hh"
 #include "main.hh"
 #include "output-def.hh"
+#include "page-layout-problem.hh"
 #include "paper-column.hh"
 #include "paper-score.hh"
 #include "paper-system.hh"
@@ -172,6 +174,12 @@ System::do_break_substitution_and_fixup_refpoints ()
     {
       System *child = dynamic_cast<System*> (broken_intos_[i]);
       child->all_elements_->remove_duplicates ();
+      for (vsize j = 0; j < child->all_elements_->size (); j++)
+       {
+         Grob *g = child->all_elements_->grob (j);
+
+         (void) g->get_property ("after-line-breaking");
+       }
     }
 
   if (be_verbose_global)
@@ -295,13 +303,6 @@ System::pre_processing ()
 void
 System::post_processing ()
 {
-  for (vsize i = 0; i < all_elements_->size (); i++)
-    {
-      Grob *g = all_elements_->grob (i);
-
-      (void) g->get_property ("after-line-breaking");
-    }
-
   Interval iv (extent (this, Y_AXIS));
   if (iv.is_empty ())
     programming_error ("system with empty extent");
@@ -515,6 +516,49 @@ get_root_system (Grob *me)
   return dynamic_cast<System*> (system_grob); 
 }
 
+Grob *
+System::get_vertical_alignment ()
+{
+  extract_grob_set (this, "elements", elts);
+  Grob *ret = 0;
+  for (vsize i = 0; i < elts.size (); i++)
+    if (Align_interface::has_interface (elts[i]))
+      {
+       if (ret)
+         programming_error ("found multiple vertical alignments in this system");
+       ret = elts[i];
+      }
+
+  if (!ret)
+    programming_error ("didn't find a vertical alignment in this system");
+  return ret;
+}
+
+// Finds the furthest staff in the given direction whose x-extent
+// overlaps with the given interval.
+Grob *
+System::get_extremal_staff (Direction dir, Interval const &iv)
+{
+  Grob *align = get_vertical_alignment ();
+  if (!align)
+    return 0;
+
+  extract_grob_set (align, "elements", elts);
+  vsize start = (dir == UP) ? 0 : elts.size () - 1;
+  vsize end = (dir == UP) ? elts.size () : VPOS;
+  for (vsize i = start; i != end; i += dir)
+    {
+      if (Hara_kiri_group_spanner::has_interface (elts[i]))
+       Hara_kiri_group_spanner::consider_suicide (elts[i]);
+
+      Interval intersection = elts[i]->extent (this, X_AXIS);
+      intersection.intersect (iv);
+      if (elts[i]->is_live () && !intersection.is_empty ())
+       return elts[i];
+    }
+  return 0;
+}
+
 ADD_INTERFACE (System,
               "This is the top-level object: Each object in a score"
               " ultimately has a @code{System} object as its X and"
index 750f2e3721c77e26e623513c2324a916dd99a4dd..bc64f1bc5ce3f66ff064dcbba76ba6c47eeefcf5 100644 (file)
@@ -1,5 +1,6 @@
 /*
   vertically-spaced-contexts-engraver.cc -- implement Vertically_spaced_contexts_engraver
+  TODO: junk this, since we now determine spaceability using Page_layout_problem::is_spaceable.
 
   source file of the GNU LilyPond music typesetter
 
index 9a43c08933dcb46dd6676ae71d27b9fe37673ab1..4e15a0576d5d7fb1f1d412e647394b5f09281a93 100644 (file)
 
     (BarNumber
      . (
+       (after-line-breaking . ,ly:side-position-interface::move-to-extremal-staff)
        ;; want the bar number before the clef at line start.
        (break-align-symbols . (left-edge staff-bar))
 
 
     (MetronomeMark
      . (
+       (after-line-breaking . ,ly:side-position-interface::move-to-extremal-staff)
        (direction . ,UP)
        (extra-spacing-width . (+inf.0 . -inf.0))
        (outside-staff-priority . 1000)
 
     (RehearsalMark
      . (
+       (after-line-breaking . ,ly:side-position-interface::move-to-extremal-staff)
        (baseline-skip . 2)
        (break-align-symbols . (staff-bar clef))
        (break-visibility . ,end-of-line-invisible)
 
     (VoltaBracket
      . (
+       (after-line-breaking . ,ly:side-position-interface::move-to-extremal-staff)
        (direction . ,UP)
        (edge-height . (2.0 . 2.0)) ;; staff-space;
        (font-encoding . fetaNumber)