2 volta-bracket.cc -- implement Volta_bracket_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 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"
23 #include "tuplet-bracket.hh"
26 this is too complicated. Yet another version of side-positioning,
31 * Should look for system_start_delim to find left edge of staff.
34 MAKE_SCHEME_CALLBACK (Volta_bracket_interface, print, 1);
36 Volta_bracket_interface::print (SCM smob)
38 Spanner *me = unsmob_spanner (smob);
39 Spanner *orig_span = dynamic_cast<Spanner *> (me->original ());
40 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0]
43 Output_def *layout = me->layout ();
44 Real half_space = 0.5;
46 Item *bound = dynamic_cast<Spanner *> (me)->get_bound (LEFT);
49 not a start, but really broken in two
52 if (bound->break_status_dir () == RIGHT)
54 Paper_column *pc = bound->get_column ();
55 left = pc->extent (pc, X_AXIS)[RIGHT]
56 - bound->relative_coordinate (pc, X_AXIS);
61 the volta spanner is attached to the bar-line, which is moved
62 to the right. We don't need to compensate for the left edge.
66 modify_edge_height (me);
70 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
72 Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
74 Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
77 scale_drul (&edge_height, - Real (get_grob_direction (me)));
81 start[X_AXIS] = me->spanner_length () - left - half_space;
84 ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around.
87 = Tuplet_bracket::make_bracket (me, Y_AXIS, start,
88 edge_height, empty, flare, shorten);
90 if (!orig_span || broken_first_bracket)
92 SCM text = me->get_property ("text");
93 SCM properties = me->get_property_alist_chain (SCM_EOL);
94 SCM snum = Text_interface::interpret_markup (layout->self_scm (),
96 Stencil num = *unsmob_stencil (snum);
97 num.align_to (Y_AXIS, UP);
98 num.translate_axis (-0.5, Y_AXIS);
99 total.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
103 total.translate_axis (left, X_AXIS);
104 return total.smobbed_copy ();
109 Volta_bracket_interface::modify_edge_height (Spanner *me)
111 Spanner *orig_span = dynamic_cast<Spanner *> (me->original ());
113 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me);
114 bool broken_last_bracket = orig_span && (orig_span->broken_intos_.back () == (Spanner *)me);
115 bool no_vertical_start = orig_span && !broken_first_bracket;
116 bool no_vertical_end = orig_span && !broken_last_bracket;
118 extract_grob_set (me, "bars", bars);
119 Grob *endbar = bars.size () ? bars.back () : 0;
120 SCM glyph = endbar ? endbar->get_property ("glyph") : SCM_EOL;
123 if (scm_is_string (glyph))
124 str = ly_scm2string (glyph);
135 if (no_vertical_end || no_vertical_start)
137 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
138 Interval (1.0, 1.0));
139 if (no_vertical_start)
140 edge_height[LEFT] = 0.0;
143 edge_height[RIGHT] = 0.0;
145 me->set_property ("edge-height", ly_interval2scm (edge_height));
148 if (broken_last_bracket && no_vertical_end && no_vertical_start
149 && !broken_first_bracket)
154 Volta_bracket_interface::add_bar (Grob *me, Item *b)
156 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
157 Side_position_interface::add_support (me, b);
158 add_bound_item (dynamic_cast<Spanner *> (me), b);
162 Volta_bracket_interface::add_column (Grob *me, Grob *c)
164 Side_position_interface::add_support (me, c);
167 ADD_INTERFACE (Volta_bracket_interface, "volta-bracket-interface",
168 "Volta bracket with number",