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
);
46 DECLARE_ACKNOWLEDGER (break_aligned
);
49 Mark_engraver::Mark_engraver ()
56 This is a flawed approach, since various break-aligned objects may
57 not appear depending on key signature etc.
59 We keep it in case someone puts the engraver in a lower context than score.
62 Mark_engraver::acknowledge_break_aligned (Grob_info inf
)
64 Grob
*s
= inf
.grob ();
66 && !text_
->get_parent (X_AXIS
)
67 && (text_
->get_property_data ("break-align-symbol")
68 == s
->get_property_data ("break-align-symbol"))
69 && Axis_group_interface::has_interface (s
))
72 RehearsalMark cannot be break-aligned, since the width of the
73 object should not be taken into alignment considerations.
75 text_
->set_parent (s
, X_AXIS
);
80 Mark_engraver::acknowledge_break_alignment (Grob_info inf
)
82 Grob
*s
= inf
.grob ();
84 && dynamic_cast<Item
*> (s
))
86 text_
->set_parent (s
, X_AXIS
);
92 Mark_engraver::stop_translation_timestep ()
96 text_
->set_object ("side-support-elements",
97 grob_list_to_grob_array (get_property ("stavesFound")));
104 Mark_engraver::create_items (Stream_event
*ev
)
109 text_
= make_item ("RehearsalMark", ev
->self_scm ());
112 IMPLEMENT_TRANSLATOR_LISTENER (Mark_engraver
, mark
);
114 Mark_engraver::listen_mark (Stream_event
*ev
)
116 ASSIGN_EVENT_ONCE (mark_ev_
, ev
);
120 TODO: make the increment function in Scheme.
123 Mark_engraver::process_music ()
127 create_items (mark_ev_
);
133 SCM m
= mark_ev_
->get_property ("label");
134 SCM proc
= get_property ("markFormatter");
135 if (!Text_interface::is_markup (m
)
136 && ly_is_procedure (proc
))
138 if (!scm_is_number (m
))
139 m
= get_property ("rehearsalMark");
141 if (scm_integer_p (m
) == SCM_BOOL_T
142 && scm_exact_p (m
) == SCM_BOOL_T
)
144 int mark_count
= scm_to_int (m
);
146 context ()->set_property ("rehearsalMark",
147 scm_from_int (mark_count
));
150 if (scm_is_number (m
))
151 m
= scm_call_2 (proc
, m
, context ()->self_scm ());
153 /* FIXME: constant error message. */
154 warning (_ ("rehearsalMark must have integer value"));
157 if (Text_interface::is_markup (m
))
158 text_
->set_property ("text", m
);
160 warning (_ ("mark label must be a markup object"));
164 ADD_ACKNOWLEDGER (Mark_engraver
, break_aligned
);
165 ADD_ACKNOWLEDGER (Mark_engraver
, break_alignment
);
167 ADD_TRANSLATOR (Mark_engraver
,
168 /* doc */ "This engraver will create RehearsalMark objects. "
169 "It puts them on top of all staves (which is taken from "
170 "the property @code{stavesFound}). If moving this engraver "
171 "to a different context, "
172 "@ref{Staff_collecting_engraver} must move along, otherwise all marks"
173 "end up on the same Y-location",
175 /* create */ "RehearsalMark",