2 volta-spanner.cc -- implement Volta_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 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 (Grob
*)
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 Grob
*me
= unsmob_grob (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_grob_property ("last-volta"));
51 Spanner
*orig_span
= dynamic_cast<Spanner
*> (me
->original_l_
);
53 bool first_bracket
= orig_span
&& (orig_span
->broken_into_l_arr_
[0] == (Spanner
*)me
);
55 bool last_bracket
= orig_span
&& (orig_span
->broken_into_l_arr_
.top () == (Spanner
*)me
);
57 no_vertical_start
= orig_span
&& !first_bracket
;
58 no_vertical_end
= orig_span
&& !last_bracket
;
60 Real staff_thick
= me
->paper_l ()->get_var ("stafflinethickness");
61 Real half_space
= 0.5;
63 Item
* bound
= dynamic_cast<Spanner
*> (me
)->get_bound (LEFT
);
66 not a start, but really broken in two
69 if (bound
->break_status_dir () == RIGHT
)
71 Paper_column
*pc
= bound
->column_l ();
72 left
= pc
->extent (pc
, X_AXIS
)[RIGHT
] - bound
->relative_coordinate (pc
, X_AXIS
);
77 the volta spanner is attached to the bar-line, which is moved
78 to the right. We don't need to compensate for the left edge.
82 Real w
= dynamic_cast<Spanner
*> (me
)->spanner_length () - left
- half_space
;
83 Real h
= gh_scm2double (me
->get_grob_property ("height"));
84 Real t
= staff_thick
* gh_scm2double (me
->get_grob_property ("thickness"));
87 ugh: should build from line segments.
89 SCM at
= (gh_list (ly_symbol2scm ("volta"),
93 gh_int2scm (no_vertical_start
),
94 gh_int2scm (no_vertical_end
),
97 Box
b (Interval (0, w
), Interval (0, h
));
99 SCM text
= me
->get_grob_property ("text");
100 SCM properties
= gh_list (me
->mutable_property_alist_
, me
->immutable_property_alist_
,SCM_UNDEFINED
);
101 Molecule num
= Text_item::text2molecule (me
, text
, properties
);
103 mol
.add_at_edge (X_AXIS
, LEFT
, num
, - num
.extent (X_AXIS
).length ()
105 mol
.translate_axis (left
, X_AXIS
);
106 return mol
.smobbed_copy ();
111 Volta_spanner::add_bar (Grob
*me
, Item
* b
)
113 Pointer_group_interface::add_element (me
, "bars",b
);
114 Side_position_interface::add_support (me
,b
);
115 add_bound_item (dynamic_cast<Spanner
*> (me
), b
);
119 Volta_spanner::add_column (Grob
*me
, Grob
* c
)
121 Side_position_interface::add_support (me
,c
);