]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/piano-pedal-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / piano-pedal-engraver.cc
index 5fb5c37321c9681bcbadc48159ca26b0d7bfb7ab..2d380fb3522699deece022a6c24e6c0ce4fba6ab 100644 (file)
@@ -3,20 +3,22 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
 
   Chris Jackson <chris@fluffhouse.org.uk> - extended to support
   bracketed pedals.
 */
 
 #include "engraver.hh"
-#include "lily-guile.hh"
-#include "side-position-interface.hh"
-#include "staff-symbol-referencer.hh"
+
 #include "axis-group-interface.hh"
 #include "context.hh"
 #include "directional-element-interface.hh"
+#include "international.hh"
+#include "lily-guile.hh"
 #include "note-column.hh"
+#include "side-position-interface.hh"
+#include "staff-symbol-referencer.hh"
 #include "warn.hh"
 
 /*
@@ -77,7 +79,7 @@ private:
     occurs simultaneously then extra space can be added between them.
   */
 
-  Link_array<Spanner> previous_;
+  vector<Spanner*> previous_;
   void del_linespanner (Spanner *);
 
   void create_text_grobs (Pedal_info *p, bool);
@@ -150,9 +152,9 @@ Piano_pedal_engraver::try_music (Music *m)
     {
       for (Pedal_info *p = info_list_; p->name_; p++)
        {
-         String nm = p->name_ + String ("Event");
+         string nm = p->name_ + string ("Event");
          if (ly_is_equal (m->get_property ("name"),
-                          scm_str2symbol (nm.to_str0 ())))
+                          scm_str2symbol (nm.c_str ())))
            {
              Direction d = to_dir (m->get_property ("span-direction"));
              p->event_drul_[d] = m;
@@ -172,9 +174,9 @@ Piano_pedal_engraver::process_music ()
        {
          if (!p->line_spanner_)
            {
-             String name = String (p->name_) + "PedalLineSpanner";
+             string name = string (p->name_) + "PedalLineSpanner";
              Music *rq = (p->event_drul_[START] ? p->event_drul_[START] : p->event_drul_[STOP]);
-             p->line_spanner_ = make_spanner (name.to_str0 (), rq->self_scm ());
+             p->line_spanner_ = make_spanner (name.c_str (), rq->self_scm ());
            }
 
          /* Choose the appropriate grobs to add to the line spanner
@@ -190,8 +192,8 @@ Piano_pedal_engraver::process_music ()
            mixed:   Ped. _____/\____|
          */
 
-         String prop = String ("pedal") + p->name_ + "Style";
-         SCM style = get_property (prop.to_str0 ());
+         string prop = string ("pedal") + p->name_ + "Style";
+         SCM style = get_property (prop.c_str ());
 
          bool mixed = style == ly_symbol2scm ("mixed");
          bool bracket = (mixed
@@ -211,14 +213,14 @@ void
 Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed)
 {
   SCM s = SCM_EOL;
-  SCM strings = get_property (("pedal" + String (p->name_) + "Strings").to_str0 ());
+  SCM strings = get_property (("pedal" + string (p->name_) + "Strings").c_str ());
 
   if (scm_ilength (strings) < 3)
     {
       Music *m = p->event_drul_[START];
       if (!m) m = p->event_drul_ [STOP];
 
-      String msg = _f ("expect 3 strings for piano pedals, found: %d",
+      string msg = _f ("expect 3 strings for piano pedals, found: %ld",
                       scm_ilength (strings));
       if (m)
        m->origin ()->warning (msg);
@@ -262,16 +264,16 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed)
          if (previous_.size ())
            // add extra space below the previous already-occuring pedal
            Side_position_interface::add_support (p->line_spanner_,
-                                                 previous_.top ());
-         previous_.push (p->line_spanner_);
+                                                 previous_.back ());
+         previous_.push_back (p->line_spanner_);
        }
     }
 
   if (scm_is_string (s))
     {
-      String propname = String (p->name_) + "Pedal";
+      string propname = string (p->name_) + "Pedal";
 
-      p->item_ = make_item (propname.to_str0 (), (p->event_drul_[START]
+      p->item_ = make_item (propname.c_str (), (p->event_drul_[START]
                                                  ? p->event_drul_[START]
                                                  : p->event_drul_[STOP])->self_scm ());
 
@@ -291,7 +293,7 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
 {
   if (!p->bracket_ && p->event_drul_[STOP])
     {
-      String msg = _f ("can't find start of piano pedal bracket: `%s'", p->name_);
+      string msg = _f ("can't find start of piano pedal bracket: `%s'", p->name_);
       p->event_drul_[STOP]->origin ()->warning (msg);
       p->event_drul_[STOP] = 0;
     }
@@ -384,9 +386,9 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
            // position new pedal spanner below the current one
            */
          if (previous_.size ())
-           Side_position_interface::add_support (p->line_spanner_, previous_.top ());
+           Side_position_interface::add_support (p->line_spanner_, previous_.back ());
 
-         previous_.push (p->line_spanner_);
+         previous_.push_back (p->line_spanner_);
        }
     }
 
@@ -436,9 +438,9 @@ Piano_pedal_engraver::finalize ()
 void
 Piano_pedal_engraver::del_linespanner (Spanner *g)
 {
-  int idx = previous_.find_index (g);
-  if (idx >= 0)
-    previous_.del (idx);
+  vsize idx = find (previous_, g) - previous_.begin ();
+  if (idx != VPOS && idx < previous_.size ())
+    previous_.erase (previous_.begin () + idx);
 }
 
 void
@@ -509,13 +511,31 @@ Piano_pedal_engraver::typeset_all (Pedal_info *p)
 }
 
 #include "translator.icc"
+
 ADD_ACKNOWLEDGER (Piano_pedal_engraver, note_column);
+
 ADD_TRANSLATOR (Piano_pedal_engraver,
-               /* doc */ "Engrave piano pedal symbols and brackets.",
-               /* create */ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner",
-               /* accept */ "pedal-event",
-               /* read */ "currentCommandColumn "
-               "pedalSostenutoStrings pedalSustainStrings "
-               "pedalUnaCordaStrings pedalSostenutoStyle "
-               "pedalSustainStyle pedalUnaCordaStyle",
+
+               /* doc */
+               "Engrave piano pedal symbols and brackets.",
+
+               /* create */
+               "SostenutoPedal "
+               "SostenutoPedalLineSpanner "
+               "SustainPedal "
+               "SustainPedalLineSpanner "
+               "UnaCordaPedal "
+               "UnaCordaPedalLineSpanner ",
+
+               /* accept */
+               "pedal-event",
+
+               /* read */
+               "currentCommandColumn "
+               "pedalSostenutoStrings "
+               "pedalSostenutoStyle "
+               "pedalSustainStrings "
+               "pedalSustainStyle "
+               "pedalUnaCordaStrings "
+               "pedalUnaCordaStyle",
                /* write */ "");