]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
release: 1.2.4
[lilypond.git] / lily / script.cc
1 /*   
2      script.cc --  implement Script
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 /*
11
12   TODO: Quantisation support (staccato dots between stafflines)
13
14 */
15 #include "debug.hh"
16 #include "script.hh"
17 #include "lookup.hh"
18 #include "staff-side.hh"
19 #include "paper-def.hh"
20 #include "dimension-cache.hh"
21
22 Script::Script ()
23 {
24   staff_side_l_ =0;
25 }
26
27 void
28 Script::do_substitute_element_pointer (Score_element*o, Score_element*n)
29 {
30   if (o == staff_side_l_)
31     staff_side_l_ = dynamic_cast<Staff_side_item*>(n);
32 }
33
34
35
36 Molecule
37 Script::get_molecule(Direction d) const
38 {
39   SCM s = get_elt_property (molecule_scm_sym);
40   assert  (s != SCM_BOOL_F);
41
42   s = SCM_CDR(s);
43   SCM key = SCM_CAR (s);
44   if (key == ly_symbol ("feta"))
45     {
46       return lookup_l ()->afm_find ("scripts-" +
47                                     ly_scm2string (index_cell (SCM_CDR (s), d)));
48     }
49   else if (key == ly_symbol ("accordion"))
50     {
51       return lookup_l ()->accordion (SCM_CDR(s), paper_l()->get_realvar(interline_scm_sym));
52     }
53
54   else assert (false);
55
56   return Molecule ();
57 }
58
59
60 void
61 Script::do_pre_processing ()
62 {
63   /*
64     center my self on the note head.
65    */
66   Graphical_element * e = staff_side_l_->parent_l(X_AXIS);
67   translate_axis (e->extent (X_AXIS).center (), X_AXIS);
68 }
69
70 void
71 Script::do_post_processing ()
72 {
73   Direction d =  staff_side_l_->dir_;
74   Molecule m (get_molecule(d));
75
76   /*
77     UGH UGH UGH
78    */
79   if (staff_side_l_->get_elt_property (no_staff_support_scm_sym) == SCM_BOOL_F) 
80     translate_axis (- m.dim_[Y_AXIS][Direction (-d)], Y_AXIS);
81 }
82
83 void
84 Script::set_staff_side (Staff_side_item*g)
85 {
86   staff_side_l_ = g;
87   add_dependency (g);
88   set_parent (g, Y_AXIS);
89 }
90
91 Molecule*
92 Script::do_brew_molecule_p () const
93 {
94   return new Molecule (get_molecule (staff_side_l_->dir_));
95 }
96
97 void
98 Script::do_print () const
99 {
100
101 }