2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2010--2015 Neil Puttock <n.puttock@gmail.com>
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 "engraver.hh"
21 #include "international.hh"
22 #include "note-column.hh"
23 #include "pointer-group-interface.hh"
24 #include "side-position-interface.hh"
26 #include "stream-event.hh"
28 #include "translator.icc"
32 class Episema_engraver : public Engraver
35 TRANSLATOR_DECLARATIONS (Episema_engraver);
37 virtual void finalize ();
38 DECLARE_TRANSLATOR_LISTENER (episema);
39 DECLARE_ACKNOWLEDGER (note_column);
40 DECLARE_ACKNOWLEDGER (note_head);
41 void stop_translation_timestep ();
42 void process_music ();
47 Stream_event *current_event_;
48 Drul_array<Stream_event *> event_drul_;
49 vector<Grob *> note_columns_;
53 Episema_engraver::Episema_engraver ()
58 event_drul_.set (0, 0);
61 IMPLEMENT_TRANSLATOR_LISTENER (Episema_engraver, episema);
63 Episema_engraver::listen_episema (Stream_event *ev)
65 Direction d = to_dir (ev->get_property ("span-direction"));
66 // Must not ASSIGN_EVENT_ONCE here, since episema
67 // can be typeset over a single neume
72 Episema_engraver::process_music ()
74 if (event_drul_[START])
77 event_drul_[START]->origin ()->warning (_ ("already have an episema"));
80 current_event_ = event_drul_[START];
81 span_ = make_spanner ("Episema", event_drul_[START]->self_scm ());
83 event_drul_[START] = 0;
86 if (event_drul_[STOP])
90 ->origin ()->warning (_ ("cannot find start of episema"));
94 announce_end_grob (finished_, SCM_EOL);
97 note_columns_.clear ();
103 Episema_engraver::typeset_all ()
107 if (!finished_->get_bound (RIGHT))
109 Grob *col = (note_columns_.size ()
110 ? note_columns_.back ()
111 : unsmob<Grob> (get_property ("currentMusicalColumn")));
112 finished_->set_bound (RIGHT, col);
119 Episema_engraver::stop_translation_timestep ()
121 if (span_ && !span_->get_bound (LEFT))
123 Grob *col = (note_columns_.size ()
124 ? note_columns_.front ()
125 : unsmob<Grob> (get_property ("currentMusicalColumn")));
126 span_->set_bound (LEFT, col);
130 event_drul_.set (0, 0);
134 Episema_engraver::finalize ()
139 current_event_->origin ()->warning (_ ("unterminated episema"));
146 Episema_engraver::acknowledge_note_column (Grob_info info)
148 note_columns_.push_back (info.grob ());
152 Episema_engraver::acknowledge_note_head (Grob_info info)
156 Side_position_interface::add_support (span_, info.grob ());
157 add_bound_item (span_, info.grob ());
161 Side_position_interface::add_support (finished_, info.grob ());
162 add_bound_item (finished_, info.grob ());
166 ADD_ACKNOWLEDGER (Episema_engraver, note_column);
167 ADD_ACKNOWLEDGER (Episema_engraver, note_head);
169 ADD_TRANSLATOR (Episema_engraver,
171 "Create an @emph{Editio Vaticana}-style episema line.",