2 text-spanner.cc -- implement Text_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "text-item.hh"
11 #include "text-spanner.hh"
12 #include "line-spanner.hh"
14 #include "font-interface.hh"
15 #include "dimensions.hh"
16 #include "paper-def.hh"
18 #include "paper-column.hh"
19 #include "staff-symbol-referencer.hh"
23 - vertical start / vertical end (fixme-name) |
24 - contination types (vert. star, vert. end) |-> eat volta-spanner
26 - more texts/positions
29 MAKE_SCHEME_CALLBACK (Text_spanner, brew_molecule, 1);
32 Text_spanner::brew_molecule (SCM smob)
34 Grob *me= unsmob_grob (smob);
35 Spanner *spanner = dynamic_cast<Spanner*> (me);
39 /* Ugh, must be same as Hairpin::brew_molecule. */
40 Real padding = gh_scm2double (me->get_grob_property ("if-text-padding"));
41 Real broken_left = spanner->get_broken_left_end_align ();
42 Real width = spanner->spanner_length ();
45 Drul_array<bool> broken;
46 Drul_array<Real> extra_off;
50 Item *b = spanner->get_bound (d);
51 broken[d] = b->break_status_dir () != CENTER;
56 Interval e = b->extent (b, X_AXIS);
60 /* Text spanners such as ottava, should span from outer limits of
61 noteheads, iso (de)cresc. spanners that span the inner space */
62 if (me->get_grob_property ("outer") != SCM_EOL)
74 while (flip (&d) != LEFT);
76 // FIXME: ecs tells us -- only for (de)cresc. spanners
77 width += gh_scm2double (me->get_grob_property ("width-correct"));
81 SCM properties = Font_interface::font_alist_chain (me);
83 SCM edge_text = me->get_grob_property ("edge-text");
84 Drul_array<Molecule> edge;
85 if (gh_pair_p (edge_text))
90 SCM text = index_cell (edge_text, d);
91 edge[d] = Text_item::text2molecule (me, text, properties);
92 if (!edge[d].empty_b ())
93 edge[d].align_to (Y_AXIS, CENTER);
95 while (flip (&d) != LEFT);
97 width -= edge[LEFT].extent (X_AXIS).length ()
98 + edge[RIGHT].extent (X_AXIS).length ();
100 Drul_array<Real> shorten;
104 SCM s = me->get_grob_property ("shorten");
107 shorten[LEFT] = gh_scm2double (gh_car (s));
108 shorten[RIGHT] = gh_scm2double (gh_cdr (s));
111 width -= shorten[LEFT] + shorten[RIGHT];
115 warning (_ ("Text_spanner too small"));
120 Real thick = me->paper_l ()->get_var ("stafflinethickness");
123 SCM list = Line_spanner::line_atom (me, width, 0);
127 Box b (Interval (0, width), Interval (-thick / 2, thick / 2));
128 line = Molecule (b, list);
131 Drul_array<Molecule> edge_line;
132 s = me->get_grob_property ("edge-height");
136 int dir = to_dir (me->get_grob_property ("direction"));
139 Real dy = gh_scm2double (index_cell (s, d)) * - dir;
142 SCM list = Line_spanner::line_atom (me, 0, dy);
143 Box b (Interval (0, thick),
147 edge_line[d] = Molecule (b, list);
150 while (flip (&d) != LEFT);
154 if (!edge[LEFT].empty_b ())
157 if (!edge_line[LEFT].empty_b ())
158 m.add_at_edge (X_AXIS, RIGHT, edge_line[LEFT], 0);
159 if (!line.empty_b ())
160 m.add_at_edge (X_AXIS, RIGHT, line, 0);
161 if (!edge_line[RIGHT].empty_b ())
162 m.add_at_edge (X_AXIS, RIGHT, edge_line[RIGHT], 0);
163 if (!edge[RIGHT].empty_b ())
164 m.add_at_edge (X_AXIS, RIGHT, edge[RIGHT], 0);
165 m.translate_axis (broken_left + extra_off[LEFT], X_AXIS);
167 return m.smobbed_copy ();