From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Mon, 15 Aug 2005 11:17:43 +0000 (+0000)
Subject: * lily/mark-engraver.cc (stop_translation_timestep): set grob
X-Git-Tag: release/2.7.5~9
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bfaf7b9c40948e603388efec369138ce45102db2;p=lilypond.git

* lily/mark-engraver.cc (stop_translation_timestep): set grob
array for staves found.

* lily/metronome-engraver.cc (stop_translation_timestep): set grob
array for stavesFound.

* lily/staff-spacing.cc (next_note_correction): add fixed and
space to calling convention. This fixes spacing of accidentals
after barlines.

* input/regression/spacing-accidental-stretch.ly: add barline -
accidental case.
---

diff --git a/ChangeLog b/ChangeLog
index 1a499b23c1..ff6b69a08b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2005-08-15  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+	* lily/mark-engraver.cc (stop_translation_timestep): set grob
+	array for staves found.
+
+	* lily/metronome-engraver.cc (stop_translation_timestep): set grob
+	array for stavesFound.
+
+	* lily/staff-spacing.cc (next_note_correction): add fixed and
+	space to calling convention. This fixes spacing of accidentals
+	after barlines.
+
+	* input/regression/spacing-accidental-stretch.ly: add barline -
+	accidental case.
+
 	* scm/framework-ps.scm (page-header): add version number to
 	creator
 	(eps-header): idem.
diff --git a/input/regression/spacing-accidental-stretch.ly b/input/regression/spacing-accidental-stretch.ly
index b46da7173b..114327939c 100644
--- a/input/regression/spacing-accidental-stretch.ly
+++ b/input/regression/spacing-accidental-stretch.ly
@@ -10,11 +10,12 @@ The accidental does add a little non-stretchable space.
 \score {
       \relative c'' \context GrandStaff {
 	#(set-accidental-style 'piano-cautionary)
-	d16 d d d d d cis d 
+	\time 2/4 
+	d16 d d d d d cis d dis dis dis dis 
 	
      }
 
      %% not raggedright!!
-     \layout {  linewidth = 14.\cm
+     \layout {  linewidth = 18.\cm
      }
 }
diff --git a/lily/include/staff-spacing.hh b/lily/include/staff-spacing.hh
index eb271be156..367af8ff8f 100644
--- a/lily/include/staff-spacing.hh
+++ b/lily/include/staff-spacing.hh
@@ -14,8 +14,8 @@
 class Staff_spacing
 {
 public:
-  static Real next_notes_correction (Grob *, Grob *);
-  static Real next_note_correction (Grob *, Grob *, Interval);
+  static void next_notes_correction (Grob *, Grob *, Real *, Real *);
+  static void next_note_correction (Grob *, Grob *, Interval, Real*, Real *);
   static bool has_interface (Grob *);
   static void get_spacing_params (Grob *, Real *, Real *);
 
diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc
index a770cf2001..209b597bfe 100644
--- a/lily/mark-engraver.cc
+++ b/lily/mark-engraver.cc
@@ -14,6 +14,7 @@
 #include "item.hh"
 #include "warn.hh"
 #include "text-interface.hh"
+#include "grob-array.hh"
 
 /**
    put stuff over or next to  bars.  Examples: bar numbers, marginal notes,
@@ -62,8 +63,8 @@ Mark_engraver::stop_translation_timestep ()
 {
   if (text_)
     {
-      SCM lst = get_property ("stavesFound");
-      text_->set_object ("side-support-elements", lst);
+      text_->set_object ("side-support-elements",
+			 grob_list_to_grob_array (get_property ("stavesFound")));
       text_ = 0;
     }
   mark_ev_ = 0;
diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc
index f42c9f1870..15375e542b 100644
--- a/lily/metronome-engraver.cc
+++ b/lily/metronome-engraver.cc
@@ -8,11 +8,11 @@
 
 #include <cctype>
 
+#include "engraver.hh"
+
 #include "note-column.hh"
-#include "bar-line.hh"
-#include "time-signature.hh"
-#include "engraver-group-engraver.hh"
 #include "context.hh"
+#include "grob-array.hh"
 
 /**
    put stuff over or next to  bars.  Examples: bar numbers, marginal notes,
@@ -47,7 +47,8 @@ Metronome_mark_engraver::stop_translation_timestep ()
     {
       Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"));
       text_->set_parent (mc, X_AXIS);
-      text_->set_object ("side-support-elements", get_property ("stavesFound"));
+      text_->set_object ("side-support-elements",
+			 grob_list_to_grob_array (get_property ("stavesFound")));
 
       text_ = 0;
     }
diff --git a/lily/paper-column.cc b/lily/paper-column.cc
index 1ae46fee11..f188bfdb48 100644
--- a/lily/paper-column.cc
+++ b/lily/paper-column.cc
@@ -27,20 +27,26 @@ Paper_column::clone (int count) const
 }
 
 ADD_INTERFACE (Paper_column, "paper-column-interface",
-	       "@code{Paper_column} objects form the top-most X-parents for items. "
+	       "@code{Paper_column} objects form the top-most X-parents for items."
 	       "  The are two types of columns: musical columns, where are attached to, and "
 	       "  non-musical columns, where bar-lines, clefs etc. are attached to. "
 	       "  The spacing engine determines the X-positions of these objects."
+	       
 	       "\n\n"
 	       "They are\n"
 	       "  numbered, the first (leftmost) is column 0. Numbering happens before\n"
 	       "  line-breaking, and columns are not renumbered after line breaking.\n"
 	       "  Since many columns go unused, you should only use the rank field to\n"
 	       "  get ordering information.  Two adjacent columns may have\n"
-	       "  non-adjacent numbers.\n"
-	       "\n",
-	       "between-cols when bounded-by-me "
-	       "page-penalty shortest-playing-duration shortest-starter-duration");
+	       "  non-adjacent numbers.\n",
+	       
+	       
+	       "between-cols "
+	       "bounded-by-me "
+	       "page-penalty "
+	       "shortest-playing-duration "
+	       "shortest-starter-duration "
+	       "when ");
 
 void
 Paper_column::do_break_processing ()
@@ -110,6 +116,7 @@ Paper_column::is_used (Grob *me)
   extract_grob_set (me, "bounded-by-me", bbm);
   if (bbm.size ())
     return true;
+  
   return Item::is_breakable (me);
 }
 
diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc
index 5860306984..735436e142 100644
--- a/lily/staff-spacing.cc
+++ b/lily/staff-spacing.cc
@@ -24,13 +24,17 @@
   Insert some more space for the next note, in case it has a stem in
   the wrong direction
 */
-Real
+void
 Staff_spacing::next_note_correction (Grob *me,
 				     Grob *g,
-				     Interval bar_size)
+				     Interval bar_size,
+				     Real *space,
+				     Real *fix)
 {
+  (void)space;
+  
   if (!g || !Note_column::has_interface (g))
-    return 0.0;
+    return ;
 
   Item *col = dynamic_cast<Item *> (g)->get_column ();
   Real max_corr = max (0., (- g->extent (col, X_AXIS)[LEFT]));
@@ -80,7 +84,8 @@ Staff_spacing::next_note_correction (Grob *me,
 	    max_corr = max (max_corr, corr);
 	  }
       }
-  return max_corr;
+
+  *fix += max_corr;
 }
 
 /*
@@ -114,24 +119,49 @@ Staff_spacing::bar_y_positions (Grob *bar_grob)
   pointers to the separation-items, not the note-columns or
   note-spacings.
 */
