]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lyric-combine-music-iterator.cc
Web-ja: update introduction
[lilypond.git] / lily / lyric-combine-music-iterator.cc
index c0c1af5a61a3c1834618661e19747599056c1532..336b167f2e98cdf2d4179b687330d1913b6d21b9 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2004--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2004--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ protected:
 private:
   bool start_new_syllable () const;
   Context *find_voice ();
-  DECLARE_LISTENER (set_busy);
-  DECLARE_LISTENER (check_new_context);
+  void set_busy (SCM);
+  void check_new_context (SCM);
 
   bool music_found_;
   bool lyrics_found_;
@@ -93,11 +93,10 @@ Lyric_combine_music_iterator::Lyric_combine_music_iterator ()
   associatedVoice switching, this routine may be triggered for
   the wrong music_context_
  */
-IMPLEMENT_LISTENER (Lyric_combine_music_iterator, set_busy)
 void
 Lyric_combine_music_iterator::set_busy (SCM se)
 {
-  Stream_event *e = Stream_event::unsmob (se);
+  Stream_event *e = unsmob<Stream_event> (se);
 
   if ((e->in_event_class ("note-event") || e->in_event_class ("cluster-note-event"))
       && music_context_)
@@ -113,13 +112,13 @@ Lyric_combine_music_iterator::set_music_context (Context *to)
   if (music_context_)
     {
       music_context_->events_below ()->
-      remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("rhythmic-event"));
+      remove_listener (GET_LISTENER (Lyric_combine_music_iterator, set_busy), ly_symbol2scm ("rhythmic-event"));
     }
 
   music_context_ = to;
   if (to)
     {
-      to->events_below ()->add_listener (GET_LISTENER (set_busy),
+      to->events_below ()->add_listener (GET_LISTENER (Lyric_combine_music_iterator, set_busy),
                                          ly_symbol2scm ("rhythmic-event"));
     }
 }
@@ -162,7 +161,8 @@ Lyric_combine_music_iterator::run_always () const
 bool
 Lyric_combine_music_iterator::ok () const
 {
-  return lyric_iter_ && lyric_iter_->ok ();
+  return lyric_iter_ && lyric_iter_->ok ()
+    && !(music_context_ && music_context_->is_removable ());
 }
 
 void
@@ -192,8 +192,8 @@ Lyric_combine_music_iterator::derived_substitute (Context *f, Context *t)
 void
 Lyric_combine_music_iterator::construct_children ()
 {
-  Music *m = Music::unsmob (get_music ()->get_property ("element"));
-  lyric_iter_ = Music_iterator::unsmob (get_iterator (m));
+  Music *m = unsmob<Music> (get_music ()->get_property ("element"));
+  lyric_iter_ = unsmob<Music_iterator> (get_iterator (m));
   if (!lyric_iter_)
     return;
   lyrics_context_ = find_context_below (lyric_iter_->get_outlet (),
@@ -218,7 +218,7 @@ Lyric_combine_music_iterator::construct_children ()
     delayed when voices are created implicitly.
   */
   Global_context *g = get_outlet ()->get_global_context ();
-  g->events_below ()->add_listener (GET_LISTENER (check_new_context), ly_symbol2scm ("CreateContext"));
+  g->events_below ()->add_listener (GET_LISTENER (Lyric_combine_music_iterator, check_new_context), ly_symbol2scm ("CreateContext"));
 
   /*
     We do not create a Lyrics context, because the user might
@@ -227,7 +227,6 @@ Lyric_combine_music_iterator::construct_children ()
   */
 }
 
-IMPLEMENT_LISTENER (Lyric_combine_music_iterator, check_new_context)
 void
 Lyric_combine_music_iterator::check_new_context (SCM /*sev*/)
 {
@@ -267,12 +266,8 @@ Lyric_combine_music_iterator::find_voice ()
       && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ())
       && scm_is_symbol (voice_type))
     {
-      Context *t = get_outlet ();
-      while (t && t->get_parent_context ())
-        t = t->get_parent_context ();
-
-      string name = ly_scm2string (voice_name);
-      return find_context_below (t, voice_type, name);
+      return find_context_below (find_top_context (get_outlet ()),
+                                 voice_type, ly_scm2string (voice_name));
     }
 
   return 0;