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"
17 #include "paper-def.hh"
19 Bar_script_engraver::Bar_script_engraver ()
24 hang_on_clef_b_ = false;
26 = gh_eval_str ("non_postbreak_visibility");
30 Bar_script_engraver::do_creation_processing ()
32 Scalar prop = get_property (type_ + "HangOnClef", 0);
35 hang_on_clef_b_ = true;
40 Some interesting item came across. Lets attach the text and the
41 positioner to the item.
46 Bar_script_engraver::do_acknowledge_element (Item *i)
48 Axis other_axis = Axis((axis_ + 1)%2);
49 if (staff_side_p_ && !staff_side_p_->dim_cache_[other_axis]->parent_l_)
51 staff_side_p_->dim_cache_[other_axis]->parent_l_
52 = i->dim_cache_[other_axis];
53 staff_side_p_->dim_cache_[axis_]->parent_l_
54 = i->dim_cache_[axis_];
56 if (!text_p_->dim_cache_[other_axis]->parent_l_)
57 text_p_->dim_cache_[other_axis]->parent_l_ = i->dim_cache_[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 get_staff_info ().command_pcol_l ()->add_dependency (staff_side_p_);
72 Bar_script_engraver::cast_to_interesting_item (Score_element *e)
77 Clef_item * c = dynamic_cast<Clef_item*> (e);
81 if (c) // && c->default_b_)
88 i = dynamic_cast<Bar*> (e);
94 Bar_script_engraver::acknowledge_element (Score_element_info inf)
96 if (inf.origin_trans_l_arr_.size () == 1)
98 Item *i=cast_to_interesting_item (inf.elem_l_);
102 /* Only put numbers on bars that are at our own level (don't put
103 numbers over the staffs of a GrandStaff, only over the GrandStaff
105 if (inf.origin_trans_l_arr_.size () != 1)
108 do_acknowledge_element (i);
113 Bar_script_engraver::do_pre_move_processing ()
117 typeset_element (text_p_);
123 typeset_element (staff_side_p_);
130 Bar_script_engraver::create_items (Request *rq)
132 if (staff_side_p_ || text_p_)
135 staff_side_p_ = new Staff_side_item;
136 staff_side_p_->axis_ = axis_;
137 staff_side_p_->set_elt_property (breakable_scm_sym, SCM_BOOL_T); // ugh
140 text_p_ = new Text_item;
141 text_p_->set_elt_property (breakable_scm_sym, SCM_BOOL_T); // ugh
143 Scalar prop = get_property (type_ + "Direction", 0);
146 staff_side_p_->dir_ = (Direction) (int) prop;
150 staff_side_p_->dir_ = UP;
153 staff_side_p_->set_victim(text_p_);
155 Scalar padding = get_property (type_ + "ScriptPadding", 0);
156 if (padding.length_i() && padding.isnum_b ())
158 staff_side_p_->set_elt_property (padding_scm_sym, gh_double2scm(Real(padding)));
163 ->set_elt_property (padding_scm_sym,
164 gh_double2scm(paper_l ()->get_realvar (interline_scm_sym)));
167 staff_side_p_->set_elt_property (visibility_lambda_scm_sym,
169 text_p_->set_elt_property (visibility_lambda_scm_sym,
172 announce_element (Score_element_info (text_p_, rq));
173 announce_element (Score_element_info (staff_side_p_, rq));