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 span_points[d] = -d * pad + b->extent (common, X_AXIS).linear_combination (encl);
93 while (flip (&d) != LEFT);
97 SCM properties = Font_interface::text_font_alist_chain (me);
98 SCM edge_text = me->get_property ("edge-text");
99 Drul_array<Stencil> edge;
100 if (ly_c_pair_p (edge_text))
108 SCM text = index_get_cell (edge_text, d);
110 if (Text_item::markup_p (text))
111 edge[d] = *unsmob_stencil (Text_item::interpret_markup (paper->self_scm (), properties, text));
113 if (!edge[d].is_empty ())
114 edge[d].align_to (Y_AXIS, CENTER);
116 while (flip (&d) != LEFT);
121 Interval ext = edge[d].extent (X_AXIS);
122 if (!ext.is_empty ())
124 edge[d].translate_axis (span_points[d], X_AXIS);
125 m.add_stencil (edge[d]);
126 span_points[d] += -d * ext[-d];
129 while (flip (&d) != LEFT);
132 if (!span_points.is_empty ())
134 Stencil l =Line_spanner::line_stencil (me,
135 Offset (span_points[LEFT], 0),
136 Offset (span_points[RIGHT], 0));
139 m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
140 return m.smobbed_copy ();
143 ADD_INTERFACE (Dynamic_text_spanner,
144 "crescendo-text-spanner-interface",
145 "A text spanner for crescendo texts",
146 "dash-period dash-fraction edge-text style thickness");