2 dynamic-text-spanner.cc -- implement Text_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
8 Revised over good by Han-Wen.
11 #include "text-interface.hh"
12 #include "text-spanner.hh"
13 #include "line-spanner.hh"
15 #include "font-interface.hh"
16 #include "dimensions.hh"
17 #include "output-def.hh"
19 #include "paper-column.hh"
21 class Dynamic_text_spanner
24 DECLARE_SCHEME_CALLBACK (print, (SCM));
25 static bool has_interface (Grob *);
29 This is a partial C&P from text-spanner.cc
31 Dynamic_text_spanner is similar, but
33 * does not require bracket functionality.
35 * should make room for spanning points (mf/f/mp texts).
37 * In the future, we should support
39 cresc - - - - poco - - - a - - - - poco - - -
44 The cut & paste is rather inelegant, but text-spanner was a failed
45 and buggy attempt at being generic.
47 MAKE_SCHEME_CALLBACK (Dynamic_text_spanner, print, 1);
49 Dynamic_text_spanner::print (SCM smob)
51 Grob *me = unsmob_grob (smob);
52 Spanner *spanner = dynamic_cast<Spanner *> (me);
54 Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
55 Output_def *layout = me->layout ();
58 Drul_array<bool> broken;
62 Item *b = spanner->get_bound (d);
63 broken[d] = b->break_status_dir () != CENTER;
68 span_points[d] = spanner->get_broken_left_end_align ();
70 span_points[d] = b->relative_coordinate (common, X_AXIS);
76 if (b->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
78 pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
85 FIXME: this fixed an issue, but need to have this issue in
90 if (d == RIGHT && me->get_property ("style") == ly_symbol2scm ("trill"))
97 Interval ext = b->extent (common, X_AXIS);
98 span_points[d] = -d * pad
99 + robust_relative_extent (b, common, X_AXIS)
100 .linear_combination (encl);
103 while (flip (&d) != LEFT);
106 SCM properties = Font_interface::text_font_alist_chain (me);
107 SCM edge_text = me->get_property ("edge-text");
108 Drul_array<Stencil> edge;
109 if (scm_is_pair (edge_text))
117 SCM text = index_get_cell (edge_text, d);
119 if (Text_interface::is_markup (text))
120 edge[d] = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, text));
122 if (!edge[d].is_empty ())
123 edge[d].align_to (Y_AXIS, CENTER);
125 while (flip (&d) != LEFT);
130 Interval ext = edge[d].extent (X_AXIS);
131 Real pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
132 if (!ext.is_empty ())
134 edge[d].translate_axis (span_points[d], X_AXIS);
135 m.add_stencil (edge[d]);
136 span_points[d] += -d * (ext[-d] + pad);
139 while (flip (&d) != LEFT);
141 if (!span_points.is_empty ()
142 && span_points.length () > robust_scm2double (me->get_property ("dash-period"), 0.0))
144 Stencil l = Line_spanner::line_stencil (me,
145 Offset (span_points[LEFT], 0),
146 Offset (span_points[RIGHT], 0));
149 m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
150 return m.smobbed_copy ();
153 ADD_INTERFACE (Dynamic_text_spanner,
154 "dynamic-text-spanner-interface",
155 "A text spanner for crescendo texts",