lilypond-1.5.10
[lilypond.git] / lily / lyric-combine-music-iterator.cc
blob6052b89ffd8e80577b71bfe46617d68e27449ea9
1 /*
2 lyric-combine-music-iterator.cc -- implement Lyric_combine_music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "translator-group.hh"
11 #include "lyric-combine-music-iterator.hh"
12 #include "lyric-combine-music.hh"
13 #include "musical-request.hh"
16 Ugh, why static?
18 Busy_playing_req *busy_req;
19 Melisma_req *melisma_start_req;
20 Melisma_req *melisma_stop_req;
21 Melisma_playing_req * melisma_playing_req;
23 Lyric_combine_music_iterator::Lyric_combine_music_iterator ()
25 if (!busy_req)
27 busy_req = new Busy_playing_req;
28 melisma_playing_req = new Melisma_playing_req;
29 melisma_stop_req = new Melisma_req;
30 melisma_start_req = new Melisma_req;
32 melisma_start_req->set_span_dir (START);
33 melisma_stop_req->set_span_dir (STOP);
35 music_iter_p_ =0;
36 lyric_iter_p_ =0;
39 Moment
40 Lyric_combine_music_iterator::pending_moment () const
42 Moment musnext = music_iter_p_->pending_moment ();
43 return musnext;
46 bool
47 Lyric_combine_music_iterator::ok () const
49 return music_iter_p_->ok ();
53 void
54 Lyric_combine_music_iterator::construct_children ()
56 Lyric_combine_music const * m = dynamic_cast<Lyric_combine_music const*> (music_l ());
58 music_iter_p_ = get_iterator_p (m->music_l ());
59 lyric_iter_p_ = get_iterator_p (m->lyrics_l ());
62 void
63 Lyric_combine_music_iterator::process (Moment m)
65 Moment my_next = music_iter_p_->pending_moment ();
66 if (my_next > m)
67 return;
69 music_iter_p_->process (m);
71 bool busy = try_music (busy_req);
72 if (busy)
74 bool melisma_b = try_music (melisma_playing_req);
75 if (!melisma_b)
77 if (lyric_iter_p_->ok ())
79 // FIXME
80 #if 0 // devise a new way for this
81 if (melisma_b && !melisma_started_b_)
82 lyric_iter_p_->try_music (melisma_start_req);
83 else if (melisma_started_b_)
84 lyric_iter_p_->try_music (melisma_stop_req);
85 #endif
87 Moment m= lyric_iter_p_->pending_moment ();
88 lyric_iter_p_->process (m);
95 Lyric_combine_music_iterator::~Lyric_combine_music_iterator ()
97 delete lyric_iter_p_;
98 delete music_iter_p_;
101 Lyric_combine_music_iterator::Lyric_combine_music_iterator (Lyric_combine_music_iterator const & src)
102 : Music_iterator (src)
105 lyric_iter_p_ = src.lyric_iter_p_ ? src.lyric_iter_p_->clone () : 0;
106 music_iter_p_ = src.music_iter_p_ ? src.music_iter_p_->clone () : 0;
108 Music_iterator*
109 Lyric_combine_music_iterator::try_music_in_children (Music *m) const
111 Music_iterator * i = music_iter_p_->try_music (m);
112 if (i)
113 return i;
114 else
115 return lyric_iter_p_->try_music (m);
119 IMPLEMENT_CTOR_CALLBACK (Lyric_combine_music_iterator);