]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
* lily/beam-performer.cc (process_music): idem.
[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--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7  */
8
9 #include "performer.hh"
10 #include "event.hh"
11 #include "audio-item.hh"
12 #include "audio-column.hh"
13 #include "global-context.hh"
14 #include "warn.hh"
15
16 /*
17   this is C&P from beam_performer.
18  */
19
20 class Slur_performer : public Performer {
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 void 
36 Slur_performer::process_music ()
37 {
38   if (now_stop_ev_)
39     {
40       slur_ = false;
41       set_melisma (false);
42     }
43
44   if (start_ev_)
45     {
46       slur_ = true;
47       set_melisma (true);
48     }
49 }
50
51
52 void
53 Slur_performer::set_melisma (bool ml)
54 {
55   daddy_context_->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
56 }
57
58 void
59 Slur_performer::start_translation_timestep ()
60 {
61   start_ev_ = 0;
62   now_stop_ev_ = 0;
63 }
64  
65 bool
66 Slur_performer::try_music (Music *m)
67 {
68   if (m->is_mus_type ("slur-event"))
69     {
70       Direction d = to_dir (m->get_property ("span-direction"));
71
72       if (d == START)
73         {
74           start_ev_ = m;
75         }
76       else if (d==STOP)
77         {
78           now_stop_ev_ = m;
79         }
80       return true;
81     }
82   return false;
83 }
84
85 ENTER_DESCRIPTION (Slur_performer,"","",
86                   "slur-event","","","");
87
88 Slur_performer::Slur_performer ()
89 {
90   slur_ = false;
91 }