2 mark-engraver.cc -- implement Mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2007 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "engraver.hh"
14 #include "axis-group-interface.hh"
15 #include "bar-line.hh"
17 #include "grob-array.hh"
18 #include "international.hh"
20 #include "stream-event.hh"
21 #include "text-interface.hh"
24 #include "translator.icc"
27 put stuff over or next to bars. Examples: bar numbers, marginal notes,
30 class Mark_engraver
: public Engraver
33 void create_items (Stream_event
*);
35 Stream_event
*mark_ev_
;
38 TRANSLATOR_DECLARATIONS (Mark_engraver
);
41 void process_music ();
42 void stop_translation_timestep ();
44 DECLARE_TRANSLATOR_LISTENER (mark
);
45 DECLARE_ACKNOWLEDGER (break_alignment
);
48 Mark_engraver::Mark_engraver ()
55 Mark_engraver::acknowledge_break_alignment (Grob_info inf
)
57 Grob
*s
= inf
.grob ();
59 && dynamic_cast<Item
*> (s
))
61 text_
->set_parent (s
, X_AXIS
);
67 Mark_engraver::stop_translation_timestep ()
71 text_
->set_object ("side-support-elements",
72 grob_list_to_grob_array (get_property ("stavesFound")));
79 Mark_engraver::create_items (Stream_event
*ev
)
84 text_
= make_item ("RehearsalMark", ev
->self_scm ());
87 IMPLEMENT_TRANSLATOR_LISTENER (Mark_engraver
, mark
);
89 Mark_engraver::listen_mark (Stream_event
*ev
)
91 ASSIGN_EVENT_ONCE (mark_ev_
, ev
);
95 TODO: make the increment function in Scheme.
98 Mark_engraver::process_music ()
102 create_items (mark_ev_
);
108 SCM m
= mark_ev_
->get_property ("label");
109 SCM proc
= get_property ("markFormatter");
110 if (!Text_interface::is_markup (m
)
111 && ly_is_procedure (proc
))
113 if (!scm_is_number (m
))
114 m
= get_property ("rehearsalMark");
116 if (scm_integer_p (m
) == SCM_BOOL_T
117 && scm_exact_p (m
) == SCM_BOOL_T
)
119 int mark_count
= scm_to_int (m
);
121 context ()->set_property ("rehearsalMark",
122 scm_from_int (mark_count
));
125 if (scm_is_number (m
))
126 m
= scm_call_2 (proc
, m
, context ()->self_scm ());
128 /* FIXME: constant error message. */
129 warning (_ ("rehearsalMark must have integer value"));
132 if (Text_interface::is_markup (m
))
133 text_
->set_property ("text", m
);
135 warning (_ ("mark label must be a markup object"));
139 ADD_ACKNOWLEDGER (Mark_engraver
, break_alignment
);
141 ADD_TRANSLATOR (Mark_engraver
,
143 "Create @code{RehearsalMark} objects. It puts them on top of"
144 " all staves (which is taken from the property"
145 " @code{stavesFound}). If moving this engraver to a different"
146 " context, @ref{Staff_collecting_engraver} must move along,"
147 " otherwise all marks end up on the same Y@tie{}location.",