]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
release: 0.1.24
[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     {
30       stem_l_ = n ? (Stem*)n->item() : 0;
31     }
32 }
33
34 void
35 Script::set_stem (Stem*st_l)
36 {
37   stem_l_ = st_l;
38   add_support (st_l);
39 }
40
41
42 Script::Script()
43 {
44   specs_l_ = 0;
45   inside_staff_b_ = false;
46   stem_l_ = 0;
47   dir_ =  CENTER;
48 }
49
50 void
51 Script::set_default_dir()
52 {
53   int s_i=specs_l_->rel_stem_dir();
54   if (s_i)
55     {
56       if (stem_l_)
57         dir_ = stem_l_->dir_ * s_i;
58       else
59         {
60           specs_l_->warning (_("Script needs stem direction"));
61           dir_ = DOWN;
62         }
63     }
64   else
65     {
66       dir_ =specs_l_->staff_dir();
67     }
68   assert (dir_);
69 }
70
71
72 Interval
73 Script::do_width() const
74 {
75   return specs_l_->get_atom (paper(), dir_).extent ().x ();
76 }
77
78 void
79 Script::do_pre_processing()
80 {
81   if  (breakable_b_ && break_status_i() != 1)
82     {
83       transparent_b_ = true;
84       set_empty (true);
85     }
86
87   if (!dir_)
88     set_default_dir();
89   inside_staff_b_ = specs_l_->inside_b();
90 }
91
92 Interval
93 Script::symbol_height() const
94 {
95   return specs_l_->get_atom (paper(), dir_).extent ().y ();
96 }
97
98 Molecule*
99 Script::brew_molecule_p() const
100 {
101   Real dy = paper()->internote_f ();
102   Real dx = paper()->note_width()/2;
103
104   Molecule*out = new Molecule (specs_l_->get_atom (paper(), dir_));
105   out->translate_axis (dy * pos_i_, Y_AXIS);
106   out->translate_axis (dx, X_AXIS);     // FIXME! ugh
107   return out;
108 }
109
110
111 IMPLEMENT_IS_TYPE_B2(Script,Item,Staff_side);
112
113 int
114 Script::compare (Script  *const&l1, Script *const&l2)
115 {
116   return l1->specs_l_->priority_i() - l2->specs_l_->priority_i ();
117 }