2 piano-pedal-bracket.cc -- implement Piano_pedal_bracket
4 source file of the GNU LilyPond music typesetter
6 (c) 2003--2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "molecule.hh"
13 #include "tuplet-bracket.hh"
15 struct Piano_pedal_bracket
17 DECLARE_SCHEME_CALLBACK(print,(SCM));
18 static bool has_interface (Grob*);
22 MAKE_SCHEME_CALLBACK(Piano_pedal_bracket,print,1);
24 Piano_pedal_bracket::print (SCM smob)
26 Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
28 Drul_array<bool> broken (false,false);
29 Drul_array<Real> height = robust_scm2drul
30 (me->get_grob_property ("edge-height"), Interval (0,0));
31 Drul_array<Real> shorten = robust_scm2drul
32 (me->get_grob_property ("shorten-pair"), Interval (0,0));
33 Drul_array<Real> flare = robust_scm2drul
34 (me->get_grob_property ("bracket-flare"), Interval (0,0));
36 Grob *common = me->get_bound (LEFT)
37 ->common_refpoint (me->get_bound (RIGHT), X_AXIS);
38 Grob *textbit = unsmob_grob (me->get_grob_property("pedal-text"));
41 common = common->common_refpoint (textbit, X_AXIS);
43 Interval span_points (0,0);
47 Item *b = me->get_bound (d);
48 broken[d] = b->break_status_dir () != CENTER;
52 Interval ext = b->extent (common, X_AXIS);
53 span_points[d] = ext [broken[d] ? RIGHT : LEFT];
55 while (flip (&d) != LEFT);
58 /* For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____|
59 need to shorten by the extent of the text grob
65 Real padding = robust_scm2double (me->get_grob_property ("if-text-padding"), 0);
67 span_points[LEFT] = padding
68 + textbit->extent (common, X_AXIS)[RIGHT];
73 if (!span_points.is_empty () &&
74 span_points.length () > 0.001)
76 m = Tuplet_bracket::make_bracket (me, Y_AXIS,
77 Offset (span_points.length (), 0),
82 m.translate_axis (span_points[LEFT]
83 - me->relative_coordinate (common, X_AXIS), X_AXIS);
84 return m.smobbed_copy ();
89 ADD_INTERFACE (Piano_pedal_bracket,"piano-pedal-bracket-interface",
90 "The bracket of the piano pedal. It can be tuned through the regular bracket properties (bracket-flare, edge-height, shorten-pair).",
91 "edge-height shorten-pair bracket-flare pedal-text");