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 "g-staff-side.hh"
14 #include "g-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 Bar_script_engraver::do_acknowledge_element (Item *i)
42 Axis other_axis = Axis((axis_ + 1)%2);
43 if (staff_side_p_ && !staff_side_p_->dim_cache_[other_axis]->parent_l_)
45 staff_side_p_->dim_cache_[other_axis]->parent_l_
46 = i->dim_cache_[other_axis];
47 staff_side_p_->dim_cache_[axis_]->parent_l_
48 = i->dim_cache_[axis_];
50 staff_side_p_->add_support (i);
53 How do we make sure that staff_side_p_ has a dependency from
54 someone else? We can't use i for that, so we use some other element.
56 get_staff_info ().command_pcol_l ()->add_dependency (staff_side_p_);
64 Bar_script_engraver::cast_to_interesting_item (Score_element *e)
69 Clef_item * c = dynamic_cast<Clef_item*> (e);
73 if (c) // && c->default_b_)
80 i = dynamic_cast<Bar*> (e);
86 Bar_script_engraver::acknowledge_element (Score_element_info inf)
88 if (inf.origin_grav_l_arr_.size () == 1)
90 Item *i=cast_to_interesting_item (inf.elem_l_);
94 /* Only put numbers on bars that are at our own level (don't put
95 numbers over the staffs of a GrandStaff, only over the GrandStaff
97 if (inf.origin_grav_l_arr_.size () != 1)
100 do_acknowledge_element (i);
105 Bar_script_engraver::do_pre_move_processing ()
109 typeset_element (text_p_);
115 typeset_element (staff_side_p_);
122 Bar_script_engraver::create_items (Request *rq)
124 if (staff_side_p_ || text_p_)
127 staff_side_p_ = new G_staff_side_item;
128 staff_side_p_->axis_ = axis_;
129 staff_side_p_->set_elt_property (breakable_scm_sym, SCM_BOOL_T); // ugh
132 text_p_ = new G_text_item;
133 text_p_->set_elt_property (breakable_scm_sym, SCM_BOOL_T); // ugh
135 Scalar prop = get_property (type_ + "Direction", 0);
138 staff_side_p_->dir_ = (Direction) (int) prop;
142 staff_side_p_->dir_ = UP;
145 staff_side_p_->set_victim(text_p_);
147 Scalar padding = get_property (type_ + "ScriptPadding", 0);
148 if (padding.length_i() && padding.isnum_b ())
150 staff_side_p_->set_elt_property (padding_scm_sym, gh_double2scm(Real(padding)));
155 ->set_elt_property (padding_scm_sym,
156 gh_double2scm(paper_l ()->get_realvar (interline_scm_sym)));
159 staff_side_p_->set_elt_property (visibility_lambda_scm_sym,
161 text_p_->set_elt_property (visibility_lambda_scm_sym,
164 announce_element (Score_element_info (text_p_, rq));
165 announce_element (Score_element_info (staff_side_p_, rq));