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"
26 put stuff over or next to bars. Examples: bar numbers, marginal notes,
29 class Mark_engraver : public Engraver
32 VIRTUAL_COPY_CONS(Translator);
36 Protected_scm visibility_lambda_;
37 Protected_scm staffs_;
40 virtual void do_creation_processing ();
41 virtual void do_pre_move_processing ();
42 virtual void acknowledge_element (Score_element_info);
43 void create_items(Request*);
44 virtual bool do_try_music (Music *req_l);
45 virtual void do_process_music ();
46 virtual void do_post_move_processing ();
48 Mark_req * mark_req_l_;
52 ADD_THIS_TRANSLATOR (Mark_engraver);
55 Mark_engraver::Mark_engraver ()
63 Mark_engraver::do_creation_processing ()
65 String t = "markVisibilityFunction";
66 SCM proc = get_property (t);
68 if (gh_procedure_p (proc))
69 visibility_lambda_ = proc;
75 Mark_engraver::acknowledge_element (Score_element_info inf)
77 Score_element * s = inf.elem_l_;
78 if (dynamic_cast<Staff_symbol*> (s))
80 staffs_ = gh_cons (inf.elem_l_->self_scm_, staffs_);
82 else if (text_p_ && dynamic_cast<Bar*> (s))
85 Ugh. Figure out how to do this right at beginning of line, (without
86 creating class Bar_script : public Text_item).
88 text_p_->set_parent (s, X_AXIS);
93 Mark_engraver::do_pre_move_processing ()
97 text_p_->set_elt_property ("side-support" , staffs_);
98 typeset_element (text_p_);
105 Mark_engraver::create_items (Request *rq)
110 text_p_ = new Text_item;
111 text_p_->set_elt_property ("breakable", SCM_BOOL_T); // ugh
112 Side_position_interface staffside(text_p_);
113 staffside.set_axis (Y_AXIS);
115 SCM prop = get_property ("markDirection");
118 prop = gh_int2scm (UP);
120 text_p_->set_elt_property ("direction", prop);
122 SCM padding = get_property ("markScriptPadding");
123 if (gh_number_p(padding))
125 text_p_->set_elt_property ("padding", padding);
130 ->set_elt_property ("padding",
131 gh_double2scm(paper_l ()->get_var ("interline")));
134 if (gh_procedure_p (visibility_lambda_))
135 text_p_->set_elt_property ("visibility-lambda",
138 announce_element (Score_element_info (text_p_, rq));
143 Mark_engraver::do_post_move_processing ()
150 Mark_engraver::do_try_music (Music* r_l)
152 if (Mark_req *mr = dynamic_cast <Mark_req *> (r_l))
154 if (mark_req_l_ && mr->equal_b (mark_req_l_))
165 Mark_engraver::do_process_music ()
169 create_items (mark_req_l_);
176 SCM m = (mark_req_l_->mark_label_ == SCM_UNDEFINED)
177 ? get_property ("rehearsalMark")
178 : SCM(mark_req_l_->mark_label_);
182 int mark_count = gh_scm2int (m);
183 t = to_str (mark_count);
185 m = gh_int2scm (mark_count);
187 else if (gh_string_p (m))
189 t = ly_scm2string (m);
197 m = ly_str02scm (next.ch_C());
204 daddy_trans_l_->set_property ("rehearsalMark", m);
207 text_p_->set_elt_property ("text",
208 ly_str02scm ( t.ch_C()));
209 SCM st = ly_str02scm ((t.index_any_i ("0123456789") >= 0 )
211 text_p_->set_elt_property ("style", st);