]> git.donarmstrong.com Git - lilypond.git/blob - lily/g-staff-side.cc
3988f0b9e99c52a73a6d4dab7936885363cc992b
[lilypond.git] / lily / g-staff-side.cc
1 /*   
2   g-staff-side.cc --  implement G_staff_side_item
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "g-staff-side.hh"
11
12 void
13 G_staff_side_item::do_pre_processing ()
14 {
15   if (!dir_)
16     set_default_direction ();
17 }
18
19 void
20 G_staff_side_item::set_default_direction ()
21 {
22   dir_ = DOWN;
23 }
24
25 G_staff_side_item::G_staff_side_item ()
26 {
27   dir_ = CENTER;
28   to_position_l_ = 0;
29   transparent_b_ = true;
30   padding_f_ = 0;
31 }
32
33 void
34 G_staff_side_item::set_victim (Score_element *e)
35 {
36   add_dependency (e);
37   to_position_l_ = e;
38   to_position_l_->dim_cache_[Y_AXIS].parent_l_ = &dim_cache_[Y_AXIS];
39 }
40
41 void
42 G_staff_side_item::add_support (Score_element*e)
43 {
44   add_dependency (e);
45   support_l_arr_.push (e);
46 }
47
48
49 void
50 G_staff_side_item::do_substitute_dependency (Score_element*o, Score_element*n)
51 {
52   if (o == to_position_l_)
53     to_position_l_ = n;
54   else
55     support_l_arr_.unordered_substitute (o,n);
56 }
57
58
59 void
60 G_staff_side_item::do_post_processing ()
61 {
62   if (!support_l_arr_.size ())
63     return ;
64   
65   Dimension_cache *common = common_group (typecast_array (support_l_arr_, (Graphical_element*)0),
66                                           Y_AXIS);
67
68   Interval dim;
69   for (int i=0; i < support_l_arr_.size (); i++)
70     {
71       Score_element * e = support_l_arr_ [i];
72       Real coord = e->relative_coordinate (common, Y_AXIS);
73       dim.unite (coord + e->extent (Y_AXIS));
74     }
75
76   Interval sym_dim = to_position_l_->extent (Y_AXIS);
77   Real off = dim_cache_[Y_AXIS].relative_coordinate (common) - padding_f_ * dir_;
78   
79   dim_cache_[Y_AXIS].set_offset (dim[dir_] - sym_dim[-dir_] - off);
80 }