]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/piano-pedal-engraver.cc
($(outdir)/%.pdf): add DVIPS_FLAGS. This will
[lilypond.git] / lily / piano-pedal-engraver.cc
index 67a877306ed6d06c63730f8a58f6a5c4e3e71bcf..77283f3bce6442ec8bcaa617e1b5cd8b50cd12fe 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
- (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
   
   Chris Jackson <chris@fluffhouse.org.uk> - extended to support
   bracketed pedals.
 #include "note-column.hh"
 #include "warn.hh"
 
+/*
+  Urgh. This engraver is too complex. rewrite. --hwn
+
+*/
+
 struct Pedal_info
 {
   char const * name_;
@@ -31,6 +36,7 @@ struct Pedal_info
     Event for currently running pedal.
   */
   Music* current_bracket_ev_;
+
   /*
     Event for currently starting pedal, (necessary?
     
@@ -67,7 +73,6 @@ protected:
   virtual void finalize ();
   virtual bool try_music (Music*);
   virtual void stop_translation_timestep ();
-  virtual void start_translation_timestep ();
   virtual void acknowledge_grob (Grob_info);
   virtual void process_music ();
 
@@ -82,8 +87,6 @@ private:
   
   Link_array<Spanner> previous_;
   
-
-  
   void create_text_grobs (Pedal_info *p, bool);
   void create_bracket_grobs (Pedal_info *p, bool);
   void typeset_all ();
@@ -98,7 +101,6 @@ Piano_pedal_engraver::Piano_pedal_engraver ()
 void
 Piano_pedal_engraver::initialize ()
 {
-
   previous_.clear ();
 
   char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0  };
@@ -144,12 +146,12 @@ Piano_pedal_engraver::acknowledge_grob (Grob_info info)
          if (p->line_spanner_)
            {
              Side_position_interface::add_support (p->line_spanner_, info.grob_);
-             
              add_bound_item (p->line_spanner_,info.grob_);
            }     
          if (p->bracket_)
-           add_bound_item (p->bracket_,info.grob_);              
-         
+           add_bound_item (p->bracket_,info.grob_);
+         if (p->finished_bracket_)
+           add_bound_item (p->finished_bracket_,info.grob_);             
        }
     }
 }
@@ -157,19 +159,7 @@ Piano_pedal_engraver::acknowledge_grob (Grob_info info)
 bool
 Piano_pedal_engraver::try_music (Music *m)
 {
-  if (m->is_mus_type ("abort-event"))
-    {
-      for (Pedal_info*p = info_list_; p->name_; p ++)
-       {
-         p->event_drul_[START] = 0;
-         p->event_drul_[STOP] = 0;
-         
-         if (p->bracket_)
-           p->bracket_->suicide ();
-         p->bracket_ = 0;
-       }
-    }
-  else if  (m->is_mus_type ("pedal-event"))
+ if  (m->is_mus_type ("pedal-event"))
     {
       for (Pedal_info*p = info_list_; p->name_; p ++)
        {
@@ -196,9 +186,8 @@ Piano_pedal_engraver::process_music ()
          if (!p->line_spanner_)
            {
              String name  = String (p->name_) + "PedalLineSpanner";
-             p->line_spanner_ = new Spanner (get_property (name.to_str0 ()));
+             p->line_spanner_ = make_spanner (name.to_str0 ());
 
-             
              Music * rq = (p->event_drul_[START]  ?  p->event_drul_[START]  :  p->event_drul_[STOP]);
              announce_grob (p->line_spanner_, rq->self_scm ());
            }
@@ -308,8 +297,7 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed)
     {
       String propname = String (p->name_) + "Pedal";
 
-      SCM b = get_property (propname.to_str0 ());
-      p->item_ = new Item (b);
+      p->item_ = make_item (propname.to_str0 ());
       p->item_->set_grob_property ("text", s);
       Axis_group_interface::add_element (p->line_spanner_, p->item_);
          
@@ -347,10 +335,12 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
       assert (!p->finished_bracket_); 
 
       Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn"));
-      p->bracket_->set_bound (RIGHT, cmc);
+
+      if (!p->bracket_->get_bound (RIGHT))
+       p->bracket_->set_bound (RIGHT, cmc);
 
       /*
-       Set properties so that the molecule-creating function will
+       Set properties so that the stencil-creating function will
        know whether the right edge should be flared ___/
        */
 
@@ -371,10 +361,10 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
       p->start_ev_ = p->event_drul_[START];
       p->current_bracket_ev_ = p->event_drul_[START];
 
-      p->bracket_  = new Spanner (get_property ("PianoPedalBracket"));
+      p->bracket_  = make_spanner ("PianoPedalBracket");
 
       /*
-       Set properties so that the molecule-creating function will
+       Set properties so that the stencil-creating function will
        know whether the left edge should be flared \___
       */
 
@@ -386,7 +376,7 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
 
 
       /* Set this property for 'mixed style' pedals,    Ped._______/\ ,  
-        so the molecule function will shorten the ____ line by the length of the Ped. text.
+        so the stencil function will shorten the ____ line by the length of the Ped. text.
       */
 
       if (mixed)
@@ -404,10 +394,22 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
            p->bracket_->set_grob_property ("pedal-text", p->item_->self_scm ());
        }
 
-      p->bracket_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
-      Axis_group_interface::add_element (p->line_spanner_, p->bracket_);             
 
-      add_bound_item (p->line_spanner_, p->bracket_->get_bound (LEFT));
+      /*
+       We do not use currentMusicalColumn for the left span-point.
+       If the column as accidentals (eg on a different stave), the
+       currentMusicalColumn is too wide, making the bracket too big.
+
+       TODO:
+
+       Hmm. What do we do when there are no notes when the spanner starts?
+
+       TODO:
+
+       what about the right span point?
+       
+       */
+      Axis_group_interface::add_element (p->line_spanner_, p->bracket_);             
       announce_grob (p->bracket_, p->event_drul_[START]->self_scm ());
 
       if (!p->event_drul_[STOP])
@@ -473,6 +475,12 @@ Piano_pedal_engraver::stop_translation_timestep ()
     }
   
   typeset_all ();
