2 volta-spanner.cc -- implement Volta_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "molecule.hh"
14 #include "note-column.hh"
15 #include "paper-column.hh"
17 #include "paper-def.hh"
18 #include "volta-spanner.hh"
20 #include "dimension-cache.hh"
21 #include "group-interface.hh"
25 Volta_spanner::Volta_spanner ()
27 dim_cache_ [Y_AXIS]->set_callback (dim_callback);
28 set_elt_property ("bars", SCM_EOL);
29 set_elt_property ("note-columns", SCM_EOL);
33 FIXME: too complicated.
36 Volta_spanner::do_brew_molecule () const
40 Link_array<Bar> bar_arr
41 = Group_interface__extract_elements (this, (Bar*)0, "bars");
46 Link_array<Score_element> note_column_arr
47 = Group_interface__extract_elements (this, (Score_element*)0, "note-columns");
49 bool no_vertical_start = false;
50 bool no_vertical_end = to_boolean (get_elt_property ("last-volta"));
51 Spanner *orig_span = dynamic_cast<Spanner*> (original_l_);
52 if (orig_span && (orig_span->broken_into_l_arr_[0] != (Spanner*)this))
53 no_vertical_start = true;
54 if (orig_span && (orig_span->broken_into_l_arr_.top () != (Spanner*)this))
55 no_vertical_end = true;
59 if (bar_arr.top ()->get_elt_property (type_str_.length_i () > 1)
60 no_vertical_end = false;
63 Real staff_space = paper_l ()->get_var ("interline");
64 Real half_staff_space = staff_space/2;
65 Real t = paper_l ()->get_var ("volta_thick");
67 Real dx = half_staff_space;
68 Real w = spanner_length() - dx - get_broken_left_end_align ();
69 Real h = paper_l()->get_var ("volta_spanner_height");
71 SCM at = (gh_list (ly_symbol2scm ("volta"),
75 gh_int2scm (no_vertical_start),
76 gh_int2scm (no_vertical_end),
78 Box b (Interval (- h/2, h/2), Interval (0, w));
81 Molecule num (lookup_l ()->text ("volta",
82 ly_scm2string (get_elt_property("text")),
84 Real dy = bar_arr.top ()->extent (Y_AXIS) [UP] >?
85 bar_arr[0]->extent (Y_AXIS) [UP];
91 FIXME (see axis-group-elt, side-pos interface.)
93 for (int i = 0; i < note_column_arr.size (); i++)
94 dy = dy >? note_column_arr[i]->extent (Y_AXIS)[BIGGER];
97 Molecule two (lookup_l ()->text ("volta", "2", paper_l ()));
98 Real gap = two.dim_.x ().length () / 2;
99 Offset off (num.dim_.x ().length () + gap,
100 h / half_staff_space - gap);
102 mol.add_molecule (volta);
103 mol.add_molecule (num);
104 mol.translate (Offset (0, dy));
109 Volta_spanner::do_add_processing ()
112 Link_array<Bar> bar_arr
113 = Group_interface__extract_elements (this, (Bar*)0, "bars");
117 set_bound (LEFT, bar_arr[0]);
118 set_bound (RIGHT, bar_arr.top ());
123 Originally the following comment existed here
124 "in most cases, it's a lot better not no have height...",
125 but problems existed with collision between volta spanner
126 and above staff or lyrics for multi-staff music, so the proper
127 height is now being returned. Additional space should still
128 be added elsewhere so lyrics from above staff do not sit on
129 volta spanner. (Roy R. Rankin)
132 Volta_spanner::dim_callback (Dimension_cache const *c)
134 Volta_spanner * v = dynamic_cast<Volta_spanner*> (c->element_l ());
135 Real h = v->paper_l()->get_var ("volta_spanner_height") * 2.;
136 return Interval (0., h);
140 Volta_spanner::do_post_processing ()
142 Link_array<Bar> bar_arr
143 = Group_interface__extract_elements (this, (Bar*)0, "bars");
146 translate_axis (bar_arr[0]->extent (Y_AXIS)[UP], Y_AXIS);
147 translate_axis (get_broken_left_end_align (), X_AXIS);
151 Volta_spanner::add_bar (Bar* c)
153 Group_interface gi(this, "bars");
160 Volta_spanner::add_column (Note_column* c)
162 Group_interface gi(this, "note-columns");