]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-engraver.cc
* lily/melisma-engraver.cc (try_music): use melisma_busy()
[lilypond.git] / lily / lyric-engraver.cc
1 /*
2   lyric-engraver.cc -- implement Lyric_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include "engraver.hh"
11 #include "event.hh"
12 #include "item.hh"
13 #include "paper-def.hh"
14 #include "font-metric.hh"
15 #include "side-position-interface.hh"
16
17 /**
18    Generate texts for lyric syllables.  We only do one lyric at a time.  
19    Multiple copies of this engraver should be used to do multiple voices.
20  */
21 class Lyric_engraver : public Engraver 
22 {
23 protected:
24   virtual void stop_translation_timestep ();
25   virtual bool try_music (Music *);
26   virtual void process_music ();
27   virtual void start_translation_timestep ();
28   
29 public:
30   TRANSLATOR_DECLARATIONS(Lyric_engraver);
31 private:
32   Music * req_;
33   Item* text_;
34 };
35
36
37
38
39 Lyric_engraver::Lyric_engraver ()
40 {
41   text_ =0;
42   req_ =0;
43 }
44
45 bool
46 Lyric_engraver::try_music (Music*r)
47 {
48   if (r->is_mus_type ("lyric-event"))
49     {
50       if (req_)
51         return false;
52       req_ =r;
53       return true;
54     }
55   return false;
56 }
57
58 void
59 Lyric_engraver::process_music ()
60 {
61   if (req_)
62     {
63       text_=  new Item (get_property ("LyricText"));
64       
65       text_->set_grob_property ("text", req_->get_mus_property ("text"));
66       announce_grob (text_, req_->self_scm());
67     }
68 }
69
70 void
71 Lyric_engraver::stop_translation_timestep ()
72 {
73   if (text_)
74     {
75       typeset_grob (text_);
76       text_ =0;
77     }
78 }
79
80 void
81 Lyric_engraver::start_translation_timestep ()
82 {
83   req_ =0;
84 }
85
86
87 ENTER_DESCRIPTION(Lyric_engraver,
88 /* descr */       "",
89 /* creats*/       "",
90 /* accepts */     "lyric-event",
91 /* acks  */      "",
92 /* reads */       "",
93 /* write */       "");