Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / beam-performer.cc
blobd14879bf93b1c01366c8d9aec7b8194918680a76
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1996--2011 Jan Nieuwenhuizen <janneke@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "performer.hh"
21 #include "audio-item.hh"
22 #include "audio-column.hh"
23 #include "global-context.hh"
24 #include "stream-event.hh"
25 #include "warn.hh"
27 #include "translator.icc"
29 class Beam_performer : public Performer
31 public:
32 TRANSLATOR_DECLARATIONS (Beam_performer);
34 protected:
35 void start_translation_timestep ();
36 void process_music ();
37 void set_melisma (bool);
38 DECLARE_TRANSLATOR_LISTENER (beam);
39 private:
40 Stream_event *start_ev_;
41 Stream_event *now_stop_ev_;
42 bool beam_;
45 Beam_performer::Beam_performer ()
47 beam_ = false;
48 start_ev_ = 0;
49 now_stop_ev_ = 0;
52 void
53 Beam_performer::process_music ()
55 if (now_stop_ev_)
57 beam_ = false;
58 set_melisma (false);
61 if (start_ev_)
63 beam_ = true;
64 set_melisma (true);
68 void
69 Beam_performer::set_melisma (bool ml)
71 SCM b = get_property ("autoBeaming");
72 if (!to_boolean (b))
73 context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
76 void
77 Beam_performer::start_translation_timestep ()
79 start_ev_ = 0;
80 now_stop_ev_ = 0;
83 IMPLEMENT_TRANSLATOR_LISTENER (Beam_performer, beam);
84 void
85 Beam_performer::listen_beam (Stream_event *ev)
87 Direction d = to_dir (ev->get_property ("span-direction"));
89 if (d == START)
90 start_ev_ = ev;
91 else if (d == STOP)
92 now_stop_ev_ = ev;
95 ADD_TRANSLATOR (Beam_performer,
96 /* doc */
97 "",
99 /* create */
102 /* read */
105 /* write */