]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
* scm/music-functions.scm (has-request-chord): don't use
[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 public:
21   TRANSLATOR_DECLARATIONS (Slur_performer);
22   
23 protected:
24   virtual bool try_music (Music *ev) ;
25   virtual void start_translation_timestep ();
26   virtual void process_music ();
27   void set_melisma (bool);
28 private:
29   Music *start_ev_;
30   Music *now_stop_ev_;
31   bool slur_;
32 };
33
34 Slur_performer::Slur_performer ()
35 {
36   slur_ = false;
37   start_ev_ = 0;
38   now_stop_ev_ = 0;
39 }
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
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         {
81           start_ev_ = m;
82         }
83       else if (d == STOP)
84         {
85           now_stop_ev_ = m;
86         }
87       return true;
88     }
89   return false;
90 }
91
92 ADD_TRANSLATOR (Slur_performer, "", "",
93                   "slur-event", "", "", "");
94