]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-side.cc
release: 0.1.53
[lilypond.git] / lily / staff-side.cc
1 /*
2   staff-side.cc -- implement Staff_side
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "interval.hh"
10 #include "paper-def.hh"
11 #include "dimen.hh"
12 #include "staff-side.hh"
13 #include "staff-sym.hh"
14 #include "debug.hh"
15
16
17 Staff_side::Staff_side()
18 {
19   y_=0;
20   sym_int_ = Interval (0,0);
21   dir_ = CENTER;
22   inside_staff_b_ = false;
23 }
24
25
26 Interval
27 Staff_side::support_height() const
28 {
29   Interval y_int;
30   for (int i=0; i < support_l_arr_.size(); i++) 
31     {
32       Axis_group_element *common = 
33         common_group (support_l_arr_[i], Y_AXIS);
34         
35       Real y = support_l_arr_[i]->relative_coordinate (common, Y_AXIS)  
36         -relative_coordinate (common,Y_AXIS);
37
38       y_int.unite (y + support_l_arr_[i]->height());
39     }
40
41
42   if (y_int.empty_b())
43     {
44       y_int = Interval (0,0);
45     }
46   return y_int;
47 }
48
49 void
50 Staff_side::add_support (Score_elem*i)
51 {
52   support_l_arr_.push (i);
53   add_dependency (i);
54 }
55
56 Real
57 Staff_side::get_position_f () const
58 {
59   if (!dir_)
60     {
61       warning (_("Staff_side::get_position_f(): "
62                  "somebody forgot to set my vertical direction, returning -20"));
63       return -20;
64     }
65
66
67   Real y=0;
68   Real inter_f = paper()-> internote_f ();
69
70   Interval v= support_height();
71   if (inside_staff_b_)
72     // ugh: i don't know why, but this is needed for inside-staff
73     y = v[dir_] + 2 * dir_ * inter_f;   // ugh
74   else
75     // get accents just above staff; (fermata etc.: ugh)
76     y = v[dir_] - 3 * dir_ * inter_f;
77
78   return y;
79 }
80
81 Interval
82 Staff_side::symbol_height() const
83 {
84   return Interval (0,0);
85 }
86
87 void
88 Staff_side::do_post_processing()
89 {
90   sym_int_ = symbol_height();
91   y_ = get_position_f();
92   if (dir_)
93     y_ += - sym_int_[-dir_];
94 }
95
96 void
97 Staff_side::do_substitute_dependency (Score_elem*o, Score_elem*n)
98 {
99   support_l_arr_.unordered_substitute (o,n);
100 }
101
102
103 IMPLEMENT_IS_TYPE_B1(Staff_side, Score_elem);