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