]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix bugs with aligning on main part of the NoteColumn
authorJanek Warchoł <lemniskata.bernoullego@gmail.com>
Sun, 17 Aug 2014 14:14:11 +0000 (16:14 +0200)
committerJanek Warchoł <lemniskata.bernoullego@gmail.com>
Wed, 27 Aug 2014 07:43:06 +0000 (09:43 +0200)
NoteColumns may contain either noteheads or rests, so the function
was changed to handle the case when NoteColumn contains only rest.

ly_scm2bool returns true when the argument is unset - that's not
what we want: unset properties should evaluate to false.

lily/include/note-column.hh
lily/note-column.cc
lily/self-alignment-interface.cc

index 9fdabd296247388778aa3588783f7d8ea5883bb1..6f688c09ffab6888e131e3271c76fc3b64969237 100644 (file)
@@ -36,7 +36,7 @@ public:
   static Grob *accidentals (Grob *me);
   static Slice head_positions_interval (Grob *me);
   static Grob *first_head (Grob *me);
-  static Interval calc_main_heads_extent (Grob *me);
+  static Interval calc_main_extent (Grob *me);
   static Grob *get_rest (Grob *me);
   static void set_stem (Grob *me, Grob *);
   static void add_head (Grob *me, Grob *);
index c5d06cfb6831a6bd678c27289132a0120129c349..760e37dc1956c045d51d3250bee9fad5269ee73b 100644 (file)
@@ -158,22 +158,29 @@ Note_column::first_head (Grob *me)
 
 /*
   Return extent of the noteheads in the "main column",
-  i.e. excluding any suspended noteheads.
+  (i.e. excluding any suspended noteheads), or extent
+  of the rest (if there are no heads).
 */
 Interval
-Note_column::calc_main_heads_extent (Grob *me)
+Note_column::calc_main_extent (Grob *me)
 {
-  if (get_stem (me))
-    return first_head (me)->extent (me, X_AXIS);
-  else
-    {
-      // no stems => no suspended noteheads.
-      extract_grob_set (me, "note-heads", heads);
-      if (heads.size())
-        return heads[0]->extent (me, X_AXIS);
-      else
-        return Interval (0, 0);
-    }
+    Grob *main_head;
+    if (get_stem (me))
+        main_head = first_head (me);
+    else
+      {
+        // no stems => no suspended noteheads.
+        extract_grob_set (me, "note-heads", heads);
+        if (heads.size())
+        main_head = heads[0];
+      }
+    Grob *main_item = main_head
+            ? main_head
+            : Grob::unsmob (me->get_object ("rest"));
+
+    return main_item
+            ? main_item->extent (me, X_AXIS)
+            : Interval (0, 0);
 }
 
 /*
index 9c73b6c7d8cf8cd6bf458b9648964150a28378b4..6b6662641f95bdde975af004bf9137557514fc0e 100644 (file)
@@ -115,9 +115,9 @@ Self_alignment_interface::aligned_on_parent (Grob *me, Axis a)
               (him, ly_symbol2scm ("note-column-interface"), a);
   else
     {
-      if (ly_scm2bool(me->internal_get_property (ly_symbol2scm ("X-align-on-main-noteheads")))
+      if (to_boolean (me->get_property ("X-align-on-main-noteheads"))
           && Note_column::has_interface (him))
-        he = Note_column::calc_main_heads_extent(him);
+        he = Note_column::calc_main_extent(him);
       else
         he = him->extent (him, a);
     }