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"),
79 scale_drul (&edge_height, - Real (get_grob_direction (me)));
83 start[X_AXIS] = me->spanner_length () - left - half_space;
86 ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around.
89 = Tuplet_bracket::make_bracket (me, Y_AXIS, start,
90 edge_height, empty, flare, shorten);
92 if (!orig_span || broken_first_bracket)
94 SCM text = me->get_property ("text");
95 SCM properties = me->get_property_alist_chain (SCM_EOL);
96 SCM snum = Text_interface::interpret_markup (layout->self_scm (),
98 Stencil num = *unsmob_stencil (snum);
99 num.align_to (Y_AXIS, UP);
100 num.translate_axis (-0.5, Y_AXIS);
101 total.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
105 total.translate_axis (left, X_AXIS);
106 return total.smobbed_copy ();
111 Volta_bracket_interface::modify_edge_height (Spanner *me)
113 Spanner *orig_span = dynamic_cast<Spanner *> (me->original ());
115 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me);
116 bool broken_last_bracket = orig_span && (orig_span->broken_intos_.back () == (Spanner *)me);
117 bool no_vertical_start = orig_span && !broken_first_bracket;
118 bool no_vertical_end = orig_span && !broken_last_bracket;
120 extract_grob_set (me, "bars", bars);
121 Grob *endbar = bars.size () ? bars.back () : 0;
122 SCM glyph = endbar ? endbar->get_property ("glyph") : SCM_EOL;
125 if (scm_is_string (glyph))
126 str = ly_scm2string (glyph);
137 if (no_vertical_end || no_vertical_start)
139 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
140 Interval (1.0, 1.0));
141 if (no_vertical_start)
142 edge_height[LEFT] = 0.0;
145 edge_height[RIGHT] = 0.0;
147 me->set_property ("edge-height", ly_interval2scm (edge_height));
150 if (broken_last_bracket && no_vertical_end && no_vertical_start
151 && !broken_first_bracket)
156 Volta_bracket_interface::add_bar (Grob *me, Item *b)
158 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
159 Side_position_interface::add_support (me, b);
160 add_bound_item (dynamic_cast<Spanner *> (me), b);
164 Volta_bracket_interface::add_column (Grob *me, Grob *c)
166 Side_position_interface::add_support (me, c);
169 ADD_INTERFACE (Volta_bracket_interface, "volta-bracket-interface",
170 "Volta bracket with number",