2 mark-engraver.cc -- implement Mark_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "command-request.hh"
12 #include "staff-symbol.hh"
13 #include "engraver-group-engraver.hh"
14 #include "engraver.hh"
15 #include "lily-guile.hh"
16 #include "paper-column.hh"
17 #include "paper-def.hh"
19 #include "side-position-interface.hh"
20 #include "staff-symbol-referencer.hh"
22 #include "group-interface.hh"
25 put stuff over or next to bars. Examples: bar numbers, marginal notes,
28 class Mark_engraver : public Engraver
31 VIRTUAL_COPY_CONS(Translator);
37 virtual void do_pre_move_processing ();
38 virtual void acknowledge_element (Score_element_info);
39 void create_items(Request*);
40 virtual bool do_try_music (Music *req_l);
41 virtual void do_process_music ();
42 virtual void do_post_move_processing ();
43 virtual void do_creation_processing ();
46 Mark_req * mark_req_l_;
50 ADD_THIS_TRANSLATOR (Mark_engraver);
53 Mark_engraver::Mark_engraver ()
60 Mark_engraver::do_creation_processing ()
62 daddy_trans_l_->set_property ("staffsFound", SCM_EOL); // ugh: sharing with barnumber grav.
67 Mark_engraver::acknowledge_element (Score_element_info inf)
69 Score_element * s = inf.elem_l_;
70 if (Staff_symbol::has_interface (s))
72 SCM sts = get_property ("staffsFound");
73 SCM thisstaff = inf.elem_l_->self_scm ();
74 if (scm_memq (thisstaff, sts) == SCM_BOOL_F)
75 daddy_trans_l_->set_property ("staffsFound", gh_cons (thisstaff, sts));
77 else if (text_p_ && Bar::has_interface (s))
80 Ugh. Figure out how to do this right at beginning of line, (without
81 creating class Bar_script : public Item).
83 text_p_->set_parent (s, X_AXIS);
88 Mark_engraver::do_pre_move_processing ()
92 text_p_->set_elt_property("side-support-elements" , get_property ("staffsFound"));
93 typeset_element (text_p_);
100 Mark_engraver::create_items (Request *rq)
105 SCM s = get_property ("basicMarkProperties");
106 text_p_ = new Item (s);
109 Side_position::set_axis (text_p_, Y_AXIS);
114 SCM prop = get_property ("markDirection");
117 prop = gh_int2scm (UP);
119 text_p_->set_elt_property ("direction", prop);
121 SCM padding = get_property ("markScriptPadding");
122 if (gh_number_p(padding))
124 text_p_->set_elt_property ("padding", padding);
129 ->set_elt_property ("padding",
130 gh_double2scm(paper_l ()->get_var ("staffspace")));
134 announce_element (text_p_, rq);
139 Mark_engraver::do_post_move_processing ()
146 Mark_engraver::do_try_music (Music* r_l)
148 if (Mark_req *mr = dynamic_cast <Mark_req *> (r_l))
150 if (mark_req_l_ && mr->equal_b (mark_req_l_))
161 Mark_engraver::do_process_music ()
165 create_items (mark_req_l_);
173 SCM m = mark_req_l_->get_mus_property ("label");
174 if (!gh_string_p (m))
175 m = get_property ("rehearsalMark");
180 int mark_count = gh_scm2int (m);
181 t = to_str (mark_count);
183 m = gh_int2scm (mark_count);
185 else if (gh_string_p (m))
187 t = ly_scm2string (m);
195 m = ly_str02scm (next.ch_C());
202 daddy_trans_l_->set_property ("rehearsalMark", m);
205 text_p_->set_elt_property ("text",
206 ly_str02scm ( t.ch_C()));
208 String style = "mark";
209 for (int i=0; i < t.length_i(); i++)
217 SCM st = ly_str02scm (style.ch_C());
218 text_p_->set_elt_property ("style", st);