]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
* flower
[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--2005 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
15 /*
16   this is C&P from beam_performer.
17 */
18
19 class Slur_performer : public Performer
20 {
21 public:
22   TRANSLATOR_DECLARATIONS (Slur_performer);
23
24 protected:
25   virtual bool try_music (Music *ev);
26   virtual void start_translation_timestep ();
27   virtual void process_music ();
28   void set_melisma (bool);
29 private:
30   Music *start_ev_;
31   Music *now_stop_ev_;
32   bool slur_;
33 };
34
35 Slur_performer::Slur_performer ()
36 {
37   slur_ = false;
38   start_ev_ = 0;
39   now_stop_ev_ = 0;
40 }
41
42 void
43 Slur_performer::process_music ()
44 {
45   if (now_stop_ev_)
46     {
47       slur_ = false;
48       set_melisma (false);
49     }
50
51   if (start_ev_)
52     {
53       slur_ = true;
54       set_melisma (true);
55     }
56 }
57
58 void
59 Slur_performer::set_melisma (bool ml)
60 {
61   context ()->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
62 }
63
64 void
65 Slur_performer::start_translation_timestep ()
66 {
67   start_ev_ = 0;
68   now_stop_ev_ = 0;
69 }
70
71 bool
72 Slur_performer::try_music (Music *m)
73 {
74   if (m->is_mus_type ("slur-event"))
75     {
76       Direction d = to_dir (m->get_property ("span-direction"));
77
78       if (d == START)
79         {
80           start_ev_ = m;
81         }
82       else if (d == STOP)
83         {
84           now_stop_ev_ = m;
85         }
86       return true;
87     }
88   return false;
89 }
90
91 ADD_TRANSLATOR (Slur_performer, "", "",
92                 "slur-event", "", "", "");
93