2 text-spanner.cc -- implement Text_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
8 Revised over good by Han-Wen.
11 #include "molecule.hh"
12 #include "text-item.hh"
13 #include "text-spanner.hh"
14 #include "line-spanner.hh"
16 #include "font-interface.hh"
17 #include "dimensions.hh"
18 #include "paper-def.hh"
20 #include "paper-column.hh"
21 #include "staff-symbol-referencer.hh"
25 - vertical start / vertical end (fixme-name) |
26 - contination types (vert. star, vert. end) |-> eat volta-bracket
28 - more texts/positions
31 MAKE_SCHEME_CALLBACK (Text_spanner, brew_molecule, 1);
34 TODO: this function is too long
37 Text_spanner::brew_molecule (SCM smob)
39 Grob *me= unsmob_grob (smob);
40 Spanner *spanner = dynamic_cast<Spanner*> (me);
42 /* Ugh, must be same as Hairpin::brew_molecule. */
44 SCM itp= me->get_grob_property ("if-text-padding");
45 if (gh_number_p (itp))
46 padding = gh_scm2double (itp);
48 Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
49 Paper_def * paper = me->get_paper();
52 Drul_array<bool> broken;
56 Item *b = spanner->get_bound (d);
57 broken[d] = b->break_status_dir () != CENTER;
62 span_points[d] = spanner->get_broken_left_end_align ();
64 span_points[d] = b->relative_coordinate (common, X_AXIS);
68 bool encl = to_boolean (me->get_grob_property ("enclose-bounds"));
69 span_points[d] = b->extent (common, X_AXIS)[encl ? d : -d];
72 while (flip (&d) != LEFT);
76 SCM properties = Font_interface::font_alist_chain (me);
77 SCM edge_text = me->get_grob_property ("edge-text");
78 Drul_array<Molecule> edge;
79 if (gh_pair_p (edge_text))
84 /* Don't repeat edge text for broken end */
88 SCM text = index_get_cell (edge_text, d);
90 if (Text_item::markup_p (text))
91 edge[d] = *unsmob_molecule (Text_item::interpret_markup (paper->self_scm (), properties, text));
93 if (!edge[d].empty_b ())
94 edge[d].align_to (Y_AXIS, CENTER);
96 while (flip (&d) != LEFT);
100 Drul_array<Real> shorten;
104 SCM ew = me->get_grob_property ("bracket-flare");
105 SCM s = me->get_grob_property ("shorten-pair");
108 span_points[LEFT] += gh_scm2double (ly_car (s));
109 span_points[RIGHT] -= gh_scm2double (ly_cdr (s));
113 span_points[LEFT] += gh_scm2double (ly_car (ew));
114 span_points[RIGHT] -= gh_scm2double (ly_cdr (ew));
117 Real thick = paper->get_realvar (ly_symbol2scm ("linethickness"));
118 SCM st = me->get_grob_property ("thickness");
119 if (gh_number_p (st))
121 thick *= gh_scm2double (st);
124 Drul_array<Molecule> edge_line;
125 s = me->get_grob_property ("edge-height");
129 int dir = to_dir (me->get_grob_property ("direction"));
137 dx = gh_scm2double (index_get_cell (ew, d)) * d;
139 Real dy = gh_scm2double (index_get_cell (s, d)) * - dir;
141 edge_line[d] = Line_spanner::line_molecule (me, thick, Offset(0,0),
144 while (flip (&d) != LEFT);
150 Interval ext = edge[d].extent (X_AXIS);
152 edge[d].translate_axis (span_points[d], X_AXIS);
153 m.add_molecule (edge[d]);
154 edge_line[d].translate_axis (span_points[d], X_AXIS);
155 m.add_molecule (edge_line[d]);
157 span_points[d] += -d * ext[-d];
159 while (flip (&d) != LEFT);
161 Molecule l =Line_spanner::line_molecule (me, thick,
162 Offset (span_points[LEFT], 0),
163 Offset (span_points[RIGHT], 0));
166 m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
167 return m.smobbed_copy ();
173 ADD_INTERFACE (Text_spanner,"text-spanner-interface",
174 "generic text spanner",
175 "dash-period if-text-padding dash-fraction edge-height bracket-flare edge-text shorten-pair style thickness enclose-bounds width-correct");