2 mark-engraver.cc -- implement Mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2009 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
*);
36 Stream_event
*mark_ev_
;
39 TRANSLATOR_DECLARATIONS (Mark_engraver
);
42 void process_music ();
43 void start_translation_timestep ();
44 void stop_translation_timestep ();
45 virtual void finalize ();
47 DECLARE_TRANSLATOR_LISTENER (mark
);
48 DECLARE_ACKNOWLEDGER (break_alignment
);
51 Mark_engraver::Mark_engraver ()
59 Mark_engraver::acknowledge_break_alignment (Grob_info inf
)
61 Grob
*s
= inf
.grob ();
63 && dynamic_cast<Item
*> (s
))
64 text_
->set_parent (s
, X_AXIS
);
68 Mark_engraver::start_translation_timestep ()
74 Mark_engraver::stop_translation_timestep ()
78 text_
->set_object ("side-support-elements",
79 grob_list_to_grob_array (get_property ("stavesFound")));
87 Mark_engraver::finalize ()
90 final_text_
->set_property ("break-visibility",
91 scm_c_make_vector (3, SCM_BOOL_T
));
96 Mark_engraver::create_items (Stream_event
*ev
)
101 text_
= make_item ("RehearsalMark", ev
->self_scm ());
104 IMPLEMENT_TRANSLATOR_LISTENER (Mark_engraver
, mark
);
106 Mark_engraver::listen_mark (Stream_event
*ev
)
108 ASSIGN_EVENT_ONCE (mark_ev_
, ev
);
112 TODO: make the increment function in Scheme.
115 Mark_engraver::process_music ()
119 create_items (mark_ev_
);
125 SCM m
= mark_ev_
->get_property ("label");
126 SCM proc
= get_property ("markFormatter");
127 if (!Text_interface::is_markup (m
)
128 && ly_is_procedure (proc
))
130 if (!scm_is_number (m
))
131 m
= get_property ("rehearsalMark");
133 if (scm_integer_p (m
) == SCM_BOOL_T
134 && scm_exact_p (m
) == SCM_BOOL_T
)
136 int mark_count
= scm_to_int (m
);
138 context ()->set_property ("rehearsalMark",
139 scm_from_int (mark_count
));
142 if (scm_is_number (m
))
143 m
= scm_call_2 (proc
, m
, context ()->self_scm ());
145 /* FIXME: constant error message. */
146 warning (_ ("rehearsalMark must have integer value"));
149 if (Text_interface::is_markup (m
))
150 text_
->set_property ("text", m
);
152 warning (_ ("mark label must be a markup object"));
156 ADD_ACKNOWLEDGER (Mark_engraver
, break_alignment
);
158 ADD_TRANSLATOR (Mark_engraver
,
160 "Create @code{RehearsalMark} objects. It puts them on top of"
161 " all staves (which is taken from the property"
162 " @code{stavesFound}). If moving this engraver to a different"
163 " context, @ref{Staff_collecting_engraver} must move along,"
164 " otherwise all marks end up on the same Y@tie{}location.",