]> git.donarmstrong.com Git - lilypond.git/blob - lily/melisma-translator.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / melisma-translator.cc
1 /*
2   melisma-engraver.cc -- implement Melisma_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "engraver.hh"
10 #include "grob.hh"
11 #include "context.hh"
12 #include "translator.icc"
13
14 /**
15    Signal existence of melismas.
16 */
17 class Melisma_translator : public Translator
18 {
19 public:
20   TRANSLATOR_DECLARATIONS (Melisma_translator);
21 protected:
22   virtual bool try_music (Music *);
23   void process_music ();
24   void start_translation_timestep ();
25   Music *event_;
26 };
27
28 bool
29 Melisma_translator::try_music (Music *m)
30 {
31   if (m->is_mus_type ("melisma-playing-event"))
32     return melisma_busy (context ());
33   else if (m->is_mus_type ("melisma-span-event"))
34     {
35       event_ = m;
36       return true;
37     }
38
39   return false;
40 }
41
42 void
43 Melisma_translator::process_music ()
44 {
45   if (event_)
46     {
47       SCM sd = event_->get_property ("span-direction");
48       Direction d = to_dir (sd);
49       if (d == START)
50         context ()->set_property ("melismaBusy", SCM_BOOL_T);
51       else
52         context ()->unset_property (ly_symbol2scm ("melismaBusy"));
53     }
54 }
55
56 void
57 Melisma_translator::start_translation_timestep ()
58 {
59   event_ = 0;
60 }
61
62 Melisma_translator::Melisma_translator ()
63 {
64   event_ = 0;
65 }
66
67 ADD_TRANSLATOR (Melisma_translator,
68                 /* doc */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code.  ",
69                 /* create */ "",
70                 /* accept */ "melisma-playing-event melisma-span-event",
71                 /* read */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy",
72                 /* write */ "");