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_sym, 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_sym) != SCM_BOOL_F)
76 Graphical_element *common = 0;
77 if (support_l_arr_.size ())
79 common = common_refpoint (typecast_array (support_l_arr_, (Graphical_element*)0),
82 for (int i=0; i < support_l_arr_.size (); i++)
84 Score_element * e = support_l_arr_ [i];
85 Real coord = e->relative_coordinate (common, axis_);
87 dim.unite (coord + e->extent (axis_));
91 common = parent_l (axis_);
101 ? to_position_l_->extent (axis_)
104 Real off = relative_coordinate (common, axis_);
108 SCM pad = remove_elt_property (padding_scm_sym);
109 if (pad != SCM_BOOL_F)
111 off += gh_scm2double (SCM_CDR(pad)) * dir_;
113 Real total_off = dim[dir_] + off;
116 no_staff_support_scm_sym is ugh bugfix to get staccato dots right.
118 if (to_position_l_ && to_position_l_->get_elt_property (no_staff_support_scm_sym) == SCM_BOOL_F)
119 total_off += - sym_dim[-dir_];
121 dim_cache_[axis_]->set_offset (total_off);
122 if (fabs (total_off) > 100 CM)
123 programming_error ("Huh ? Improbable staff side dim.");
127 Staff_side_element::do_post_processing ()
135 Staff_side_element::do_add_processing ()
137 if (get_elt_property (no_staff_support_scm_sym) == SCM_BOOL_F
138 && axis_ == Y_AXIS && staff_symbol_l ())
140 add_support (staff_symbol_l ());
145 Staff_side_element::do_height () const
149 return to_position_l_->extent (Y_AXIS);
154 Staff_side_element::do_print () const
158 DOUT << "positioning " << to_position_l_->name();
160 DOUT << "axis == " << axis_name_str (axis_)
161 << ", dir == " << to_str (dir_ );
167 Staff_side_item::do_width () const
171 return to_position_l_->extent (X_AXIS);
176 Staff_side_item::do_print () const
178 Staff_side_element::do_print ();
182 Staff_side_spanner::do_print () const
184 Staff_side_element::do_print ();