2 mark-engraver.cc -- implement Mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "bar-line.hh"
14 #include "engraver-group.hh"
17 #include "text-interface.hh"
18 #include "grob-array.hh"
21 put stuff over or next to bars. Examples: bar numbers, marginal notes,
24 class Mark_engraver : public Engraver
27 TRANSLATOR_DECLARATIONS (Mark_engraver);
31 void stop_translation_timestep ();
32 DECLARE_ACKNOWLEDGER (bar_line);
33 void create_items (Music *);
34 virtual bool try_music (Music *ev);
35 void process_music ();
41 Mark_engraver::Mark_engraver ()
48 Mark_engraver::acknowledge_bar_line (Grob_info inf)
50 Grob *s = inf.grob ();
54 TODO: make this configurable. RehearsalMark cannot be
55 break-aligned, since the width of the object should not be taken
56 into alignment considerations.
58 text_->set_parent (s, X_AXIS);
63 Mark_engraver::stop_translation_timestep ()
67 text_->set_object ("side-support-elements",
68 grob_list_to_grob_array (get_property ("stavesFound")));
75 Mark_engraver::create_items (Music *ev)
80 text_ = make_item ("RehearsalMark", ev->self_scm ());
84 Mark_engraver::try_music (Music *r)
91 TODO: make the increment function in Scheme.
94 Mark_engraver::process_music ()
98 create_items (mark_ev_);
104 SCM m = mark_ev_->get_property ("label");
105 SCM proc = get_property ("markFormatter");
106 if (!Text_interface::is_markup (m)
107 && ly_is_procedure (proc))
109 if (!scm_is_number (m))
110 m = get_property ("rehearsalMark");
112 if (scm_integer_p (m) == SCM_BOOL_T
113 && scm_exact_p (m) == SCM_BOOL_T)
115 int mark_count = scm_to_int (m);
117 context ()->set_property ("rehearsalMark",
118 scm_from_int (mark_count));
121 if (scm_is_number (m))
122 m = scm_call_2 (proc, m, context ()->self_scm ());
124 /* FIXME: constant error message. */
125 warning (_ ("rehearsalMark must have integer value"));
128 if (Text_interface::is_markup (m))
129 text_->set_property ("text", m);
131 warning (_ ("mark label must be a markup object"));
135 #include "translator.icc"
137 ADD_ACKNOWLEDGER (Mark_engraver, bar_line);
138 ADD_TRANSLATOR (Mark_engraver,
139 /* doc */ "This engraver will create RehearsalMark objects. "
140 "It puts them on top of all staves (which is taken from "
141 "the property @code{stavesFound}). If moving this engraver "
142 "to a different context, "
143 "@ref{Staff_collecting_engraver} must move along, otherwise all marks"
144 "end up on the same Y-location",
145 /* create */ "RehearsalMark",
146 /* accept */ "mark-event",
147 /* read */ "rehearsalMark markFormatter stavesFound",