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 (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_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_grob_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_grob_property (type_str_.length_i () > 1)
60 no_vertical_end = false;
63 Real staff_thick = me->paper_l ()->get_var ("stafflinethickness");
64 Real half_space = 0.5;
67 the volta spanner is attached to the bar-line, which is moved
68 to the right. We don't need to compensate for the left edge.
71 Real w = dynamic_cast<Spanner*>(me)->spanner_length () - left - half_space;
72 Real h = gh_scm2double (me->get_grob_property ("height"));
73 Real t = staff_thick * gh_scm2double (me->get_grob_property ("thickness"));
76 ugh: should build from line segments.
78 SCM at = (gh_list (ly_symbol2scm ("volta"),
82 gh_int2scm (no_vertical_start),
83 gh_int2scm (no_vertical_end),
86 Box b (Interval (0, w), Interval (0, h));
88 SCM text = me->get_grob_property("text");
89 SCM properties = gh_list (me->mutable_property_alist_, me->immutable_property_alist_,SCM_UNDEFINED);
90 Molecule num = Text_item::text2molecule (me, text, properties);
92 mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
94 mol.translate_axis (left, X_AXIS);
95 return mol.smobbed_copy ();
100 Volta_spanner::add_bar (Grob *me, Item* b)
102 Pointer_group_interface::add_element(me, "bars",b);
103 Side_position::add_support (me,b);
104 add_bound_item (dynamic_cast<Spanner*>(me), b);
108 Volta_spanner::add_column (Grob*me, Grob* c)
110 Side_position::add_support (me,c);