2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2015 Jan Nieuwenhuizen <janneke@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
23 #include "font-interface.hh"
24 #include "line-interface.hh"
25 #include "paper-column.hh"
26 #include "output-def.hh"
27 #include "text-interface.hh"
28 #include "volta-bracket.hh"
29 #include "pointer-group-interface.hh"
30 #include "side-position-interface.hh"
31 #include "directional-element-interface.hh"
33 #include "tuplet-bracket.hh"
34 #include "lily-imports.hh"
39 this is too complicated. Yet another version of side-positioning,
44 * Should look for system_start_delim to find left edge of staff.
47 MAKE_SCHEME_CALLBACK (Volta_bracket_interface, print, 1);
49 Volta_bracket_interface::print (SCM smob)
51 Spanner *me = unsmob<Spanner> (smob);
52 Spanner *orig_span = dynamic_cast<Spanner *> (me->original ());
53 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0]
56 Output_def *layout = me->layout ();
58 Item *bound = dynamic_cast<Spanner *> (me)->get_bound (LEFT);
61 If the volta bracket appears after a line-break, make
62 it start after the prefatory matter.
65 if (bound->break_status_dir () == RIGHT)
67 Paper_column *pc = bound->get_column ();
68 left = pc->break_align_width (pc, ly_symbol2scm ("break-alignment"))[RIGHT]
69 // For some reason, break_align_width is relative to
70 // the x-parent of the column.
71 - bound->relative_coordinate (pc->get_parent (X_AXIS), X_AXIS);
76 the volta spanner is attached to the bar-line, which is moved
77 to the right. We don't need to compensate for the left edge.
81 modify_edge_height (me);
85 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
87 Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
89 Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
92 scale_drul (&edge_height, - Real (get_grob_direction (me)));
96 start[X_AXIS] = me->spanner_length () - left;
99 ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around.
102 = Tuplet_bracket::make_bracket (me, Y_AXIS, start,
103 edge_height, empty, flare, shorten);
105 if (!orig_span || broken_first_bracket)
107 SCM text = me->get_property ("text");
108 SCM properties = me->get_property_alist_chain (SCM_EOL);
109 SCM snum = Text_interface::interpret_markup (layout->self_scm (),
111 Stencil num = *unsmob<Stencil> (snum);
112 num.align_to (Y_AXIS, UP);
113 num.translate_axis (-0.5, Y_AXIS);
114 total.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
118 total.translate_axis (left, X_AXIS);
119 return total.smobbed_copy ();
123 Volta_bracket_interface::modify_edge_height (Spanner *me)
125 Spanner *orig_span = dynamic_cast<Spanner *> (me->original ());
127 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me);
128 bool broken_last_bracket = orig_span && (orig_span->broken_intos_.back () == (Spanner *)me);
129 bool no_vertical_start = orig_span && !broken_first_bracket;
130 bool no_vertical_end = orig_span && !broken_last_bracket;
132 extract_grob_set (me, "bars", bars);
133 Grob *endbar = bars.size () ? bars.back () : 0;
134 SCM glyph = endbar ? endbar->get_property ("glyph-name") : SCM_EOL;
137 if (scm_is_string (glyph))
138 str = ly_scm2string (glyph);
142 no_vertical_end |= ly_scm2bool (Lily::volta_bracket_calc_hook_visibility
143 (ly_string2scm (str)));
145 if (no_vertical_end || no_vertical_start)
147 Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
148 Interval (1.0, 1.0));
149 if (no_vertical_start)
150 edge_height[LEFT] = 0.0;
153 edge_height[RIGHT] = 0.0;
155 me->set_property ("edge-height", ly_interval2scm (edge_height));
158 if (broken_last_bracket && no_vertical_end && no_vertical_start
159 && !broken_first_bracket)
164 Volta_bracket_interface::add_bar (Grob *me, Item *b)
166 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
167 add_bound_item (dynamic_cast<Spanner *> (me), b);
170 ADD_INTERFACE (Volta_bracket_interface,
171 "Volta bracket with number.",