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"
30 class Episema_engraver : public Engraver
33 TRANSLATOR_DECLARATIONS (Episema_engraver);
35 virtual void finalize ();
36 void listen_episema (Stream_event *);
37 void acknowledge_note_column (Grob_info);
38 void acknowledge_note_head (Grob_info);
39 void stop_translation_timestep ();
40 void process_music ();
45 Stream_event *current_event_;
46 Drul_array<Stream_event *> event_drul_;
47 vector<Grob *> note_columns_;
51 Episema_engraver::Episema_engraver ()
56 event_drul_.set (0, 0);
60 Episema_engraver::listen_episema (Stream_event *ev)
62 Direction d = to_dir (ev->get_property ("span-direction"));
63 // Must not ASSIGN_EVENT_ONCE here, since episema
64 // can be typeset over a single neume
69 Episema_engraver::process_music ()
71 if (event_drul_[START])
74 event_drul_[START]->origin ()->warning (_ ("already have an episema"));
77 current_event_ = event_drul_[START];
78 span_ = make_spanner ("Episema", event_drul_[START]->self_scm ());
80 event_drul_[START] = 0;
83 if (event_drul_[STOP])
87 ->origin ()->warning (_ ("cannot find start of episema"));
91 announce_end_grob (finished_, SCM_EOL);
94 note_columns_.clear ();
100 Episema_engraver::typeset_all ()
104 if (!finished_->get_bound (RIGHT))
106 Grob *col = (note_columns_.size ()
107 ? note_columns_.back ()
108 : unsmob<Grob> (get_property ("currentMusicalColumn")));
109 finished_->set_bound (RIGHT, col);
116 Episema_engraver::stop_translation_timestep ()
118 if (span_ && !span_->get_bound (LEFT))
120 Grob *col = (note_columns_.size ()
121 ? note_columns_.front ()
122 : unsmob<Grob> (get_property ("currentMusicalColumn")));
123 span_->set_bound (LEFT, col);
127 event_drul_.set (0, 0);
131 Episema_engraver::finalize ()
136 current_event_->origin ()->warning (_ ("unterminated episema"));
143 Episema_engraver::acknowledge_note_column (Grob_info info)
145 note_columns_.push_back (info.grob ());
149 Episema_engraver::acknowledge_note_head (Grob_info info)
153 Side_position_interface::add_support (span_, info.grob ());
154 add_bound_item (span_, info.grob ());
158 Side_position_interface::add_support (finished_, info.grob ());
159 add_bound_item (finished_, info.grob ());
165 Episema_engraver::boot ()
167 ADD_LISTENER (Episema_engraver, episema);
168 ADD_ACKNOWLEDGER (Episema_engraver, note_column);
169 ADD_ACKNOWLEDGER (Episema_engraver, note_head);
172 ADD_TRANSLATOR (Episema_engraver,
174 "Create an @emph{Editio Vaticana}-style episema line.",