2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2003--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
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 "tuplet-bracket.hh"
24 #include "axis-group-interface.hh"
26 struct Piano_pedal_bracket
28 DECLARE_SCHEME_CALLBACK (print, (SCM));
29 DECLARE_GROB_INTERFACE ();
32 MAKE_SCHEME_CALLBACK (Piano_pedal_bracket, print, 1);
34 Piano_pedal_bracket::print (SCM smob)
36 Spanner *me = dynamic_cast<Spanner *> (Grob::unsmob (smob));
37 Spanner *orig = dynamic_cast<Spanner *> (me->original ());
39 Drul_array<bool> broken (false, false);
40 Drul_array<Real> height = robust_scm2drul
41 (me->get_property ("edge-height"), Interval (0, 0));
42 Drul_array<Real> shorten = robust_scm2drul
43 (me->get_property ("shorten-pair"), Interval (0, 0));
44 Drul_array<Real> flare = robust_scm2drul
45 (me->get_property ("bracket-flare"), Interval (0, 0));
47 Grob *common = me->get_bound (LEFT)
48 ->common_refpoint (me->get_bound (RIGHT), X_AXIS);
49 Grob *textbit = Grob::unsmob (me->get_object ("pedal-text"));
52 common = common->common_refpoint (textbit, X_AXIS);
54 Interval span_points (0, 0);
55 for (LEFT_and_RIGHT (d))
57 Item *b = me->get_bound (d);
58 broken[d] = b->break_status_dir () != CENTER;
63 && me->get_break_index () != orig->broken_intos_.size () - 1)
64 || (d == LEFT && me->get_break_index ())))
70 = Axis_group_interface::generic_bound_extent (b, common, X_AXIS)[RIGHT];
73 span_points[d] = b->relative_coordinate (common, X_AXIS);
76 /* For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____|
77 need to shorten by the extent of the text grob
83 Real padding = robust_scm2double (me->get_property ("bound-padding"), 0);
85 span_points[LEFT] = padding
86 + robust_relative_extent (textbit, common, X_AXIS)[RIGHT];
90 if (!span_points.is_empty ()
91 && span_points.length () > 0.001)
93 m = Tuplet_bracket::make_bracket (me, Y_AXIS,
94 Offset (span_points.length (), 0),
99 m.translate_axis (span_points[LEFT]
100 - me->relative_coordinate (common, X_AXIS), X_AXIS);
101 return m.smobbed_copy ();
104 ADD_INTERFACE (Piano_pedal_bracket,
105 "The bracket of the piano pedal. It can be tuned through"
106 " the regular bracket properties.",