2 g-staff-side.cc -- implement Staff_side_element
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "staff-side.hh"
11 #include "staff-symbol.hh"
14 #include "dimensions.hh"
15 #include "dimension-cache.hh"
17 Staff_side_element::Staff_side_element ()
21 set_elt_property ("transparent", SCM_BOOL_T);
26 Staff_side_element::do_pre_processing ()
29 dir_ = get_default_direction ();
36 Staff_side_element::get_default_direction () const
43 Staff_side_element::set_victim (Score_element *e)
47 to_position_l_->set_parent (this, axis_);
51 Staff_side_element::add_support (Score_element*e)
54 support_l_arr_.push (e);
59 Staff_side_element::do_substitute_element_pointer (Score_element*o, Score_element*n)
61 Staff_symbol_referencer::do_substitute_element_pointer (o,n);
62 if (o == to_position_l_)
65 support_l_arr_.unordered_substitute (o,n);
69 Staff_side_element::position_self ()
72 to_position_l_->get_elt_property ("transparent") != SCM_UNDEFINED)
75 Axis other = Axis ((axis_ + 1) % NO_AXES);
76 if (parent_l (axis_)->empty_b (axis_)
77 &&parent_l (axis_)->empty_b (other)) // guh
79 warning (_("No support; erasing script"));
80 to_position_l_->set_empty (X_AXIS,Y_AXIS);
81 to_position_l_->set_elt_property ("transparent", SCM_BOOL_T);
82 set_empty (X_AXIS, Y_AXIS);
87 Graphical_element *common = 0;
88 if (support_l_arr_.size ())
90 common = common_refpoint (typecast_array (support_l_arr_, (Graphical_element*)0),
93 for (int i=0; i < support_l_arr_.size (); i++)
95 Score_element * e = support_l_arr_ [i];
96 Real coord = e->relative_coordinate (common, axis_);
98 dim.unite (coord + e->extent (axis_));
102 common = parent_l (axis_);
112 ? to_position_l_->extent (axis_)
115 Real off = relative_coordinate (common, axis_);
117 SCM pad = remove_elt_property ("padding");
118 if (pad != SCM_UNDEFINED)
120 off += gh_scm2double (pad) * dir_;
122 Real total_off = dim[dir_] + off;
125 "no-staff-support" is ugh bugfix to get staccato dots right.
127 if (to_position_l_ && to_position_l_->get_elt_property ("no-staff-support") == SCM_UNDEFINED)
128 total_off += - sym_dim[-dir_];
130 dim_cache_[axis_]->set_offset (total_off);
131 if (fabs (total_off) > 100 CM)
132 programming_error ("Huh ? Improbable staff side dim.");
136 Staff_side_element::do_post_processing ()
144 Staff_side_element::do_add_processing ()
146 if (get_elt_property ("no-staff-support") == SCM_UNDEFINED
147 && axis_ == Y_AXIS && staff_symbol_l ())
149 add_support (staff_symbol_l ());
154 Staff_side_element::do_height () const
158 return to_position_l_->extent (Y_AXIS);
163 Staff_side_element::do_print () const
167 DEBUG_OUT << "positioning " << to_position_l_->name();
169 DEBUG_OUT << "axis == " << axis_name_str (axis_)
170 << ", dir == " << to_str ((int)dir_ );
176 Staff_side_item::do_width () const
180 return to_position_l_->extent (X_AXIS);
185 Staff_side_item::do_print () const
187 Staff_side_element::do_print ();
191 Staff_side_spanner::do_print () const
193 Staff_side_element::do_print ();