2 mark-engraver.cc -- implement Mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "bar-line.hh"
13 #include "engraver-group-engraver.hh"
14 #include "engraver.hh"
17 #include "text-item.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 virtual void stop_translation_timestep ();
31 virtual void acknowledge_grob (Grob_info);
32 void create_items (Music*);
33 virtual bool try_music (Music *ev);
34 virtual void process_music ();
44 Mark_engraver::Mark_engraver ()
51 Mark_engraver::acknowledge_grob (Grob_info inf)
54 if (text_ && Bar_line::has_interface (s))
57 TODO: make this configurable. RehearsalMark cannot be
58 break-aligned, since the width of the object should not be taken
59 into alignment considerations.
61 text_->set_parent (s, X_AXIS);
66 Mark_engraver::stop_translation_timestep ()
70 SCM lst = get_property ("stavesFound");
71 text_->set_property ("side-support-elements" , lst);
79 Mark_engraver::create_items (Music *ev)
84 text_ = make_item ("RehearsalMark", ev->self_scm ());
89 Mark_engraver::try_music (Music* r)
97 TODO: make the increment function in Scheme.
100 Mark_engraver::process_music ()
104 create_items (mark_ev_);
111 SCM m = mark_ev_->get_property ("label");
112 SCM proc = get_property ("markFormatter");
113 if (!Text_interface::markup_p (m) &&
114 ly_c_procedure_p (proc))
116 if (!scm_is_number (m))
117 m = get_property ("rehearsalMark");
119 if (scm_integer_p (m) == SCM_BOOL_T
120 && scm_exact_p (m) == SCM_BOOL_T)
122 int mark_count = scm_to_int (m);
124 context ()->set_property ("rehearsalMark",
125 scm_int2num (mark_count));
128 if (scm_is_number (m))
129 m = scm_call_2 (proc, m, context ()->self_scm ());
131 warning ("rehearsalMark does not have integer value.");
134 if (Text_interface::markup_p (m))
135 text_->set_property ("text", m);
137 warning ("Mark label should be markup object.");
141 ENTER_DESCRIPTION (Mark_engraver,
142 /* descr */ "This engraver will create RehearsalMark objects. "
143 "It puts them on top of all staves (which is taken from "
144 "the property @code{stavesFound}). If moving this engraver "
145 "to a different context, "
146 "@ref{Staff_collecting_engraver} must move along, otherwise all marks"
147 "end up on the same Y-location"
149 /* creats*/ "RehearsalMark",
150 /* accepts */ "mark-event",
151 /* acks */ "bar-line-interface",
152 /* reads */ "rehearsalMark markFormatter stavesFound",