2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2010 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 DECLARE_TRANSLATOR_LISTENER (episema
);
37 DECLARE_ACKNOWLEDGER (note_column
);
38 DECLARE_ACKNOWLEDGER (note_head
);
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);
59 IMPLEMENT_TRANSLATOR_LISTENER (Episema_engraver
, episema
);
61 Episema_engraver::listen_episema (Stream_event
*ev
)
63 Direction d
= to_dir (ev
->get_property ("span-direction"));
64 // Must not ASSIGN_EVENT_ONCE here, since episema
65 // can be typeset over a single neume
70 Episema_engraver::process_music ()
72 if (event_drul_
[START
])
75 event_drul_
[START
]->origin ()->warning (_ ("already have an episema"));
78 current_event_
= event_drul_
[START
];
79 span_
= make_spanner ("Episema", event_drul_
[START
]->self_scm ());
81 event_drul_
[START
] = 0;
84 if (event_drul_
[STOP
])
88 ->origin ()->warning (_ ("cannot find start of episema"));
92 announce_end_grob (finished_
, SCM_EOL
);
95 note_columns_
.clear ();
101 Episema_engraver::typeset_all ()
105 if (!finished_
->get_bound (RIGHT
))
107 Grob
*col
= (note_columns_
.size ()
108 ? note_columns_
.back ()
109 : unsmob_grob (get_property ("currentMusicalColumn")));
110 finished_
->set_bound (RIGHT
, col
);
117 Episema_engraver::stop_translation_timestep ()
119 if (span_
&& !span_
->get_bound (LEFT
))
121 Grob
*col
= (note_columns_
.size ()
122 ? note_columns_
.front ()
123 : unsmob_grob (get_property ("currentMusicalColumn")));
124 span_
->set_bound (LEFT
, col
);
128 event_drul_
.set (0, 0);
132 Episema_engraver::finalize ()
137 current_event_
->origin ()->warning (_ ("unterminated episema"));
144 Episema_engraver::acknowledge_note_column (Grob_info info
)
146 note_columns_
.push_back (info
.grob ());
150 Episema_engraver::acknowledge_note_head (Grob_info info
)
154 Side_position_interface::add_support (span_
, info
.grob ());
155 add_bound_item (span_
, info
.grob ());
159 Side_position_interface::add_support (finished_
, info
.grob ());
160 add_bound_item (finished_
, info
.grob ());
164 ADD_ACKNOWLEDGER (Episema_engraver
, note_column
);
165 ADD_ACKNOWLEDGER (Episema_engraver
, note_head
);
167 ADD_TRANSLATOR (Episema_engraver
,
169 "Create an @emph{Editio Vaticana}-style episema line.",