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 ()
20 set_elt_property ("transparent", SCM_BOOL_T);
25 Staff_side_element::do_pre_processing ()
27 if (!get_direction ())
28 set_direction (get_default_direction ());
35 Staff_side_element::get_default_direction () const
42 Staff_side_element::set_victim (Score_element *e)
46 to_position_l_->set_parent (this, axis_);
50 Staff_side_element::add_support (Score_element*e)
53 support_l_arr_.push (e);
58 Staff_side_element::do_substitute_element_pointer (Score_element*o, Score_element*n)
60 Staff_symbol_referencer::do_substitute_element_pointer (o,n);
61 if (o == to_position_l_)
64 support_l_arr_.unordered_substitute (o,n);
68 Staff_side_element::position_self ()
71 to_position_l_->get_elt_property ("transparent") != SCM_UNDEFINED)
74 Axis other = Axis ((axis_ + 1) % NO_AXES);
75 if (parent_l (axis_)->empty_b (axis_)
76 &&parent_l (axis_)->empty_b (other)) // guh
78 warning (_("No support; erasing script"));
79 to_position_l_->set_empty (X_AXIS,Y_AXIS);
80 to_position_l_->set_elt_property ("transparent", SCM_BOOL_T);
81 set_empty (X_AXIS, Y_AXIS);
86 Graphical_element *common = 0;
87 if (support_l_arr_.size ())
89 common = common_refpoint (typecast_array (support_l_arr_, (Graphical_element*)0),
92 for (int i=0; i < support_l_arr_.size (); i++)
94 Score_element * e = support_l_arr_ [i];
95 Real coord = e->relative_coordinate (common, axis_);
97 dim.unite (coord + e->extent (axis_));
101 common = parent_l (axis_);
111 ? to_position_l_->extent (axis_)
114 Real off = relative_coordinate (common, axis_);
116 SCM pad = remove_elt_property ("padding");
117 if (pad != SCM_UNDEFINED)
119 off += gh_scm2double (pad) * get_direction ();
121 Real total_off = dim[get_direction ()] + off;
124 "no-staff-support" is ugh bugfix to get staccato dots right.
126 if (to_position_l_ && to_position_l_->get_elt_property ("no-staff-support") == SCM_UNDEFINED)
127 total_off += - sym_dim[-get_direction ()];
129 dim_cache_[axis_]->set_offset (total_off);
130 if (fabs (total_off) > 100 CM)
131 programming_error ("Huh ? Improbable staff side dim.");
135 Staff_side_element::do_post_processing ()
143 Staff_side_element::do_add_processing ()
145 if (get_elt_property ("no-staff-support") == SCM_UNDEFINED
146 && axis_ == Y_AXIS && staff_symbol_l ())
148 add_support (staff_symbol_l ());
153 Staff_side_element::do_height () const
157 return to_position_l_->extent (Y_AXIS);
162 Staff_side_element::do_print () const
166 DEBUG_OUT << "positioning " << to_position_l_->name();
168 DEBUG_OUT << "axis == " << axis_name_str (axis_)
169 << ", dir == " << to_str ((int)get_direction () );
175 Staff_side_item::do_width () const
179 return to_position_l_->extent (X_AXIS);
184 Staff_side_item::do_print () const
186 Staff_side_element::do_print ();
190 Staff_side_spanner::do_print () const
192 Staff_side_element::do_print ();