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 "side-position-interface.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"
19 #include "staff-symbol-referencer.hh"
20 #include "side-position-interface.hh"
21 #include "staff-symbol.hh"
23 Bar_script_engraver::Bar_script_engraver ()
28 = ly_eval_str ("non-postbreak-visibility");
32 Bar_script_engraver::do_creation_processing ()
37 Some interesting item came across. Lets attach the text and the
38 positioner to the item.
43 Bar_script_engraver::attach_script_to_item (Item *i)
45 Axis other_axis = Axis((axis_ + 1)%2);
46 if (text_p_ && !text_p_->parent_l(other_axis))
48 text_p_->set_parent (i,other_axis);
49 text_p_->set_parent (i,axis_);
51 if (!text_p_->parent_l(other_axis))
52 text_p_->set_parent (i,other_axis);
54 Side_position_interface (text_p_).add_support (i);
57 How do we make sure that text_p_ has a dependency from
58 someone else? We can't use I for that, so we use some other element.
60 // text_p_->set_elt_property ("dangling", SCM_BOOL_T)
61 get_staff_info ().command_pcol_l ()->add_dependency (text_p_);
69 Bar_script_engraver::cast_to_interesting_item (Score_element *e)
74 should do type lookup: if (e ->is_type (hang_on_type))
76 i = dynamic_cast<Bar*> (e);
82 Bar_script_engraver::acknowledge_element (Score_element_info inf)
84 if (inf.origin_trans_l_arr (this).size () == 1)
86 Item *i=cast_to_interesting_item (inf.elem_l_);
90 /* Only put numbers on bars that are at our own level (don't put
91 numbers over the staffs of a GrandStaff, only over the GrandStaff
93 if (inf.origin_trans_l_arr (this).size () != 1)
96 attach_script_to_item (i);
101 Bar_script_engraver::do_pre_move_processing ()
105 Staff_symbol * st = staff_symbol_referencer (text_p_).staff_symbol_l();
108 side_position (text_p_).add_support (st);
110 typeset_element (text_p_);
117 Bar_script_engraver::create_items (Request *rq)
122 text_p_ = new Text_item;
123 text_p_->set_elt_property ("breakable", SCM_BOOL_T); // ugh
124 Side_position_interface staffside(text_p_);
125 staffside.set_axis (axis_);
127 SCM prop = get_property (type_ + "Direction", 0);
130 prop = gh_int2scm (UP);
132 text_p_->set_elt_property ("direction", prop);
134 SCM padding = get_property (type_ + "ScriptPadding", 0);
135 if (gh_number_p(padding))
137 text_p_->set_elt_property ("padding", padding);
142 ->set_elt_property ("padding",
143 gh_double2scm(paper_l ()->get_var ("interline")));
146 text_p_->set_elt_property ("visibility-lambda",
149 announce_element (Score_element_info (text_p_, rq));