]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-side.cc
release: 0.0.51
[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 #include "debug.hh"
12
13 void
14 Staff_side::set_staffsym(Staff_symbol* s_l)
15 {
16     staff_sym_l_ = s_l;
17 }
18
19 Staff_side::Staff_side(Staff_elem * elem_l)
20 {
21     elem_l_ = elem_l;
22     dir_i_ =0;
23     staff_sym_l_ =0;
24     inside_staff_b_ =false;
25 }
26
27
28 Interval
29 Staff_side::support_height() const return r;
30 {
31     for (int i=0; i < support_l_arr_.size(); i++)
32         r.unite(support_l_arr_[i]->height());
33 }
34
35 void
36 Staff_side::add_support(Staff_elem*i)
37 {
38     support_l_arr_.push(i);
39     elem_l_->add_dependency(i);
40 }
41
42 int
43 Staff_side::get_position_i()const
44 {
45     if (!staff_sym_l_)
46         return 0;
47     if (!dir_i_) {
48         warning("Staff_side::get_position_i(): returning -20");
49         return -20;
50     }
51     
52     Real inter_f = staff_sym_l_->inter_note_f();
53     int staff_size_i = staff_sym_l_->steps_i();
54     Real y=0;
55     if (!inside_staff_b_) {
56         y  = (dir_i_ > 0) ? staff_size_i + 2: -2; 
57         y *=inter_f;
58         Interval v= support_height();
59
60         if (dir_i_ > 0) {
61             y = y >? (v.max() + 2*inter_f);
62         } else if (dir_i_ < 0) {
63             y = y <? (v.min() - 2*inter_f);
64         }
65     } else {
66         Interval v= support_height();
67         y = v[dir_i_]  + 2*dir_i_*inter_f;      // ugh
68     }
69     return int(rint(Real(y)/inter_f)); // should ret a float?
70 }
71
72 int
73 Staff_side::get_position_i(Interval sym_dim) const
74
75     if (!staff_sym_l_)
76         return 0;
77    if (!dir_i_) {
78         warning("Staff_side::get_position_i(): returning -20");
79         return -20;
80     }
81    
82     Real inter_f = staff_sym_l_->inter_note_f();
83   
84     int i= get_position_i();
85     return i+ int(rint(- sym_dim[dir_i_] / inter_f));
86 }