2 align-elem.cc -- implement Align_elem
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "align-element.hh"
10 #include "interval.hh"
11 #include "direction.hh"
13 #include "hash-table-iter.hh"
14 #include "dimension-cache.hh"
17 Align_element::do_post_processing()
19 if (axis () == Y_AXIS)
20 do_side_processing ();
24 Align_element::do_pre_processing ()
26 if (axis () == X_AXIS)
27 do_side_processing ();
31 Align_element::do_side_processing ()
33 SCM d = get_elt_property ("stacking-dir");
34 Direction stacking_dir = gh_number_p(d) ? to_dir (d) : CENTER;
41 Link_array<Score_element> elems;
42 Link_array<Score_element> all_elts (elem_l_arr ());
43 for (int i=0; i < all_elts.size(); i++)
45 Interval y = all_elts[i]->extent(axis ()) + all_elts[i]->relative_coordinate (this, axis ());
48 Score_element *e =dynamic_cast<Score_element*>(all_elts[i]);
50 // todo: fucks up if item both in Halign & Valign.
51 SCM min_dims = e->remove_elt_property ("minimum-space");
52 if (gh_pair_p (min_dims) &&
53 gh_number_p (gh_car (min_dims))
54 && gh_number_p (gh_cdr (min_dims)))
56 y.unite (Interval (gh_scm2double (gh_car (min_dims)),
57 gh_scm2double (gh_cdr (min_dims))));
60 SCM extra_dims = e->remove_elt_property ("extra-space");
61 if (gh_pair_p (extra_dims) &&
62 gh_number_p (gh_car (extra_dims))
63 && gh_number_p (gh_cdr (extra_dims)))
65 y[LEFT] += gh_scm2double (gh_car (extra_dims));
66 y[RIGHT] += gh_scm2double (gh_cdr (extra_dims));
75 for (int i=0 ; i < elems.size(); i++)
77 Real dy = - stacking_dir * dims[i][-stacking_dir];
79 dy += stacking_dir * dims[i-1][stacking_dir];
83 dy = (dy >? threshold_interval_[SMALLER] )
84 <? threshold_interval_[BIGGER];
88 where_f += stacking_dir * dy;
89 elems[i]->translate_axis (where_f, axis ());
93 Align_element::Align_element()
95 threshold_interval_ = Interval (0, Interval::infinity ());
99 Align_element::get_count (Score_element*s)const
101 SCM e = get_elt_property ("elements");
103 while (gh_pair_p (e))
105 if (gh_car (e) == s->self_scm_)
114 Align_element::axis () const
120 Align_element::set_axis (Axis a)