2 piano-pedal-bracket.cc -- implement Piano_pedal_bracket
4 source file of the GNU LilyPond music typesetter
6 (c) 2003 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 based on smouldering remains by
10 Chris Jackson <chris@fluffhouse.org.uk>
15 Piano pedal brackets are a special case of a text spanner.
16 Pedal up-down (restart) indicated by the angled right and left edges
17 of consecutive pedals touching exactly to form an __/\__
23 TODO: this should be moved somewhere else (?).
25 Perhaps make separate function for pedal-bracket.
27 #include "molecule.hh"
30 #include "paper-def.hh"
32 struct Piano_pedal_bracket
34 DECLARE_SCHEME_CALLBACK(after_line_breaking
,(SCM
));
35 static bool has_interface (Grob
*);
38 ADD_INTERFACE (Piano_pedal_bracket
,"piano-pedal-bracket-interface",
42 MAKE_SCHEME_CALLBACK(Piano_pedal_bracket
,after_line_breaking
,1);
44 Piano_pedal_bracket::after_line_breaking (SCM smob
)
46 Spanner
*me
= dynamic_cast<Spanner
*> (unsmob_grob (smob
));
48 Drul_array
<bool> broken
;
49 Drul_array
<Real
> height(0,0), shorten(0,0);
51 SCM eh
= me
->get_grob_property ("edge-height");
52 SCM sp
= me
->get_grob_property ("shorten-pair");
58 Item
*b
= me
->get_bound (d
);
59 broken
[d
] = b
->break_status_dir () != CENTER
;
61 if (!broken
[d
] && (is_number_pair (eh
)))
62 height
[d
] += gh_scm2double (index_get_cell (eh
, d
));
63 if (is_number_pair (sp
))
64 shorten
[d
] += gh_scm2double (index_get_cell (sp
, d
));
66 while (flip (&d
) != LEFT
);
68 /* For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____|
69 need to shorten by the extent of the text grob
72 Urg. - why not hang bracket between text items? --hwn
74 if (Grob
*textbit
= unsmob_grob (me
->get_grob_property("pedal-text")))
77 SCM pa
= me
->get_grob_property ("if-text-padding"); // UGH.
80 padding
= gh_scm2double (pa
);
82 shorten
[LEFT
] += padding
+ textbit
->extent (textbit
, X_AXIS
)[RIGHT
];
87 shorten
[LEFT
] -= me
->get_broken_left_end_align () ;
90 // Also shorten so that it ends just before the spanned note.
91 Grob
*rb
= me
->get_bound (RIGHT
);
92 shorten
[RIGHT
] += rb
->extent (rb
, X_AXIS
)[RIGHT
];
94 me
->set_grob_property ("edge-height", ly_interval2scm (height
));
95 me
->set_grob_property ("shorten-pair", ly_interval2scm (shorten
));
97 return SCM_UNSPECIFIED
;