]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/auto-change-iterator.cc
* lily/font-select.cc: new file handle font selection routines.
[lilypond.git] / lily / auto-change-iterator.cc
index 74d345ee1470cbab47e9da292a9ce1d3eb855dfb..51e2284b2fbb61673fcb1ee3eee0b8ce406eb784 100644 (file)
@@ -3,19 +3,19 @@
 
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #include "music.hh"
 #include "auto-change-iterator.hh"
 #include "translator-group.hh"
-#include "musical-request.hh"
+#include "event.hh"
 
 
 
 void
-Auto_change_iterator::change_to (Music_iterator *it, String to_type,
+Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym,
                                 String to_id)
 {
   Translator_group * current = it->report_to ();
@@ -31,7 +31,7 @@ Auto_change_iterator::change_to (Music_iterator *it, String to_type,
      
      If \translator Staff = bass, then look for Staff = *
    */
-  while (current && current->type_string_ != to_type)
+  while (current && !current->is_alias_b (to_type_sym))
     {
       last = current;
       current = current->daddy_trans_;
@@ -47,7 +47,7 @@ Auto_change_iterator::change_to (Music_iterator *it, String to_type,
     if (last)
       {
        Translator_group * dest = 
-         it->report_to ()->find_create_translator (to_type, to_id);
+         it->report_to ()->find_create_translator (to_type_sym, to_id);
        current->remove_translator (last);
        dest->add_used_group_translator (last);
       }
@@ -86,11 +86,14 @@ Auto_change_iterator::pending_pitch (Moment m) const
     {
       SCM muses = iter->get_pending_events (m);
       for (SCM s = muses; gh_pair_p (s); s=ly_cdr (s))
-       if (Note_req* nr = dynamic_cast<Note_req*> (unsmob_music (ly_car (s))))
-         {
-           ps.push (*unsmob_pitch (nr->get_mus_property ("pitch")));
-         }
-
+       {
+         Music * m = unsmob_music (ly_car (s));
+         if (m && m->is_mus_type ("note-event"))
+           {
+             ps.push (*unsmob_pitch (m->get_mus_property ("pitch")));
+           }
+       }
+      
       if (ps.size ())
        break;
 
@@ -131,8 +134,7 @@ Auto_change_iterator::process (Moment m)
        {
          where_dir_ = s;
          String to_id = (s >= 0) ?  "up" : "down";
-         String wh = ly_scm2string (get_music ()->get_mus_property ("what"));
-         change_to (child_iter_, wh, to_id);     
+         change_to (child_iter_, get_music ()->get_mus_property ("what"), to_id);        
        }
     }
 }