2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1998--2015 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/>.
23 #include "engraver.hh"
25 #include "axis-group-interface.hh"
27 #include "grob-array.hh"
28 #include "international.hh"
30 #include "stream-event.hh"
31 #include "text-interface.hh"
34 #include "translator.icc"
37 put stuff over or next to bars. Examples: bar numbers, marginal notes,
40 class Mark_engraver : public Engraver
43 void create_items (Stream_event *);
46 Stream_event *mark_ev_;
49 TRANSLATOR_DECLARATIONS (Mark_engraver);
52 void process_music ();
53 void start_translation_timestep ();
54 void stop_translation_timestep ();
55 virtual void finalize ();
57 void listen_mark (Stream_event *);
58 void acknowledge_break_alignment (Grob_info);
61 Mark_engraver::Mark_engraver (Context *c)
70 Mark_engraver::acknowledge_break_alignment (Grob_info inf)
72 Grob *s = inf.grob ();
74 && dynamic_cast<Item *> (s))
75 text_->set_parent (s, X_AXIS);
79 Mark_engraver::start_translation_timestep ()
85 Mark_engraver::stop_translation_timestep ()
89 text_->set_object ("side-support-elements",
90 grob_list_to_grob_array (get_property ("stavesFound")));
98 Mark_engraver::finalize ()
101 final_text_->set_property ("break-visibility",
102 scm_c_make_vector (3, SCM_BOOL_T));
107 Mark_engraver::create_items (Stream_event *ev)
112 text_ = make_item ("RehearsalMark", ev->self_scm ());
116 Mark_engraver::listen_mark (Stream_event *ev)
118 ASSIGN_EVENT_ONCE (mark_ev_, ev);
122 TODO: make the increment function in Scheme.
125 Mark_engraver::process_music ()
129 create_items (mark_ev_);
135 SCM m = mark_ev_->get_property ("label");
136 SCM proc = get_property ("markFormatter");
137 if (!Text_interface::is_markup (m)
138 && ly_is_procedure (proc))
140 if (!scm_is_number (m))
141 m = get_property ("rehearsalMark");
143 if (scm_is_number (m))
145 context ()->set_property ("rehearsalMark", scm_oneplus (m));
146 m = scm_call_2 (proc, m, context ()->self_scm ());
149 /* Score.rehearsalMark is initialized to #1 so we
150 never should see this case without user error */
151 mark_ev_->origin ()->warning
152 (_ ("rehearsalMark must have integer value"));
155 if (Text_interface::is_markup (m))
156 text_->set_property ("text", m);
158 mark_ev_->origin ()->warning (_ ("mark label must be a markup object"));
164 Mark_engraver::boot ()
166 ADD_LISTENER (Mark_engraver, mark);
167 ADD_ACKNOWLEDGER (Mark_engraver, break_alignment);
170 ADD_TRANSLATOR (Mark_engraver,
172 "Create @code{RehearsalMark} objects. It puts them on top of"
173 " all staves (which is taken from the property"
174 " @code{stavesFound}). If moving this engraver to a different"
175 " context, @ref{Staff_collecting_engraver} must move along,"
176 " otherwise all marks end up on the same Y@tie{}location.",