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 "dimension-cache.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"
18 #include "protected-scm.hh"
19 #include "side-position-interface.hh"
20 #include "staff-symbol-referencer.hh"
21 #include "staff-symbol.hh"
23 #include "group-interface.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 staffs_
;
39 virtual void do_creation_processing ();
40 virtual void do_pre_move_processing ();
41 virtual void acknowledge_element (Score_element_info
);
42 void create_items(Request
*);
43 virtual bool do_try_music (Music
*req_l
);
44 virtual void do_process_music ();
45 virtual void do_post_move_processing ();
47 Mark_req
* mark_req_l_
;
51 ADD_THIS_TRANSLATOR (Mark_engraver
);
54 Mark_engraver::Mark_engraver ()
62 Mark_engraver::do_creation_processing ()
68 Mark_engraver::acknowledge_element (Score_element_info inf
)
70 Score_element
* s
= inf
.elem_l_
;
71 if (dynamic_cast<Staff_symbol
*> (s
))
73 staffs_
= gh_cons (inf
.elem_l_
->self_scm_
, staffs_
);
75 else if (text_p_
&& dynamic_cast<Bar
*> (s
))
78 Ugh. Figure out how to do this right at beginning of line, (without
79 creating class Bar_script : public Item).
81 text_p_
->set_parent (s
, X_AXIS
);
86 Mark_engraver::do_pre_move_processing ()
90 text_p_
->set_elt_pointer("side-support-elements" , staffs_
);
91 typeset_element (text_p_
);
98 Mark_engraver::create_items (Request
*rq
)
103 SCM s
= get_property ("basicMarkProperties");
104 text_p_
= new Item (s
);
106 Group_interface (text_p_
, "interfaces").add_thing (ly_symbol2scm ("Mark"));
107 Side_position_interface
staffside(text_p_
);
108 staffside
.set_axis (Y_AXIS
);
113 SCM prop
= get_property ("markDirection");
116 prop
= gh_int2scm (UP
);
118 text_p_
->set_elt_property ("direction", prop
);
120 SCM padding
= get_property ("markScriptPadding");
121 if (gh_number_p(padding
))
123 text_p_
->set_elt_property ("padding", padding
);
128 ->set_elt_property ("padding",
129 gh_double2scm(paper_l ()->get_var ("interline")));
133 announce_element (Score_element_info (text_p_
, rq
));
138 Mark_engraver::do_post_move_processing ()
145 Mark_engraver::do_try_music (Music
* r_l
)
147 if (Mark_req
*mr
= dynamic_cast <Mark_req
*> (r_l
))
149 if (mark_req_l_
&& mr
->equal_b (mark_req_l_
))
160 Mark_engraver::do_process_music ()
164 create_items (mark_req_l_
);
171 SCM m
= (mark_req_l_
->mark_label_
== SCM_UNDEFINED
)
172 ? get_property ("rehearsalMark")
173 : SCM(mark_req_l_
->mark_label_
);
177 int mark_count
= gh_scm2int (m
);
178 t
= to_str (mark_count
);
180 m
= gh_int2scm (mark_count
);
182 else if (gh_string_p (m
))
184 t
= ly_scm2string (m
);
192 m
= ly_str02scm (next
.ch_C());
199 daddy_trans_l_
->set_property ("rehearsalMark", m
);
202 text_p_
->set_elt_property ("text",
203 ly_str02scm ( t
.ch_C()));
205 String style
= "mark";
206 for (int i
=0; i
< t
.length_i(); i
++)
214 SCM st
= ly_str02scm (style
.ch_C());
215 text_p_
->set_elt_property ("style", st
);