]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-side.cc
release: 0.0.50
[lilypond.git] / lily / staff-side.cc
1 /*
2   staff-side.cc -- implement Staff_side
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "staff-side.hh"
10 #include "staff-sym.hh"
11
12 void
13 Staff_side::set_staffsym(Staff_symbol* s_l)
14 {
15     staff_sym_l_ = s_l;
16 }
17
18 Staff_side::Staff_side(Staff_elem * elem_l)
19 {
20     elem_l_ = elem_l;
21     dir_i_ =0;
22     staff_sym_l_ =0;
23     inside_staff_b_ =false;
24 }
25
26
27 Interval
28 Staff_side::support_height() const return r;
29 {
30     for (int i=0; i < support_l_arr_.size(); i++)
31         r.unite(support_l_arr_[i]->height());
32 }
33
34 void
35 Staff_side::add_support(Staff_elem*i)
36 {
37     support_l_arr_.push(i);
38     elem_l_->add_dependency(i);
39 }
40
41 int
42 Staff_side::get_position_i()const
43 {
44     if (!staff_sym_l_)
45         return 0;
46     
47     Real inter_f = staff_sym_l_->inter_note_f();
48     int staff_size_i = staff_sym_l_->steps_i();
49     Real y=0;
50     if (!inside_staff_b_) {
51         y  = (dir_i_ > 0) ? staff_size_i + 2: -2; 
52         y *=inter_f;
53         Interval v= support_height();
54
55         if (dir_i_ > 0) {
56             y = y >? (v.max() + 2*inter_f);
57         } else if (dir_i_ < 0) {
58             y = y <? (v.min() - 2*inter_f);
59         }
60     } else {
61         Interval v= support_height();
62         y = v[dir_i_]  + 2*dir_i_*inter_f;      // ugh
63     }
64     return int(rint(Real(y)/inter_f));
65 }