3 crescendo-text-spanner.cc -- implement Text_spanner
5 source file of the GNU LilyPond music typesetter
7 (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
9 Revised over good by Han-Wen.
13 #include "text-item.hh"
14 #include "text-spanner.hh"
15 #include "line-spanner.hh"
17 #include "font-interface.hh"
18 #include "dimensions.hh"
19 #include "output-def.hh"
21 #include "paper-column.hh"
25 class Dynamic_text_spanner
28 DECLARE_SCHEME_CALLBACK (print, (SCM));
29 static bool has_interface (Grob*);
35 This is a partial C&P from text-spanner.cc
37 Dynamic_text_spanner is similar, but
39 * does not require bracket functionality.
41 * should make room for spanning points (mf/f/mp texts).
43 * In the future, we should support
45 cresc - - - - poco - - - a - - - - poco - - -
50 The cut & paste is rather inelegant, but text-spanner was a failed
51 and buggy attempt at being generic.
55 MAKE_SCHEME_CALLBACK (Dynamic_text_spanner, print, 1);
57 Dynamic_text_spanner::print (SCM smob)
59 Grob *me= unsmob_grob (smob);
60 Spanner *spanner = dynamic_cast<Spanner*> (me);
62 Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
63 Output_def * paper = me->get_paper ();
66 Drul_array<bool> broken;
70 Item *b = spanner->get_bound (d);
71 broken[d] = b->break_status_dir () != CENTER;
76 span_points[d] = spanner->get_broken_left_end_align ();
78 span_points[d] = b->relative_coordinate (common, X_AXIS);
84 if (b->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
86 pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
90 Interval ext = b->extent (common, X_AXIS);
91 span_points[d] = -d * pad
92 + robust_relative_extent (b,common, X_AXIS)
93 .linear_combination (encl);
96 while (flip (&d) != LEFT);
100 SCM properties = Font_interface::text_font_alist_chain (me);
101 SCM edge_text = me->get_property ("edge-text");
102 Drul_array<Stencil> edge;
103 if (ly_c_pair_p (edge_text))
111 SCM text = index_get_cell (edge_text, d);
113 if (Text_interface::markup_p (text))
114 edge[d] = *unsmob_stencil (Text_interface::interpret_markup (paper->self_scm (), properties, text));
116 if (!edge[d].is_empty ())
117 edge[d].align_to (Y_AXIS, CENTER);
119 while (flip (&d) != LEFT);
124 Interval ext = edge[d].extent (X_AXIS);
125 if (!ext.is_empty ())
127 edge[d].translate_axis (span_points[d], X_AXIS);
128 m.add_stencil (edge[d]);
129 span_points[d] += -d * ext[-d];
132 while (flip (&d) != LEFT);
135 if (!span_points.is_empty ())
137 Stencil l =Line_spanner::line_stencil (me,
138 Offset (span_points[LEFT], 0),
139 Offset (span_points[RIGHT], 0));
142 m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
143 return m.smobbed_copy ();
146 ADD_INTERFACE (Dynamic_text_spanner,
147 "dynamic-text-spanner-interface",
148 "A text spanner for crescendo texts",
149 "dash-period dash-fraction edge-text style thickness");