2 volta-bracket.cc -- implement Volta_bracket_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "font-interface.hh"
14 #include "line-interface.hh"
15 #include "paper-column.hh"
16 #include "output-def.hh"
17 #include "text-interface.hh"
18 #include "volta-bracket.hh"
19 #include "pointer-group-interface.hh"
20 #include "side-position-interface.hh"
21 #include "directional-element-interface.hh"
25 this is too complicated. Yet another version of side-positioning,
30 * Should look for system_start_delim to find left edge of staff.
33 MAKE_SCHEME_CALLBACK (Volta_bracket_interface, print, 1);
35 Volta_bracket_interface::print (SCM smob)
37 Grob *me = unsmob_grob (smob);
38 Spanner *orig_span = dynamic_cast<Spanner *> (me->original_);
40 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me);
42 bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner *)me);
44 bool no_vertical_start = orig_span && !broken_first_bracket;
45 bool no_vertical_end = orig_span && !broken_last_bracket;
47 extract_grob_set (me, "bars", bars);
48 Grob *endbar = bars.size () ? bars.top () : 0;
49 SCM glyph = endbar ? endbar->get_property ("glyph") : SCM_EOL;
52 if (scm_is_string (glyph))
53 str = ly_scm2string (glyph);
64 Output_def *layout = me->get_layout ();
65 Real half_space = 0.5;
67 Item *bound = dynamic_cast<Spanner *> (me)->get_bound (LEFT);
70 not a start, but really broken in two
73 if (bound->break_status_dir () == RIGHT)
75 Paper_column *pc = bound->get_column ();
76 left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS);
81 the volta spanner is attached to the bar-line, which is moved
82 to the right. We don't need to compensate for the left edge.
86 Real w = dynamic_cast<Spanner *> (me)->spanner_length () - left - half_space;
87 Real h = robust_scm2double (me->get_property ("height"), 1);
90 if (!no_vertical_start)
91 start = Line_interface::line (me, Offset (0, 0), Offset (0, h));
94 end = Line_interface::line (me, Offset (w, 0), Offset (w, h));
96 Stencil mol = Line_interface::line (me, Offset (0, h), Offset (w, h));
97 mol.add_stencil (start);
98 mol.add_stencil (end);
100 if (!orig_span || broken_first_bracket)
102 SCM text = me->get_property ("text");
103 SCM properties = me->get_property_alist_chain (SCM_EOL);
104 SCM snum = Text_interface::interpret_markup (layout->self_scm (),
106 Stencil num = *unsmob_stencil (snum);
108 mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
111 mol.translate_axis (left, X_AXIS);
112 return mol.smobbed_copy ();
116 Volta_bracket_interface::add_bar (Grob *me, Item *b)
118 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
119 Side_position_interface::add_support (me, b);
120 add_bound_item (dynamic_cast<Spanner *> (me), b);
124 Volta_bracket_interface::add_column (Grob *me, Grob *c)
126 Side_position_interface::add_support (me, c);
129 ADD_INTERFACE (Volta_bracket_interface, "volta-bracket-interface",
130 "Volta bracket with number",
131 "bars thickness height");