2 bar-script-engraver.cc -- implement Bar_script_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "bar-script-engraver.hh"
12 #include "clef-item.hh"
13 #include "staff-side.hh"
14 #include "text-item.hh"
15 #include "lily-guile.hh"
16 #include "paper-column.hh"
17 #include "paper-def.hh"
18 #include "dimension-cache.hh"
21 Bar_script_engraver::Bar_script_engraver ()
26 hang_on_clef_b_ = false;
28 = ly_eval_str ("non-postbreak-visibility");
32 Bar_script_engraver::do_creation_processing ()
34 SCM prop = get_property (type_ + "HangOnClef", 0);
35 if (gh_boolean_p (prop) && gh_scm2bool (prop))
37 hang_on_clef_b_ = true;
42 Some interesting item came across. Lets attach the text and the
43 positioner to the item.
48 Bar_script_engraver::attach_script_to_item (Item *i)
50 Axis other_axis = Axis((axis_ + 1)%2);
51 if (staff_side_p_ && !staff_side_p_->parent_l(other_axis))
53 staff_side_p_->set_parent (i,other_axis);
54 staff_side_p_->set_parent (i,axis_);
56 if (!text_p_->parent_l(other_axis))
57 text_p_->set_parent (i,other_axis);
58 staff_side_p_->add_support (i);
61 How do we make sure that staff_side_p_ has a dependency from
62 someone else? We can't use I for that, so we use some other element.
64 // staff_side_p_->set_elt_property ("dangling", SCM_BOOL_T)
65 get_staff_info ().command_pcol_l ()->add_dependency (staff_side_p_);
73 Bar_script_engraver::cast_to_interesting_item (Score_element *e)
78 Clef_item * c = dynamic_cast<Clef_item*> (e);
82 if (c) // && c->default_b_)
89 i = dynamic_cast<Bar*> (e);
95 Bar_script_engraver::acknowledge_element (Score_element_info inf)
97 if (inf.origin_trans_l_arr_.size () == 1)
99 Item *i=cast_to_interesting_item (inf.elem_l_);
103 /* Only put numbers on bars that are at our own level (don't put
104 numbers over the staffs of a GrandStaff, only over the GrandStaff
106 if (inf.origin_trans_l_arr_.size () != 1)
109 attach_script_to_item (i);
114 Bar_script_engraver::do_pre_move_processing ()
118 typeset_element (text_p_);
124 typeset_element (staff_side_p_);
131 Bar_script_engraver::create_items (Request *rq)
133 if (staff_side_p_ || text_p_)
136 staff_side_p_ = new Staff_side_item;
137 staff_side_p_->axis_ = axis_;
138 staff_side_p_->set_elt_property ("breakable", SCM_BOOL_T); // ugh
141 text_p_ = new Text_item;
142 text_p_->set_elt_property ("breakable", SCM_BOOL_T); // ugh
144 SCM prop = get_property (type_ + "Direction", 0);
147 staff_side_p_->set_direction ( to_dir (prop));
151 staff_side_p_->set_direction ( UP);
154 staff_side_p_->set_victim(text_p_);
156 SCM padding = get_property (type_ + "ScriptPadding", 0);
157 if (gh_number_p(padding))
159 staff_side_p_->set_elt_property ("padding", padding);
164 ->set_elt_property ("padding",
165 gh_double2scm(paper_l ()->get_var ("interline")));
168 staff_side_p_->set_elt_property ("visibility-lambda",
170 text_p_->set_elt_property ("visibility-lambda",
173 announce_element (Score_element_info (text_p_, rq));
174 announce_element (Score_element_info (staff_side_p_, rq));