]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/script-engraver.cc
2003 -> 2004
[lilypond.git] / lily / script-engraver.cc
index 74df559d3bd7145f3e94c7f7b205df8c40b153e5..03826157bf269bc69a171e4aff67924f4e1038fc 100644 (file)
@@ -1,7 +1,7 @@
 /*
   script-engraver.cc -- implement Script_engraver
 
-  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "script.hh"
@@ -12,6 +12,7 @@
 #include "engraver.hh"
 #include "note-column.hh"
 #include "translator-group.hh"
+#include "warn.hh"
 
 struct Script_tuple
 {
@@ -33,27 +34,30 @@ public:
   TRANSLATOR_DECLARATIONS(Script_engraver);
 protected:
   virtual bool try_music (Music*);
-  virtual void initialize ();
   virtual void stop_translation_timestep ();
-  virtual void start_translation_timestep ();
   virtual void process_music ();
   virtual void acknowledge_grob (Grob_info);
 };
 
-void
-Script_engraver::initialize ()
-{
-  scripts_.clear ();
-}
-
 bool
 Script_engraver::try_music (Music *r)
 {
   if (r->is_mus_type ("articulation-event"))
     {
+      /*
+       Discard double articulations.
+       This is necessary for part-combining.
+       */
+      for (int j = 0; j < scripts_.size (); j++)
+       if (gh_equal_p (scripts_[j]. event_->get_mus_property ("articulation-type"),
+                       r->get_mus_property ("articulation-type")
+                       ))
+         return true;
+         
       Script_tuple t;
       t.event_ =r;
       scripts_.push (t);
+      
       return true;
     }
   return false;
@@ -78,27 +82,26 @@ copy_property (Grob * g , SCM sym, SCM alist)
   little space by tacking the props onto the Script grob (i.e. make
   ScriptStaccato , ScriptMarcato, etc. )
  */
-Grob *make_script_from_event (SCM * descr, Translator_group*tg, Music * event,
-                             int index)
+void make_script_from_event (Grob *p,
+                            SCM * descr, Translator_group*tg,
+                            SCM art_type, 
+                            int index)
 {
   SCM alist = tg->get_property ("scriptDefinitions");
-  SCM art = scm_assoc (event->get_mus_property ("articulation-type"), alist);
+  SCM art = scm_assoc (art_type, alist);
 
   if (art == SCM_BOOL_F)
     {
-      String a = ly_scm2string (event->get_mus_property ("articulation-type"));
-      event->origin ()->warning (_f ("Don't know how to interpret articulation `%s'", a.to_str0 ()));
-      return 0 ;
+      warning (_("Don't know how to interpret articulation:"));
+      warning (_("Scheme encoding: "));
+      scm_write (art_type, scm_current_error_port ());
+      return  ;
     }
 
   art = gh_cdr (art);
-    
-  Grob *p =new Item (tg->get_property ("Script"));
+  
   *descr = art;  
 
-  SCM force_dir = event->get_mus_property ("direction");
-  if (ly_dir_p (force_dir) && to_dir (force_dir))
-    p->set_grob_property ("direction", force_dir);
 
   copy_property (p, ly_symbol2scm ("script-molecule"), art);
   copy_property (p, ly_symbol2scm ("direction"), art);
@@ -119,7 +122,6 @@ Grob *make_script_from_event (SCM * descr, Translator_group*tg, Music * event,
 
   Side_position_interface::set_axis (p, Y_AXIS);
   p->set_grob_property ("script-priority", gh_int2scm (prio));
-  return p;
 }
 
 void
@@ -129,9 +131,19 @@ Script_engraver::process_music ()
     {
       Music* l=scripts_[i].event_;
 
-      Grob * p = make_script_from_event (&scripts_[i].description_, daddy_trans_, l, i);
+      Grob * p = make_item ("Script");
+
+      make_script_from_event (p, &scripts_[i].description_, daddy_trans_,
+                             l->get_mus_property ("articulation-type"),
+                             i);
 
       scripts_[i].script_ = p;
+
+      
+      SCM force_dir = l->get_mus_property ("direction");
+      if (is_direction (force_dir) && to_dir (force_dir))
+       p->set_grob_property ("direction", force_dir);
+      
       if (p)
        announce_grob (p, l->self_scm());
     }
@@ -207,20 +219,15 @@ Script_engraver::stop_translation_timestep ()
 
       SCM follow = scm_assoc (ly_symbol2scm ("follow-into-staff"), scripts_[i].description_);
       if (gh_pair_p (follow) && to_boolean (gh_cdr (follow)))
-       sc->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
-      else
-       Side_position_interface::add_staff_support (sc);
+       {
+         sc->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
+         sc->set_grob_property ("staff-padding", SCM_EOL);
+       }
       typeset_grob (sc);
     }
   scripts_.clear ();
 }
 
-void
-Script_engraver::start_translation_timestep ()
-{
-  scripts_.clear ();
-}
-
 
 
 Script_engraver::Script_engraver(){}