]> git.donarmstrong.com Git - lilypond.git/blob - lily/volta-spanner.cc
release: 1.3.56
[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 (SCM s)
26   : Spanner (s)
27 {
28   set_elt_pointer ("bars", SCM_EOL);
29   Side_position_interface (this).set_axis (Y_AXIS);
30   directional_element (this).set (UP);
31 }
32
33
34 /*
35   this is too complicated. Yet another version of side-positioning,
36   badly implemented.
37
38   --
39
40   * Should look for system_start_delim to find left edge of staff.
41   
42   
43 */
44 MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Volta_spanner)
45 Molecule 
46 Volta_spanner::do_brew_molecule () const
47 {
48   Molecule  mol;
49
50   Link_array<Bar> bar_arr
51     = Pointer_group_interface__extract_elements (this, (Bar*)0, "bars");
52
53   if (!bar_arr.size ())
54     return mol;
55
56   bool no_vertical_start = false;
57   bool no_vertical_end = to_boolean (get_elt_property ("last-volta"));
58   Spanner *orig_span =  dynamic_cast<Spanner*> (original_l_);
59   if (orig_span && (orig_span->broken_into_l_arr_[0] != (Spanner*)this))
60     no_vertical_start = true;
61   if (orig_span && (orig_span->broken_into_l_arr_.top () != (Spanner*)this))
62     no_vertical_end = true;
63
64 #if 0
65   // FIXME
66   if (bar_arr.top ()->get_elt_property (type_str_.length_i () > 1)
67     no_vertical_end = false;
68 #endif
69
70   Real staff_space = paper_l ()->get_var ("interline");
71   Real half_space = staff_space / 2;
72
73   Real w = spanner_length ()
74   - get_broken_left_end_align ()
75     - half_space;
76   Real h = paper_l()->get_var ("volta_spanner_height");
77   Real t = paper_l ()->get_var ("volta_thick");
78
79   SCM at = (gh_list (ly_symbol2scm ("volta"),
80                      gh_double2scm (h),
81                      gh_double2scm (w),
82                      gh_double2scm (t),
83                      gh_int2scm (no_vertical_start),
84                      gh_int2scm (no_vertical_end),
85                      SCM_UNDEFINED));
86
87   Box b (Interval (0, w), Interval (0, h));
88   Molecule volta (b, at);
89   mol.add_molecule (volta);
90   
91   Molecule num (lookup_l ()->text ("volta",
92                                    ly_scm2string (get_elt_property("text")),
93                                    paper_l ()));
94
95   mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
96                    - staff_space);
97   return mol;
98 }
99   
100 void
101 Volta_spanner::do_add_processing ()
102 {
103
104   Link_array<Bar> bar_arr
105     = Pointer_group_interface__extract_elements (this, (Bar*)0, "bars");
106
107   if (bar_arr.size ())
108     {
109       set_bound (LEFT, bar_arr[0]);
110       set_bound (RIGHT, bar_arr.top ());  
111     }
112 }
113
114 void
115 Volta_spanner::after_line_breaking ()
116 {
117   Side_position_interface (this).add_staff_support ();
118 }
119   
120 void
121 Volta_spanner::add_bar  (Bar* b)
122 {
123   Pointer_group_interface gi(this, "bars");
124   gi.add_element (b);
125
126   Side_position_interface (this).add_support (b);
127   add_dependency (b);
128 }
129
130 void
131 Volta_spanner::add_column (Note_column* c)
132 {
133   Side_position_interface (this).add_support (c);
134   add_dependency (c);
135 }