2 lyric-extender.cc -- implement Lyric_extender
3 source file of the GNU LilyPond music typesetter
5 (c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "lyric-extender.hh"
15 #include "paper-column.hh"
16 #include "output-def.hh"
17 #include "note-head.hh"
18 #include "group-interface.hh"
20 MAKE_SCHEME_CALLBACK (Lyric_extender, print, 1)
22 Lyric_extender::print (SCM smob)
24 Spanner *me = unsmob_spanner (smob);
25 Item *left_edge = me->get_bound (LEFT);
26 Item *right_text = unsmob_item (me->get_property ("next"));
28 Grob *common = left_edge;
31 common = common->common_refpoint (right_text, X_AXIS);
33 common = common->common_refpoint (me->get_bound (RIGHT), X_AXIS);
34 Real sl = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
35 Link_array<Grob> heads (extract_grob_array (me, ly_symbol2scm ("heads")));
40 common = common_refpoint_of_array (heads, common, X_AXIS);
42 Real left_point = 0.0;
43 if (left_edge->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
44 left_point = left_edge->extent (common, X_AXIS)[RIGHT];
45 else if (heads.size ())
46 left_point = heads[0]->extent (common, X_AXIS)[LEFT];
48 left_point = left_edge->extent (common, X_AXIS)[RIGHT];
50 if (isinf (left_point))
53 /* It seems that short extenders are even lengthened to go past the
54 note head, but haven't found a pattern in it yet. --hwn 1/1/04 */
55 SCM minlen = me->get_property ("minimum-length");
57 = left_point + (robust_scm2double (minlen, 0));
60 right_point = right_point >? heads.top ()->extent (common, X_AXIS)[RIGHT];
62 Real h = sl * robust_scm2double (me->get_property ("thickness"), 0);
66 right_point = right_point <? (robust_relative_extent (right_text, common, X_AXIS)[LEFT] - pad);
68 /* run to end of line. */
69 if (me->get_bound (RIGHT)->break_status_dir ())
70 right_point = right_point >? (robust_relative_extent (me->get_bound (RIGHT), common, X_AXIS)[LEFT] - pad);
73 Real w = right_point - left_point;
78 Stencil mol (Lookup::round_filled_box (Box (Interval (0, w),
81 mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS),
83 return mol.smobbed_copy ();
86 ADD_INTERFACE (Lyric_extender, "lyric-extender-interface",
87 "The extender is a simple line at the baseline of the lyric "
88 "that helps show the length of a melissima (tied/slurred note).",
89 "next thickness heads");