]> git.donarmstrong.com Git - lilypond.git/commitdiff
use X-parents to align MMRNumbers, MMRTexts and PercentRepeatCounters
authorJanek Warchoł <lemniskata.bernoullego@gmail.com>
Mon, 8 Apr 2013 13:58:08 +0000 (15:58 +0200)
committerJanek Warchoł <lemniskata.bernoullego@gmail.com>
Sat, 28 Jun 2014 12:34:29 +0000 (14:34 +0200)
It makes more sense to use X-parents than Y-parents for horizontal
alignment. To be able to do this, we have to ensure that X-parents of
MultiMeasureRestNumber, MultiMeasureRestText and PercentRepeatCounter
won't be overwritten by set_bound (these grobs are spanners).  We can
do this because parents of these grobs are spanners as well.

Expected changes in output: none.

lily/include/self-alignment-interface.hh
lily/multi-measure-rest-engraver.cc
lily/percent-repeat-engraver.cc
lily/self-alignment-interface.cc
lily/spanner.cc
scm/define-grobs.scm

index 2b34b39eff78b1dd47b09d10b66c54c8555e86bc..823556a4c2f7ac30ec930927955423b958faf19d 100644 (file)
@@ -41,7 +41,6 @@ struct Self_alignment_interface
   DECLARE_SCHEME_CALLBACK (centered_on_note_columns, (SCM element));
   DECLARE_SCHEME_CALLBACK (centered_on_x_parent, (SCM element));
   DECLARE_SCHEME_CALLBACK (centered_on_y_parent, (SCM element));
-  DECLARE_SCHEME_CALLBACK (x_centered_on_y_parent, (SCM element));
   DECLARE_SCHEME_CALLBACK (aligned_on_x_parent, (SCM element));
   DECLARE_SCHEME_CALLBACK (aligned_on_y_parent, (SCM element));
 };
index 9f460dd981871ea7ab640838d49b5dc71aaf1dd1..3b968e654f87a2c5f3276d4426929e4140df9a9e 100644 (file)
@@ -146,6 +146,7 @@ Multi_measure_rest_engraver::process_music ()
         {
           Side_position_interface::add_support (numbers_[i], mmrest_);
           numbers_[i]->set_parent (mmrest_, Y_AXIS);
+          numbers_[i]->set_parent (mmrest_, X_AXIS);
         }
 
       start_measure_
index 008081f138f4ee897e2814cf062d04d9292801ac..98d840e0c72c2a13dd104975fef39f836e16f2f3 100644 (file)
@@ -133,6 +133,7 @@ Percent_repeat_engraver::process_music ()
           percent_counter_->set_bound (LEFT, col);
           Side_position_interface::add_support (percent_counter_, percent_);
           percent_counter_->set_parent (percent_, Y_AXIS);
+          percent_counter_->set_parent (percent_, X_AXIS);
         }
       else
         percent_counter_ = 0;
index f04eb19d1073592a84c7f0416c80af378b267ce3..eb51dc7f1b4e981902ddaf35a0d68ed2516dbb4f 100644 (file)
@@ -107,13 +107,6 @@ Self_alignment_interface::centered_on_y_parent (SCM smob)
   return centered_on_object (unsmob_grob (smob)->get_parent (Y_AXIS), Y_AXIS);
 }
 
-MAKE_SCHEME_CALLBACK (Self_alignment_interface, x_centered_on_y_parent, 1);
-SCM
-Self_alignment_interface::x_centered_on_y_parent (SCM smob)
-{
-  return centered_on_object (unsmob_grob (smob)->get_parent (Y_AXIS), X_AXIS);
-}
-
 MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_x_parent, 1);
 SCM
 Self_alignment_interface::aligned_on_x_parent (SCM smob)
index 5d0485f46e4007bc519a242415957a90fc02e92e..7c36f1755b5701a45d2ea42aea9b7b0bf7a60963 100644 (file)
@@ -183,6 +183,10 @@ Spanner::get_bound (Direction d) const
 /*
   Set the items that this spanner spans. If D == LEFT, we also set the
   X-axis parent of THIS to S.
+
+  For example, when a slur crosses a line break, it's broken into two
+  pieces.  The second piece shouldn't be positioned relative to the
+  original NoteColumn, but rather to the PaperColumn after the break.
 */
 void
 Spanner::set_bound (Direction d, Grob *s)
@@ -200,7 +204,14 @@ Spanner::set_bound (Direction d, Grob *s)
      We check for System to prevent the column -> line_of_score
      -> column -> line_of_score -> etc situation */
   if (d == LEFT && !dynamic_cast<System *> (this))
-    set_parent (i, X_AXIS);
+    /*
+      If the X-parent is a spanner, it will be split across linebreaks, too,
+      so we shouldn't have to overwrite it with the bound. Also, we need
+      original parent for alignment.
+      This happens e.g. for MultiMeasureRestNumbers and PercentRepeatCounters.
+    */
+    if (!dynamic_cast <Spanner *> (this->get_parent (X_AXIS)))
+      set_parent (i, X_AXIS);
 
   /*
     Signal that this column needs to be kept alive. They need to be
index 62473075ded4b03a25a147420bd720e27fd34a0a..aa3e605aeb60423810836df9cbdf49cf70badc37 100644 (file)
         (X-offset . ,(ly:make-simple-closure
                       `(,+
                         ,(ly:make-simple-closure
-                          (list ly:self-alignment-interface::centered-on-y-parent))
+                          (list ly:self-alignment-interface::centered-on-x-parent))
                         ,(ly:make-simple-closure
                           (list ly:self-alignment-interface::x-aligned-on-self)))))
         (Y-offset . ,side-position-interface::y-aligned-side)
                         ,(ly:make-simple-closure
                           (list ly:self-alignment-interface::x-aligned-on-self))
                         ,(ly:make-simple-closure
-                          (list ly:self-alignment-interface::x-centered-on-y-parent)))))
+                          (list ly:self-alignment-interface::centered-on-x-parent)))))
         (Y-offset . ,side-position-interface::y-aligned-side)
         (vertical-skylines . ,grob::unpure-vertical-skylines-from-stencil)
         (Y-extent . ,grob::always-Y-extent-from-stencil)
         (X-offset . ,(ly:make-simple-closure
                       `(,+
                         ,(ly:make-simple-closure
-                          (list ly:self-alignment-interface::x-centered-on-y-parent))
+                          (list ly:self-alignment-interface::centered-on-x-parent))
                         ,(ly:make-simple-closure
                           (list ly:self-alignment-interface::x-aligned-on-self)))))
         (Y-offset . ,side-position-interface::y-aligned-side)
         (X-offset . ,(ly:make-simple-closure
                       `(,+
                         ,(ly:make-simple-closure
-                          (list ly:self-alignment-interface::x-centered-on-y-parent))
+                          (list ly:self-alignment-interface::centered-on-x-parent))
                         ,(ly:make-simple-closure
                           (list ly:self-alignment-interface::x-aligned-on-self)))))
         (Y-offset . ,side-position-interface::y-aligned-side)