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