+
+  for (Pedal_info*p = info_list_; p->name_; p ++)
+    {
+      p->event_drul_[STOP] = 0;
+      p->event_drul_[START] = 0;
+    }
 }
 
 
@@ -501,12 +509,9 @@ Piano_pedal_engraver::typeset_all ()
          /*
            Hmm.
          */
-         if (p->name_ != String ("Sustain"))
+         if (p->name_ != String ("Sustain") && sustain)
            {
-             if (sustain)
-               {
-                 Side_position_interface::add_support (p->item_,sustain);
-               }
+             Side_position_interface::add_support (p->item_,sustain);
            }
          typeset_grob (p->item_);
          p->item_ = 0;
@@ -521,12 +526,12 @@ Piano_pedal_engraver::typeset_all ()
            }
 
          typeset_grob (p->finished_bracket_);
+         
          p->finished_bracket_ =0;
        }
 
       if (p->finished_line_spanner_)
        {
-         Side_position_interface::add_staff_support (p->finished_line_spanner_);
          Grob * l = p->finished_line_spanner_->get_bound (LEFT);
          Grob * r = p->finished_line_spanner_->get_bound (RIGHT);      
          if (!r && l)
@@ -546,20 +551,10 @@ Piano_pedal_engraver::typeset_all ()
     }
 }
 
-void
-Piano_pedal_engraver::start_translation_timestep ()
-{
-  for (Pedal_info*p = info_list_; p->name_; p ++)
-    {
-      p->event_drul_[STOP] = 0;
-      p->event_drul_[START] = 0;
-    }
-}
-
 ENTER_DESCRIPTION (Piano_pedal_engraver,
 /* descr */       "Engrave piano pedal symbols and brackets.",
 /* creats*/       "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner",
-/* accepts */     "pedal-event abort-event",
+/* accepts */     "pedal-event",
 /* acks  */       "note-column-interface",
 /* reads */       "pedalSostenutoStrings pedalSustainStrings pedalUnaCordaStrings pedalSostenutoStyle pedalSustainStyle pedalUnaCordaStyle",
 /* write */       "");