From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Tue, 23 Jul 2002 18:46:33 +0000 (+0000)
Subject: juergens pats
X-Git-Tag: release/1.5.70~49
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3a8bdbfb00fdc32e150baf0b6fa855677fad57dd;p=lilypond.git

juergens pats
---

diff --git a/ChangeLog b/ChangeLog
index 6e4584f89e..65be160e05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-07-23  Juergen Reuter  <reuter@ipd.uka.de>
+
+	* lily/ambitus-engraver.cc: bugfix: create ambitus grob during
+	process_music phase
+
 2002-07-23  Han-Wen  <hanwen@cs.uu.nl>
 
 	* lily/separation-item.cc (width): cache extent in extent-X
diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc
index 85dbbd46b8..adfa5b8f77 100644
--- a/lily/ambitus-engraver.cc
+++ b/lily/ambitus-engraver.cc
@@ -64,6 +64,7 @@ class Ambitus_engraver : public Engraver
 {
 public:
 TRANSLATOR_DECLARATIONS(Ambitus_engraver);
+  virtual void process_music ();
   virtual void acknowledge_grob (Grob_info);
   virtual void stop_translation_timestep ();
   virtual void finalize ();
@@ -71,51 +72,65 @@ TRANSLATOR_DECLARATIONS(Ambitus_engraver);
 private:
   void create_ambitus ();
   Item *ambitus_p_;
-  int isActive;
+  int/*bool*/ is_typeset;
   Pitch pitch_min, pitch_max;
 };
 
 Ambitus_engraver::Ambitus_engraver ()
 {
-  ambitus_p_ = 0; isActive = 0;
+  ambitus_p_ = 0;
+  is_typeset = 0;
 
-  // (pitch_min > pitch_max) means that pitches are not yet
-  // initialized
+  /*
+   * (pitch_min > pitch_max) means that pitches are not yet
+   * initialized
+   */
   pitch_min = Pitch (0, 0, +1);
   pitch_max = Pitch (0, 0, -1);
 }
 
 void
-Ambitus_engraver::stop_translation_timestep ()
+Ambitus_engraver::process_music ()
 {
+  /*
+   * Ensure that ambitus is created in the very first timestep (on
+   * which lily does not call start_translation_timestep ()).
+   * Otherwise, if a voice begins with a rest, the ambitus grob will
+   * be placed after the rest.
+   */
   if (!ambitus_p_) {
-    // Create ambitus not before stopping timestep.  centralCPosition
-    // will then be the same as that for the first timestep.
-    //
-    // TODO: is this really a good idea?  At least, creating the
-    // ambitus in start_translation_timestep is a *bad* idea, since we
-    // may then oversee a clef that is defined in a staff context if
-    // we are in a voice context; centralCPosition would then be
-    // assumed to be 0.
     create_ambitus ();
   }
-  if (ambitus_p_ && isActive)
+}
+
+void
+Ambitus_engraver::stop_translation_timestep ()
+{
+  if (ambitus_p_ && !is_typeset)
     {
+      /*
+       * Evaluate centralCPosition not until now, since otherwise we
+       * may then oversee a clef that is defined in a staff context if
+       * we are in a voice context; centralCPosition would then be
+       * assumed to be 0.
+       */
+      SCM c0 = get_property ("centralCPosition");
+      ambitus_p_->set_grob_property ("centralCPosition", c0);
+
+      /*
+       * Similar for keySignature.
+       */
       SCM key_signature = get_property ("keySignature");
       ambitus_p_->set_grob_property ("keySignature", key_signature);
+
       typeset_grob (ambitus_p_);
-      isActive = 0;
+      is_typeset = 1;
     }
 }
 
 void
 Ambitus_engraver::acknowledge_grob (Grob_info info)
 {
-  if (!ambitus_p_) {
-    create_ambitus ();
-  }
-  if (!ambitus_p_)
-    return;
   Item *item = dynamic_cast <Item *>(info.grob_l_);
   if (item)
     {
@@ -148,9 +163,7 @@ void
 Ambitus_engraver::create_ambitus ()
 {
   SCM basicProperties = get_property ("Ambitus");
-  SCM c0 = get_property ("centralCPosition");
-  ambitus_p_ = new Item (basicProperties); isActive = 1;
-  ambitus_p_->set_grob_property ("centralCPosition", c0);
+  ambitus_p_ = new Item (basicProperties); is_typeset = 0;
   announce_grob (ambitus_p_, SCM_EOL);
 }
 
@@ -168,9 +181,11 @@ Ambitus_engraver::finalize ()
 	}
       else // have not seen any pitch, so forget about the ambitus
 	{
-	  // Do not print a warning on empty ambitus range, since this
-	  // most probably arises from an empty voice, such as shared
-	  // global timesig/clef definitions.
+	  /*
+	   * Do not print a warning on empty ambitus range, since this
+	   * most probably arises from an empty voice, such as shared
+	   * global timesig/clef definitions.
+	   */
 #if 0
 	  ambitus_p_->warning("empty ambitus range [ignored]");
 #endif
diff --git a/scm/grob-description.scm b/scm/grob-description.scm
index 3782c13472..27ae041723 100644
--- a/scm/grob-description.scm
+++ b/scm/grob-description.scm
@@ -303,6 +303,7 @@
 	(X-extent-callback . ,Grob::point_dimension_callback)
 	(breakable . #t)
 	(space-alist . (
+			(custos . (extra-space . 0.0))
 			(ambitus . (extra-space . 2.0))
 			(time-signature . (extra-space . 0.0)) 
 			(staff-bar . (extra-space . 0.0))