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 "clef-item.hh"
12 #include "command-request.hh"
13 #include "dimension-cache.hh"
14 #include "engraver-group-engraver.hh"
15 #include "engraver.hh"
16 #include "lily-guile.hh"
17 #include "paper-column.hh"
18 #include "paper-def.hh"
19 #include "protected-scm.hh"
20 #include "side-position-interface.hh"
21 #include "staff-symbol-referencer.hh"
22 #include "staff-symbol.hh"
23 #include "text-item.hh"
24 #include "group-interface.hh"
27 put stuff over or next to bars. Examples: bar numbers, marginal notes,
30 class Mark_engraver : public Engraver
33 VIRTUAL_COPY_CONS(Translator);
37 Protected_scm visibility_lambda_;
38 Protected_scm staffs_;
41 virtual void do_creation_processing ();
42 virtual void do_pre_move_processing ();
43 virtual void acknowledge_element (Score_element_info);
44 void create_items(Request*);
45 virtual bool do_try_music (Music *req_l);
46 virtual void do_process_music ();
47 virtual void do_post_move_processing ();
49 Mark_req * mark_req_l_;
53 ADD_THIS_TRANSLATOR (Mark_engraver);
56 Mark_engraver::Mark_engraver ()
64 Mark_engraver::do_creation_processing ()
66 String t = "markVisibilityFunction";
67 SCM proc = get_property (t);
69 if (gh_procedure_p (proc))
70 visibility_lambda_ = proc;
76 Mark_engraver::acknowledge_element (Score_element_info inf)
78 Score_element * s = inf.elem_l_;
79 if (dynamic_cast<Staff_symbol*> (s))
81 staffs_ = gh_cons (inf.elem_l_->self_scm_, staffs_);
83 else if (text_p_ && dynamic_cast<Bar*> (s))
86 Ugh. Figure out how to do this right at beginning of line, (without
87 creating class Bar_script : public Text_item).
89 text_p_->set_parent (s, X_AXIS);
94 Mark_engraver::do_pre_move_processing ()
98 text_p_->set_elt_pointer("side-support-elements" , staffs_);
99 typeset_element (text_p_);
106 Mark_engraver::create_items (Request *rq)
111 text_p_ = new Text_item;
112 text_p_->set_elt_property ("breakable", SCM_BOOL_T); // ugh
113 Group_interface (text_p_, "interfaces").add_thing (ly_symbol2scm ("Mark"));
114 Side_position_interface staffside(text_p_);
115 staffside.set_axis (Y_AXIS);
117 SCM prop = get_property ("markDirection");
120 prop = gh_int2scm (UP);
122 text_p_->set_elt_property ("direction", prop);
124 SCM padding = get_property ("markScriptPadding");
125 if (gh_number_p(padding))
127 text_p_->set_elt_property ("padding", padding);
132 ->set_elt_property ("padding",
133 gh_double2scm(paper_l ()->get_var ("interline")));
136 if (gh_procedure_p (visibility_lambda_))
137 text_p_->set_elt_property ("visibility-lambda",
140 announce_element (Score_element_info (text_p_, rq));
145 Mark_engraver::do_post_move_processing ()
152 Mark_engraver::do_try_music (Music* r_l)
154 if (Mark_req *mr = dynamic_cast <Mark_req *> (r_l))
156 if (mark_req_l_ && mr->equal_b (mark_req_l_))
167 Mark_engraver::do_process_music ()
171 create_items (mark_req_l_);
178 SCM m = (mark_req_l_->mark_label_ == SCM_UNDEFINED)
179 ? get_property ("rehearsalMark")
180 : SCM(mark_req_l_->mark_label_);
184 int mark_count = gh_scm2int (m);
185 t = to_str (mark_count);
187 m = gh_int2scm (mark_count);
189 else if (gh_string_p (m))
191 t = ly_scm2string (m);
199 m = ly_str02scm (next.ch_C());
206 daddy_trans_l_->set_property ("rehearsalMark", m);
209 text_p_->set_elt_property ("text",
210 ly_str02scm ( t.ch_C()));
212 String style = "mark";
213 for (int i=0; i < t.length_i(); i++)
221 SCM st = ly_str02scm (style.ch_C());
222 text_p_->set_elt_property ("style", st);