]> git.donarmstrong.com Git - lilypond.git/commitdiff
Uses special X alignment for instrument names.
authorMike Solomon <mike@apollinemike.com>
Fri, 29 Mar 2013 04:55:13 +0000 (05:55 +0100)
committerMike Solomon <mike@apollinemike.com>
Fri, 29 Mar 2013 04:55:13 +0000 (05:55 +0100)
Previously, instrument names used the side-position-interface for
calculations in its alignment function.  This made no sense, as it never
had any side-support elements, requiring a kludge to get them to
align properly.

Here, we remove that kludge and align them by aligning them to their
right end and adding padding.  We also change the name of the grob array
in which vertical axis groups are stored to
system-start-text-align-elements so that the grob is not accidentally
treated as an axis-group implementing an elements array.

lily/instrument-name-engraver.cc
lily/side-position-interface.cc
scm/define-grob-interfaces.scm
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/output-lib.scm

index 0abc7e432955bf8306b9f7f6704b02f9e4bdd766..a0b0c2682f8c0deb6697ea59b2818d3ec5c02d6a 100644 (file)
@@ -160,14 +160,14 @@ Instrument_name_engraver::stop_spanner ()
 
   for (vsize i = 0; i < axis_groups_.size (); i++)
     Pointer_group_interface::add_grob (text_spanner_,
-                                       ly_symbol2scm ("elements"),
+                                       ly_symbol2scm ("system-start-text-alignment-elements"),
                                        axis_groups_[i]);
 
   text_spanner_->set_bound (RIGHT,
                             unsmob_grob (get_property ("currentCommandColumn")));
 
   Pointer_group_interface::set_ordered (text_spanner_,
-                                        ly_symbol2scm ("elements"),
+                                        ly_symbol2scm ("system-start-text-alignment-elements"),
                                         false);
 
   text_spanner_ = 0;
index 4d8efe1ced4d0687fe0aa61ddf46fc0d190b8b14..5a8ecb74c91b8eac59f6489995b63daecfee2d80 100644 (file)
@@ -314,16 +314,6 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
       dim.set_minimum_height (staff_extents[dir]);
     }
 
-  // this seems kinda kludgy, as there is no apparent logic to it
-  // however, it is a holdover from the previous code and
-  // necessary for the InstrumentName grob
-  // TODO: find a better way to deal with this...
-  if (dim.is_empty ())
-    {
-      dim = Skyline (dim.direction ());
-      dim.set_minimum_height (0.0);
-    }
-
   // Many cross-staff grobs do not have good height estimations.
   // We give the grob the best chance of not colliding by shifting
   // it to the maximum height in the case of cross-staff alignment.
index 6068579995115078b81526a2793326f97c285de3..df001959ce29ce41ac3c0420f3f57feff1eed08f 100644 (file)
@@ -264,7 +264,8 @@ interesting enough to maintain a hara-kiri staff."
 (ly:add-interface
  'system-start-text-interface
  "Text in front of the system."
- '(long-text self-alignment-X self-alignment-Y text))
+ '(system-start-text-alignment-elements long-text
+   padding self-alignment-X self-alignment-Y text))
 
 (ly:add-interface
  'tab-note-head-interface
index 9afb49a0a32e4c3fb471df85f1ad3aea23f06ca4..c35b5e19098350b29863b885583dc791486abba2 100644 (file)
@@ -1174,6 +1174,8 @@ results, use @code{LEFT} and @code{RIGHT}.")
      (staff-symbol ,ly:grob? "The staff symbol grob that we are in.")
      (stem ,ly:grob? "A pointer to a @code{Stem} object.")
      (stems ,ly:grob-array? "An array of stem objects.")
+     (system-start-text-alignment-elements ,ly:grob-array? "Elements
+used to align system start text.")
 
      (tie ,ly:grob? "A pointer to a @code{Tie} object.")
      (ties ,ly:grob-array? "A grob array of @code{Tie} objects.")
index 19a767fba5cd980145fa33cd578053e3c606873b..5ff4c7f803802e701c096c6bdb07220d03b3f64c 100644 (file)
        (direction . ,LEFT)
        (font-series . bold)
        (padding . 1.0)
+       (self-alignment-X . ,RIGHT)
        (side-axis . ,X)
        (stencil . ,ly:text-interface::print)
-       (X-offset . ,ly:side-position-interface::x-aligned-side)
+       (X-offset . ,stanza-number::calc-x-offset)
        (Y-extent . ,grob::always-Y-extent-from-stencil)
        (meta . ((class . Item)
                 (interfaces . (font-interface
+                               self-alignment-interface
                                side-position-interface
                                stanza-number-interface
                                text-interface))))))
index 4533cf2a965a8c95eb22b3dcf84d21dc2e5ad8f7..4ce2cd667f342e3cee7633f1137e9f6744919f89 100644 (file)
@@ -1146,6 +1146,20 @@ and draws the stencil based on its coordinates.
           0.0))))
 
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; stanza-number
+
+(define-public (stanza-number::calc-x-offset grob)
+  "We want @code{StanzaNumbers} to side-align to lyrics.
+Sometimes, however, this is not possible, as the lyrics
+they align to are hara-kiri'd. In this case, we self-align
+them to the right and tack on any padding."
+  (if (null? (ly:grob-object grob 'side-support-elements))
+      (+ (ly:self-alignment-interface::x-aligned-on-self grob)
+         (* (ly:grob-property grob 'direction LEFT)
+            (ly:grob-property grob 'padding 0.0)))
+      (ly:side-position-interface::x-aligned-side grob)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; instrument names
 
@@ -1177,6 +1191,8 @@ and draws the stencil based on its coordinates.
         (common (ly:grob-common-refpoint-of-array system elements X))
         (total-ext empty-interval)
         (align-x (ly:grob-property grob 'self-alignment-X 0))
+         (my-padding (ly:grob-property grob 'padding 0))
+         (ss (ly:staff-symbol-staff-space grob))
         (padding (min 0 (- (interval-length my-extent) indent)))
         (right-padding (- padding
                           (/ (* padding (1+ align-x)) 2))))
@@ -1195,14 +1211,15 @@ and draws the stencil based on its coordinates.
            (unite-delims (1- l)))))
 
     (+
-     (ly:side-position-interface::x-aligned-side grob)
+     (- (interval-length my-extent))
+     (* -1 my-padding ss)
      right-padding
      (- (interval-length total-ext)))))
 
 (define-public (system-start-text::calc-y-offset grob)
 
   (define (live-elements-list me)
-    (let ((elements (ly:grob-object me 'elements)))
+    (let ((elements (ly:grob-object me 'system-start-text-alignment-elements)))
 
       (filter! grob::is-live?
                (ly:grob-array->list elements))))