]> git.donarmstrong.com Git - lilypond.git/blob - lily/script.cc
patch::: 1.3.1.hwn1
[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");
40   assert (s != SCM_UNDEFINED);
41
42   SCM key = SCM_CAR (s);
43   if (key == ly_symbol ("feta"))
44     {
45       return lookup_l ()->afm_find ("scripts-" +
46                                     ly_scm2string (index_cell (gh_cdr (s), d)));
47     }
48   else if (key == ly_symbol ("accordion"))
49     {
50       return lookup_l ()->accordion (s, paper_l()->get_var("interline"));
51     }
52
53   else assert (false);
54
55   return Molecule ();
56 }
57
58
59 void
60 Script::do_pre_processing ()
61 {
62   /*
63     center my self on the note head.
64    */
65   Graphical_element * e = staff_side_l_->parent_l(X_AXIS);
66   translate_axis (e->extent (X_AXIS).center (), X_AXIS);
67 }
68
69 void
70 Script::do_post_processing ()
71 {
72   Direction d =  staff_side_l_->dir_;
73   Molecule m (get_molecule(d));
74
75   /*
76     UGH UGH UGH
77    */
78   if (staff_side_l_->get_elt_property ("no-staff-support") == SCM_UNDEFINED) 
79     translate_axis (- m.dim_[Y_AXIS][Direction (-d)], Y_AXIS);
80 }
81
82 void
83 Script::set_staff_side (Staff_side_item*g)
84 {
85   staff_side_l_ = g;
86   add_dependency (g);
87   set_parent (g, Y_AXIS);
88 }
89
90 Molecule*
91 Script::do_brew_molecule_p () const
92 {
93   return new Molecule (get_molecule (staff_side_l_->dir_));
94 }
95
96 void
97 Script::do_print () const
98 {
99
100 }
101