]> git.donarmstrong.com Git - lilypond.git/blob - lily/volta-spanner.cc
patch::: 1.3.35.jcn1
[lilypond.git] / lily / volta-spanner.cc
1 /*
2   volta-spanner.cc -- implement Volta_spanner
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9
10 #include "box.hh"
11 #include "debug.hh"
12 #include "lookup.hh"
13 #include "molecule.hh"
14 #include "note-column.hh"
15 #include "paper-column.hh"
16 #include "bar.hh"
17 #include "paper-def.hh"
18 #include "volta-spanner.hh"
19 #include "stem.hh"
20 #include "dimension-cache.hh"
21 #include "group-interface.hh"
22 #include "side-position-interface.hh"
23 #include "directional-element-interface.hh"
24
25 Volta_spanner::Volta_spanner ()
26 {
27   //dim_cache_ [Y_AXIS]->set_callback (dim_callback);
28   set_elt_property ("bars", SCM_EOL);
29   side_position (this).set_axis (Y_AXIS);
30   directional_element (this).set (UP);
31 }
32
33 Molecule 
34 Volta_spanner::do_brew_molecule () const
35 {
36   Molecule  mol;
37
38   Link_array<Bar> bar_arr
39     = Group_interface__extract_elements (this, (Bar*)0, "bars");
40
41   if (!bar_arr.size ())
42     return mol;
43
44   bool no_vertical_start = false;
45   bool no_vertical_end = to_boolean (get_elt_property ("last-volta"));
46   Spanner *orig_span =  dynamic_cast<Spanner*> (original_l_);
47   if (orig_span && (orig_span->broken_into_l_arr_[0] != (Spanner*)this))
48     no_vertical_start = true;
49   if (orig_span && (orig_span->broken_into_l_arr_.top () != (Spanner*)this))
50     no_vertical_end = true;
51
52 #if 0
53   // FIXME
54   if (bar_arr.top ()->get_elt_property (type_str_.length_i () > 1)
55     no_vertical_end = false;
56 #endif
57
58   Real staff_space = paper_l ()->get_var ("interline");
59   Real half_space = staff_space / 2;
60
61   Real w = spanner_length () - get_broken_left_end_align () - half_space;
62   Real h = paper_l()->get_var ("volta_spanner_height");
63   Real t = paper_l ()->get_var ("volta_thick");
64
65   SCM at = (gh_list (ly_symbol2scm ("volta"),
66                      gh_double2scm (h),
67                      gh_double2scm (w),
68                      gh_double2scm (t),
69                      gh_int2scm (no_vertical_start),
70                      gh_int2scm (no_vertical_end),
71                      SCM_UNDEFINED));
72   //Box b (Interval (0, w), Interval (- h/2, h/2));
73   Box b (Interval (0, w), Interval (0, h));
74   Molecule volta (b, at);
75   mol.add_molecule (volta);
76   
77   Molecule num (lookup_l ()->text ("volta",
78                                    ly_scm2string (get_elt_property("text")),
79                                    paper_l ()));
80
81   mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
82                    - staff_space);
83   return mol;
84 }
85   
86 void
87 Volta_spanner::do_add_processing ()
88 {
89
90   Link_array<Bar> bar_arr
91     = Group_interface__extract_elements (this, (Bar*)0, "bars");
92
93   if (bar_arr.size ())
94     {
95       set_bound (LEFT, bar_arr[0]);
96       set_bound (RIGHT, bar_arr.top ());  
97     }
98 }
99
100 void
101 Volta_spanner::after_line_breaking ()
102 {
103   side_position (this).add_staff_support ();
104 }
105   
106 void
107 Volta_spanner::add_bar  (Bar* b)
108 {
109   Group_interface gi(this, "bars");
110   gi.add_element (b);
111
112   side_position (this).add_support (b);
113   add_dependency (b);
114 }
115
116 void
117 Volta_spanner::add_column (Note_column* c)
118 {
119   side_position (this).add_support (c);
120   add_dependency (c);
121 }