]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / slur-performer.cc
1 /*
2   slur-performer.cc -- implement Slur_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "performer.hh"
10 #include "audio-item.hh"
11 #include "audio-column.hh"
12 #include "global-context.hh"
13 #include "warn.hh"
14 #include "music.hh"
15
16 /*
17   this is C&P from beam_performer.
18 */
19
20 class Slur_performer : public Performer
21 {
22 public:
23   TRANSLATOR_DECLARATIONS (Slur_performer);
24
25 protected:
26   virtual bool try_music (Music *ev);
27   void start_translation_timestep ();
28   void process_music ();
29   void set_melisma (bool);
30 private:
31   Music *start_ev_;
32   Music *now_stop_ev_;
33   bool slur_;
34 };
35
36 Slur_performer::Slur_performer ()
37 {
38   slur_ = false;
39   start_ev_ = 0;
40   now_stop_ev_ = 0;
41 }
42
43 void
44 Slur_performer::process_music ()
45 {
46   if (now_stop_ev_)
47     {
48       slur_ = false;
49       set_melisma (false);
50     }
51
52   if (start_ev_)
53     {
54       slur_ = true;
55       set_melisma (true);
56     }
57 }
58
59 void
60 Slur_performer::set_melisma (bool ml)
61 {
62   context ()->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
63 }
64
65 void
66 Slur_performer::start_translation_timestep ()
67 {
68   start_ev_ = 0;
69   now_stop_ev_ = 0;
70 }
71
72 bool
73 Slur_performer::try_music (Music *m)
74 {
75   if (m->is_mus_type ("slur-event"))
76     {
77       Direction d = to_dir (m->get_property ("span-direction"));
78
79       if (d == START)
80         start_ev_ = m;
81       else if (d == STOP)
82         now_stop_ev_ = m;
83       return true;
84     }
85   return false;
86 }
87
88 #include "translator.icc"
89
90 ADD_TRANSLATOR (Slur_performer,
91                 "", "",
92                 "slur-event",
93                 "", "");
94