]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-side.cc
partial: 1.0.1.jcn
[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--1998 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 }
23
24
25 Interval
26 Staff_side::support_height() const
27 {
28   Interval y_int;
29   for (int i=0; i < support_l_arr_.size(); i++) 
30     {
31       Axis_group_element *common = 
32         common_group (support_l_arr_[i], Y_AXIS);
33         
34       Real y = support_l_arr_[i]->relative_coordinate (common, Y_AXIS)  
35         -relative_coordinate (common,Y_AXIS);
36
37       y_int.unite (y + support_l_arr_[i]->height());
38     }
39
40
41   if (y_int.empty_b())
42     {
43       y_int = Interval (0,0);
44     }
45   return y_int;
46 }
47
48 void
49 Staff_side::add_support (Score_elem*i)
50 {
51   support_l_arr_.push (i);
52   add_dependency (i);
53 }
54
55 Real
56 Staff_side::get_position_f () const
57 {
58   if (!dir_)
59     {
60       warning (_("Staff_side::get_position_f(): "
61                  "somebody forgot to set my vertical direction, returning -20"));
62       return -20;
63     }
64
65
66   Real y = 0;
67   Real inter_f = paper()-> internote_f ();
68
69   Interval v = support_height();
70
71   // ugh, dim[y] = PT over here
72   y = v[dir_] + 1 * dir_ * inter_f;
73
74   int y_i = (int)rint (y / inter_f);
75   // ugh: 5 -> staff_lines
76   if (abs (y_i) < 5)
77     {
78       if (!(abs (y_i) % 2))
79         y += (Real)dir_ * inter_f;
80     }
81 //  else
82 //    y = v[dir_] + 1 * dir_ * inter_f;
83
84   return y;
85 }
86
87 Interval
88 Staff_side::symbol_height() const
89 {
90   return Interval (0,0);
91 }
92
93 void
94 Staff_side::do_post_processing()
95 {
96   sym_int_ = symbol_height();
97   y_ = get_position_f();
98   if (dir_)
99     y_ += - sym_int_[-dir_];
100 }
101
102 void
103 Staff_side::do_substitute_dependency (Score_elem*o, Score_elem*n)
104 {
105   support_l_arr_.unordered_substitute (o,n);
106 }
107
108
109 IMPLEMENT_IS_TYPE_B1(Staff_side, Score_elem);