-Real
-Staff_spacing::next_notes_correction (Grob *me, Grob *last_grob)
+void
+Staff_spacing::next_notes_correction (Grob *me, Grob *last_grob,
+				      Real *compound_space, Real *compound_fixed
+				      )
 {
   Interval bar_size = bar_y_positions (last_grob);
-  Real max_corr = 0.0;
 
   extract_grob_set (me, "right-items", right_items);
+
+  *compound_fixed = 0.0;
+  *compound_space = 0.0;
+  int wishes;
+  
   for (int i = right_items.size (); i--;)
     {
       Grob *g = right_items[i];
 
-      max_corr = max (max_corr, next_note_correction (me, g, bar_size));
+      Real space = 0.0;
+      Real fixed = 0.0;
+
+      next_note_correction (me, g, bar_size, &space, &fixed);
+
+      *compound_space += space;
+      *compound_fixed += fixed; 
+      wishes ++;
+      
       extract_grob_set (g, "elements", elts);
       for (int j = elts.size (); j--;)
-	max_corr = max (max_corr, next_note_correction (me, elts[j], bar_size));
+	{
+	  Real space = 0.0;
+	  Real fixed = 0.0;
+	  next_note_correction (me, elts[j], bar_size, &space, &fixed);
+	  *compound_fixed += fixed;
+	  *compound_space += space;
+	  wishes ++;
+	}
     }
 
-  return max_corr;
+  if (wishes)
+    {
+      *compound_space /= wishes;
+      *compound_fixed /= wishes;
+    }
 }
 
 void
@@ -152,7 +182,6 @@ Staff_spacing::get_spacing_params (Grob *me, Real *space, Real *fixed)
     }
 
   //  printf ("doing col %d\n" , Paper_column::get_rank (left_col));
-
   if (!separation_item)
     {
       programming_error ("no sep item");
@@ -224,7 +253,10 @@ Staff_spacing::get_spacing_params (Grob *me, Real *space, Real *fixed)
       *fixed = *space;
     }
 
-  *space += next_notes_correction (me, last_grob);
+  Real correction_fixed, correction_space;
+  next_notes_correction (me, last_grob, &correction_space, &correction_fixed );
+  *space += correction_space;
+  *fixed += correction_fixed;
 }
 
 ADD_INTERFACE (Staff_spacing, "staff-spacing-interface",