From b567b5b82bb0408e3bbffa2f77abd2daab345390 Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Thu, 4 Aug 2005 14:46:00 +0000
Subject: [PATCH] (shift_region_to_valid): divide by zero fix. This fixes beams
 with a single stem (eg. beams across linebreaks.)

---
 ChangeLog                |  3 +++
 lily/beam.cc             |  2 +-
 lily/spacing-engraver.cc |  1 -
 lily/spacing-spanner.cc  |  5 +++++
 ly/engraver-init.ly      | 22 +++++++++++++---------
 scm/define-grobs.scm     |  4 ++--
 6 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0a9c37ee4c..97ae6c0cd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2005-08-04  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+	* lily/beam.cc (shift_region_to_valid): divide by zero fix. This
+	fixes beams with a single stem (eg. beams across linebreaks.)
+
 	* lily/parser.yy (simple_string): allow \new STRING_IDENTIFIER.
 
 	* flower/rational.cc (operator +): prevent overflow. This fixes
diff --git a/lily/beam.cc b/lily/beam.cc
index a7c9a61e71..38120cd681 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -941,7 +941,7 @@ Beam::shift_region_to_valid (SCM grob)
 
   Real dy = pos[RIGHT] - pos[LEFT];
   Real y = pos[LEFT];
-  Real slope = dy / dx;
+  Real slope = dx ? (dy / dx) : 0.0;
 
   /*
     Shift the positions so that we have a chance of finding good
diff --git a/lily/spacing-engraver.cc b/lily/spacing-engraver.cc
index d74991cfd2..cc4b3f39c8 100644
--- a/lily/spacing-engraver.cc
+++ b/lily/spacing-engraver.cc
@@ -145,7 +145,6 @@ Spacing_engraver::stop_translation_timestep ()
      return; 
    }
   
-  
   Moment shortest_playing;
   shortest_playing.set_infinite (1);
   for (int i = 0; i < playing_durations_.size (); i++)
diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc
index 80a4511a79..108454d63e 100644
--- a/lily/spacing-spanner.cc
+++ b/lily/spacing-spanner.cc
@@ -414,6 +414,11 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r,
       compound_fixed /= wish_count;
     }
 
+  if (options->uniform_ && l->break_status_dir () != RIGHT)
+    {
+      compound_fixed = 0.0;
+    }
+  
   assert (!isinf (compound_space));
   compound_space = max (compound_space, compound_fixed);
 
diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly
index 358400bc4b..3cb645460e 100644
--- a/ly/engraver-init.ly
+++ b/ly/engraver-init.ly
@@ -116,16 +116,14 @@ contained staves are not connected vertically."
 \context{
   \type "Engraver_group_engraver"
   
-  \consists "Output_property_engraver"	
-
   minimumVerticalExtent = ##f
   extraVerticalExtent = ##f
   verticalExtent = ##f 
   localKeySignature = #'()
+  createSpacing = ##t
 
-  \consists "Pitch_squash_engraver"
+  
   squashedPosition = #0
-  \consists "Separating_line_group_engraver"	
   \name RhythmicStaff
   \alias "Staff"
   
@@ -135,19 +133,25 @@ contained staves are not connected vertically."
   \override StaffSymbol #'line-count = #1	
 
   \override Stem  #'neutral-direction = #1
-  \override Beam  #'neutral-direction = #1 	
-  %%	\consists "Repeat_engraver"
-  \consists "Dot_column_engraver"
+  \override Beam  #'neutral-direction = #1
+  
+  \consists "Output_property_engraver"
+  \consists "Font_size_engraver"
   \consists "Volta_engraver"
+  \consists "Separating_line_group_engraver"	
+  \consists "Dot_column_engraver"
   \consists "Bar_engraver"
-  \consists "Time_signature_engraver"
-  \consists "Staff_symbol_engraver"
   \consists "Ledger_line_engraver" 
+  \consists "Staff_symbol_engraver"
+  \consists "Pitch_squash_engraver"
+  \consists "Time_signature_engraver"
   \consists "Instrument_name_engraver"
   \consists "Axis_group_engraver"
+  
   \accepts "Voice"
   \accepts "CueVoice"
   \defaultchild "Voice"
+
   \description  "
     A context like @code{Staff} but for printing rhythms.  Pitches are
     ignored; the notes are printed on one line.  
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 29e471b7ec..978ccdd9d4 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -660,11 +660,11 @@
 	(space-alist . (
 			(custos . (extra-space . 0.0))
 			(ambitus . (extra-space . 2.0))
-			(time-signature . (extra-space . 0.0))
+			(time-signature . (extra-space . 1.0))
 			(staff-bar . (extra-space . 0.0))
 			(breathing-sign . (minimum-space . 0.0))
 			(clef . (extra-space . 0.8))
-			(first-note . (fixed-space . 1.0))
+			(first-note . (fixed-space . 2.0))
 			(right-edge . (extra-space . 0.0))
 			(key-signature . (extra-space . 0.0))
 			(key-cancellation . (extra-space . 0.0))
-- 
2.39.5