From a1aa03e96f21f72d8a5962f64f3938cc2823f67e Mon Sep 17 00:00:00 2001
From: Mike Solomon <mike@apollinemike.com>
Date: Sat, 30 Mar 2013 10:57:31 +0100
Subject: [PATCH] Revert "Uses special X alignment for instrument names."

This reverts commit 6e4e69f2735a764eab2e6f70f83546461da0203b.
---
 lily/instrument-name-engraver.cc |  4 ++--
 lily/side-position-interface.cc  | 10 ++++++++++
 scm/define-grob-interfaces.scm   |  3 +--
 scm/define-grob-properties.scm   |  2 --
 scm/define-grobs.scm             |  4 +---
 scm/output-lib.scm               | 21 ++-------------------
 6 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc
index a0b0c2682f..0abc7e4329 100644
--- a/lily/instrument-name-engraver.cc
+++ b/lily/instrument-name-engraver.cc
@@ -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 ("system-start-text-alignment-elements"),
+                                       ly_symbol2scm ("elements"),
                                        axis_groups_[i]);
 
   text_spanner_->set_bound (RIGHT,
                             unsmob_grob (get_property ("currentCommandColumn")));
 
   Pointer_group_interface::set_ordered (text_spanner_,
-                                        ly_symbol2scm ("system-start-text-alignment-elements"),
+                                        ly_symbol2scm ("elements"),
                                         false);
 
   text_spanner_ = 0;
diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc
index 5a8ecb74c9..4d8efe1ced 100644
--- a/lily/side-position-interface.cc
+++ b/lily/side-position-interface.cc
@@ -314,6 +314,16 @@ 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.
diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm
index df001959ce..6068579995 100644
--- a/scm/define-grob-interfaces.scm
+++ b/scm/define-grob-interfaces.scm
@@ -264,8 +264,7 @@ interesting enough to maintain a hara-kiri staff."
 (ly:add-interface
  'system-start-text-interface
  "Text in front of the system."
- '(system-start-text-alignment-elements long-text
-   padding self-alignment-X self-alignment-Y text))
+ '(long-text self-alignment-X self-alignment-Y text))
 
 (ly:add-interface
  'tab-note-head-interface
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index c35b5e1909..9afb49a0a3 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -1174,8 +1174,6 @@ 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.")
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 5ff4c7f803..19a767fba5 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -2039,14 +2039,12 @@
 	(direction . ,LEFT)
 	(font-series . bold)
 	(padding . 1.0)
-	(self-alignment-X . ,RIGHT)
 	(side-axis . ,X)
 	(stencil . ,ly:text-interface::print)
-	(X-offset . ,stanza-number::calc-x-offset)
+	(X-offset . ,ly:side-position-interface::x-aligned-side)
 	(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))))))
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 4ce2cd667f..4533cf2a96 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -1146,20 +1146,6 @@ 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
 
@@ -1191,8 +1177,6 @@ them to the right and tack on any padding."
 	 (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))))
@@ -1211,15 +1195,14 @@ them to the right and tack on any padding."
 	    (unite-delims (1- l)))))
 
     (+
-     (- (interval-length my-extent))
-     (* -1 my-padding ss)
+     (ly:side-position-interface::x-aligned-side grob)
      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 'system-start-text-alignment-elements)))
+    (let ((elements (ly:grob-object me 'elements)))
 
       (filter! grob::is-live?
                (ly:grob-array->list elements))))
-- 
2.39.5