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>
11 #include "bar-line.hh"
13 #include "engraver-group-engraver.hh"
16 #include "text-interface.hh"
17 #include "grob-array.hh"
20 put stuff over or next to bars. Examples: bar numbers, marginal notes,
23 class Mark_engraver : public Engraver
26 TRANSLATOR_DECLARATIONS (Mark_engraver);
30 void stop_translation_timestep ();
31 DECLARE_ACKNOWLEDGER (bar_line);
32 void create_items (Music *);
33 virtual bool try_music (Music *ev);
34 void process_music ();
40 Mark_engraver::Mark_engraver ()
47 Mark_engraver::acknowledge_bar_line (Grob_info inf)
49 Grob *s = inf.grob ();
53 TODO: make this configurable. RehearsalMark cannot be
54 break-aligned, since the width of the object should not be taken
55 into alignment considerations.
57 text_->set_parent (s, X_AXIS);
62 Mark_engraver::stop_translation_timestep ()
66 text_->set_object ("side-support-elements",
67 grob_list_to_grob_array (get_property ("stavesFound")));
74 Mark_engraver::create_items (Music *ev)
79 text_ = make_item ("RehearsalMark", ev->self_scm ());
83 Mark_engraver::try_music (Music *r)
90 TODO: make the increment function in Scheme.
93 Mark_engraver::process_music ()
97 create_items (mark_ev_);
103 SCM m = mark_ev_->get_property ("label");
104 SCM proc = get_property ("markFormatter");
105 if (!Text_interface::is_markup (m)
106 && ly_is_procedure (proc))
108 if (!scm_is_number (m))
109 m = get_property ("rehearsalMark");
111 if (scm_integer_p (m) == SCM_BOOL_T
112 && scm_exact_p (m) == SCM_BOOL_T)
114 int mark_count = scm_to_int (m);
116 context ()->set_property ("rehearsalMark",
117 scm_from_int (mark_count));
120 if (scm_is_number (m))
121 m = scm_call_2 (proc, m, context ()->self_scm ());
123 /* FIXME: constant error message. */
124 warning (_ ("rehearsalMark must have integer value"));
127 if (Text_interface::is_markup (m))
128 text_->set_property ("text", m);
130 warning (_ ("mark label must be a markup object"));
134 #include "translator.icc"
136 ADD_ACKNOWLEDGER (Mark_engraver, bar_line);
137 ADD_TRANSLATOR (Mark_engraver,
138 /* doc */ "This engraver will create RehearsalMark objects. "
139 "It puts them on top of all staves (which is taken from "
140 "the property @code{stavesFound}). If moving this engraver "
141 "to a different context, "
142 "@ref{Staff_collecting_engraver} must move along, otherwise all marks"
143 "end up on the same Y-location",
144 /* create */ "RehearsalMark",
145 /* accept */ "mark-event",
146 /* read */ "rehearsalMark markFormatter stavesFound",