]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-symbol-referencer.cc
release: 1.3.4
[lilypond.git] / lily / staff-symbol-referencer.cc
1 /*   
2   staff-symbol-referencer.cc -- implement Staff_symbol_referencer
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7  */
8
9 #include <math.h>
10
11 #include "staff-symbol-referencer.hh"
12 #include "staff-symbol.hh"
13 #include "paper-def.hh"
14 #include "dimension-cache.hh"
15
16 Staff_symbol_referencer::Staff_symbol_referencer ()
17 {
18   staff_sym_l_ =0;
19   position_i_ =0;
20 }
21
22 void
23 Staff_symbol_referencer::do_substitute_element_pointer (Score_element *o, Score_element*n)
24 {
25   if (staff_sym_l_ == o)
26     {
27       staff_sym_l_ = dynamic_cast<Staff_symbol*> (n);
28     }
29 }
30
31 int
32 Staff_symbol_referencer::lines_i () const
33 {
34   return (staff_sym_l_) ?  staff_sym_l_->no_lines_i_ : 5;
35 }
36
37 void
38 Staff_symbol_referencer::set_staff_symbol (Staff_symbol*s)
39 {
40   staff_sym_l_ =s;
41   add_dependency (s);
42 }
43
44 Staff_symbol*
45 Staff_symbol_referencer::staff_symbol_l () const
46 {
47   return staff_sym_l_;
48 }
49
50 Real
51 Staff_symbol_referencer::staff_line_leading_f () const
52 {
53   return (staff_sym_l_) ? staff_sym_l_->staff_line_leading_f_ : paper_l ()->get_var ("interline");
54 }
55
56 Real
57 Staff_symbol_referencer::position_f () const
58 {
59   Real p = position_i_;
60   if (staff_sym_l_ )
61     {
62       Graphical_element * c = common_refpoint (staff_sym_l_, Y_AXIS);
63       Real y = relative_coordinate (c, Y_AXIS) - staff_sym_l_->relative_coordinate (c, Y_AXIS);
64
65       p += 2.0 * y / staff_line_leading_f ();
66     }
67   return  p;
68 }
69
70
71
72 void
73 Staff_symbol_referencer::do_pre_processing ()
74 {
75   translate_axis (position_i_ * staff_line_leading_f () /2.0, Y_AXIS);
76   position_i_ =0;
77 }
78
79
80 void
81 Staff_symbol_referencer::set_position (int p)
82 {
83   /*
84     UGH. Use position_f() as well. 
85    */
86   position_i_ =   p;
87   
88 }