]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
release: 0.0.74pre
[lilypond.git] / lily / script.cc
1 /*
2   script.cc -- implement Script
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "script-def.hh"
9 #include "musical-request.hh"
10 #include "paper-def.hh"
11 #include "script.hh"
12 #include "stem.hh"
13 #include "molecule.hh"
14 #include "lookup.hh"
15
16 void
17 Script::do_print() const
18 {
19 #ifndef NPRINT
20     specs_l_->print();
21 #endif
22 }
23
24 void
25 Script::do_substitute_dependency(Score_elem*o,Score_elem*n)
26 {
27     Staff_side::do_substitute_dependency(o,n);
28     if (o == stem_l_) {
29         stem_l_ = n ? (Stem*)n->item() : 0;
30     }
31 }
32
33 void
34 Script::set_stem(Stem*st_l)
35 {
36     stem_l_ = st_l;
37     add_support(st_l);
38 }
39
40
41 Script::Script()
42 {    
43     specs_l_ = 0;
44     inside_staff_b_ = false;
45     stem_l_ = 0;
46     dir_i_ =  0;
47 }
48
49 void
50 Script::set_default_dir()
51 {
52     int s_i=specs_l_->rel_stem_dir_i();
53     if (s_i) { 
54         if(stem_l_)
55             dir_i_ = stem_l_->dir_i_ * s_i;
56         else{ 
57             specs_l_->warning("Script needs stem direction");
58             dir_i_ = -1;
59         }
60     } else {
61         dir_i_ =specs_l_->staff_dir_i();
62     }
63     assert(dir_i_);
64 }
65
66
67 Interval
68 Script::do_width() const
69 {
70     return specs_l_->get_atom(paper(), dir_i_).extent().x;
71 }
72
73 void
74 Script::do_pre_processing()
75 {
76     if (!dir_i_)
77         set_default_dir();
78     inside_staff_b_ = specs_l_->inside_b();
79 }
80
81 Interval
82 Script::symbol_height()const
83 {
84     return specs_l_->get_atom(paper(), dir_i_).extent().y;
85 }
86
87 Molecule*
88 Script::brew_molecule_p() const
89 {
90     Real dy = paper()->internote_f();
91     
92     Molecule*out = new Molecule(specs_l_->get_atom(paper(), dir_i_));
93     out->translate_y(dy * pos_i_);
94     return out;
95 }
96
97 IMPLEMENT_STATIC_NAME(Script);
98 IMPLEMENT_IS_TYPE_B2(Script,Item,Staff_side);
99
100 int 
101 Script::compare(Script  *const&l1, Script *const&l2) 
102 {
103     return l1->specs_l_->priority_i() - l2->specs_l_->priority_i();
104 }
105