]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
release: 0.1.8
[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  (breakable_b_ && break_status_i() != 1) {
77         transparent_b_ = empty_b_ = true;
78     }
79     
80     if (!dir_i_)
81         set_default_dir();
82     inside_staff_b_ = specs_l_->inside_b();
83 }
84
85 Interval
86 Script::symbol_height()const
87 {
88     return specs_l_->get_atom (paper(), dir_i_).extent ().y ();
89 }
90
91 Molecule*
92 Script::brew_molecule_p() const
93 {
94     Real dy = paper()->internote_f ();
95     
96     Molecule*out = new Molecule (specs_l_->get_atom (paper(), dir_i_));
97     out->translate (dy * pos_i_, Y_AXIS);
98     return out;
99 }
100
101
102 IMPLEMENT_IS_TYPE_B2(Script,Item,Staff_side);
103
104 int 
105 Script::compare (Script  *const&l1, Script *const&l2) 
106 {
107     return l1->specs_l_->priority_i() - l2->specs_l_->priority_i ();
108 }
109