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>
12 #include "font-interface.hh"
13 #include "molecule.hh"
14 #include "paper-column.hh"
15 #include "paper-def.hh"
16 #include "text-item.hh"
17 #include "volta-spanner.hh"
18 #include "group-interface.hh"
19 #include "side-position-interface.hh"
20 #include "directional-element-interface.hh"
24 Volta_spanner::set_interface (Score_element
*me
)
29 this is too complicated. Yet another version of side-positioning,
34 * Should look for system_start_delim to find left edge of staff.
38 MAKE_SCHEME_CALLBACK(Volta_spanner
,brew_molecule
,1);
40 Volta_spanner::brew_molecule (SCM smob
)
42 Score_element
*me
= unsmob_element (smob
);
43 Link_array
<Item
> bar_arr
44 = Pointer_group_interface__extract_elements (me
, (Item
*)0, "bars");
49 bool no_vertical_start
= false;
50 bool no_vertical_end
= to_boolean (me
->get_elt_property ("last-volta"));
51 Spanner
*orig_span
= dynamic_cast<Spanner
*> (me
->original_l_
);
52 if (orig_span
&& (orig_span
->broken_into_l_arr_
[0] != (Spanner
*)me
))
53 no_vertical_start
= true;
54 if (orig_span
&& (orig_span
->broken_into_l_arr_
.top () != (Spanner
*)me
))
55 no_vertical_end
= true;
59 if (bar_arr
.top ()->me
->get_elt_property (type_str_
.length_i () > 1)
60 no_vertical_end
= false;
63 Real staff_space
= me
->paper_l ()->get_var ("staffspace");
64 Real staff_thick
= me
->paper_l ()->get_var ("stafflinethickness");
65 Real half_space
= staff_space
/ 2;
68 the volta spanner is attached to the bar-line, which is moved
69 to the right. We don't need to compensate for the left edge.
72 Real w
= dynamic_cast<Spanner
*>(me
)->spanner_length () - left
- half_space
;
73 Real h
= staff_space
* gh_scm2double (me
->get_elt_property ("height"));
74 Real t
= staff_thick
* gh_scm2double (me
->get_elt_property ("thickness"));
77 ugh: should build from line segments.
79 SCM at
= (gh_list (ly_symbol2scm ("volta"),
83 gh_int2scm (no_vertical_start
),
84 gh_int2scm (no_vertical_end
),
87 Box
b (Interval (0, w
), Interval (0, h
));
89 SCM text
= me
->get_elt_property("text");
90 SCM properties
= gh_list (me
->mutable_property_alist_
, me
->immutable_property_alist_
,SCM_UNDEFINED
);
91 Molecule num
= Text_item::text2molecule (me
, text
, properties
);
93 mol
.add_at_edge (X_AXIS
, LEFT
, num
, - num
.extent (X_AXIS
).length ()
95 mol
.translate_axis (left
, X_AXIS
);
96 return mol
.create_scheme();
101 Volta_spanner::add_bar (Score_element
*me
, Item
* b
)
103 Pointer_group_interface::add_element(me
, "bars",b
);
104 Side_position::add_support (me
,b
);
105 add_bound_item (dynamic_cast<Spanner
*>(me
), b
);
109 Volta_spanner::add_column (Score_element
*me
, Score_element
* c
)
111 Side_position::add_support (me
,c
);