2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2002--2011 Juergen Reuter <reuter@ipd.uka.de>
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 "international.hh"
22 #include "engraver.hh"
23 #include "note-column.hh"
24 #include "tuplet-bracket.hh"
26 #include "stream-event.hh"
29 #include "translator.icc"
31 class Ligature_bracket_engraver : public Engraver
34 virtual void process_music ();
35 virtual void stop_translation_timestep ();
36 DECLARE_ACKNOWLEDGER (rest);
37 DECLARE_ACKNOWLEDGER (note_column);
38 DECLARE_TRANSLATOR_LISTENER (ligature);
40 TRANSLATOR_DECLARATIONS (Ligature_bracket_engraver);
43 Drul_array<Stream_event *> events_drul_;
44 Spanner *finished_ligature_;
46 Stream_event *previous_start_event_;
49 IMPLEMENT_TRANSLATOR_LISTENER (Ligature_bracket_engraver, ligature);
51 Ligature_bracket_engraver::listen_ligature (Stream_event *ev)
53 Direction d = to_dir (ev->get_property ("span-direction"));
54 ASSIGN_EVENT_ONCE (events_drul_[d], ev);
57 Ligature_bracket_engraver::Ligature_bracket_engraver ()
60 finished_ligature_ = 0;
61 events_drul_[LEFT] = events_drul_[RIGHT] = 0;
62 previous_start_event_ = 0;
66 Ligature_bracket_engraver::process_music()
68 if (events_drul_[STOP])
72 events_drul_[STOP]->origin ()->warning (_ ("cannot find start of ligature"));
76 finished_ligature_ = ligature_;
78 previous_start_event_ = 0;
81 if (events_drul_[START])
85 events_drul_[START]->origin ()->warning (_ ("already have a ligature"));
89 previous_start_event_ = events_drul_[START];
90 ligature_ = make_spanner ("LigatureBracket", events_drul_[START]->self_scm ());
95 Ligature_bracket_engraver::acknowledge_note_column (Grob_info info)
99 Tuplet_bracket::add_column (ligature_,
101 add_bound_item (ligature_, info.item());
106 Ligature_bracket_engraver::acknowledge_rest (Grob_info info)
108 acknowledge_note_column(info);
113 Ligature_bracket_engraver::stop_translation_timestep ()
116 events_drul_[RIGHT] = 0;
117 finished_ligature_ = 0;
120 ADD_ACKNOWLEDGER (Ligature_bracket_engraver, rest);
121 ADD_ACKNOWLEDGER (Ligature_bracket_engraver, note_column);
123 ADD_TRANSLATOR (Ligature_bracket_engraver,
125 "Handle @code{Ligature_events} by engraving @code{Ligature}"