Update from Andrew: tweaks for cross-staff chords snippet.
[lilypond.git] / lily / beam-performer.cc
blob34a1a86482d89386f87337da7ca740bd5f0ebd3a
1 /*
2 beam-performer.cc -- implement Beam_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2007 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "performer.hh"
10 #include "audio-item.hh"
11 #include "audio-column.hh"
12 #include "global-context.hh"
13 #include "stream-event.hh"
14 #include "warn.hh"
16 #include "translator.icc"
18 class Beam_performer : public Performer
20 public:
21 TRANSLATOR_DECLARATIONS (Beam_performer);
23 protected:
24 void start_translation_timestep ();
25 void process_music ();
26 void set_melisma (bool);
27 DECLARE_TRANSLATOR_LISTENER (beam);
28 private:
29 Stream_event *start_ev_;
30 Stream_event *now_stop_ev_;
31 bool beam_;
34 Beam_performer::Beam_performer ()
36 beam_ = false;
37 start_ev_ = 0;
38 now_stop_ev_ = 0;
41 void
42 Beam_performer::process_music ()
44 if (now_stop_ev_)
46 beam_ = false;
47 set_melisma (false);
50 if (start_ev_)
52 beam_ = true;
53 set_melisma (true);
57 void
58 Beam_performer::set_melisma (bool ml)
60 SCM b = get_property ("autoBeaming");
61 if (!to_boolean (b))
62 context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
65 void
66 Beam_performer::start_translation_timestep ()
68 start_ev_ = 0;
69 now_stop_ev_ = 0;
72 IMPLEMENT_TRANSLATOR_LISTENER (Beam_performer, beam);
73 void
74 Beam_performer::listen_beam (Stream_event *ev)
76 Direction d = to_dir (ev->get_property ("span-direction"));
78 if (d == START)
79 start_ev_ = ev;
80 else if (d == STOP)
81 now_stop_ev_ = ev;
84 ADD_TRANSLATOR (Beam_performer,
85 /* doc */
86 "",
88 /* create */
89 "",
91 /* read */
92 "",
94 /* write */