3 text-spanner.cc -- implement Text_spanner
5 source file of the GNU LilyPond music typesetter
7 (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "molecule.hh"
11 #include "text-item.hh"
12 #include "text-spanner.hh"
13 #include "line-spanner.hh"
15 #include "font-interface.hh"
16 #include "dimensions.hh"
17 #include "paper-def.hh"
19 #include "paper-column.hh"
20 #include "staff-symbol-referencer.hh"
24 - vertical start / vertical end (fixme-name) |
25 - contination types (vert. star, vert. end) |-> eat volta-spanner
27 - more texts/positions
30 MAKE_SCHEME_CALLBACK (Text_spanner, brew_molecule, 1);
33 Text_spanner::brew_molecule (SCM smob)
35 Grob *me= unsmob_grob (smob);
36 Spanner *spanner = dynamic_cast<Spanner*> (me);
40 /* Ugh, must be same as Hairpin::brew_molecule. */
41 Real padding = gh_scm2double (me->get_grob_property ("if-text-padding"));
42 Real broken_left = spanner->get_broken_left_end_align ();
43 Real width = spanner->spanner_length ();
46 Drul_array<bool> broken;
47 Drul_array<Real> extra_off;
52 Item *b = spanner->get_bound (d);
53 broken[d] = b->break_status_dir () != CENTER;
58 Interval e = b->extent (b, X_AXIS);
62 /* Text spanners such as ottava, should span from outer limits of
63 noteheads, iso (de)cresc. spanners that span the inner space */
64 if (me->get_grob_property ("outer") != SCM_EOL)
76 while (flip (&d) != LEFT);
78 // FIXME: ecs tells us -- only for (de)cresc. spanners
79 width += gh_scm2double (me->get_grob_property ("width-correct"));
83 SCM properties = Font_interface::font_alist_chain (me);
85 SCM edge_text = me->get_grob_property ("edge-text");
86 Drul_array<Molecule> edge;
87 if (gh_pair_p (edge_text))
92 /* Don't repeat edge text for broken end */
95 SCM text = index_cell (edge_text, d);
96 edge[d] = Text_item::text2molecule (me, text, properties);
97 if (!edge[d].empty_b ())
98 edge[d].align_to (Y_AXIS, CENTER);
101 while (flip (&d) != LEFT);
103 width -= edge[LEFT].extent (X_AXIS).length ()
104 + edge[RIGHT].extent (X_AXIS).length ();
106 Drul_array<Real> shorten;
110 SCM s = me->get_grob_property ("shorten");
113 shorten[LEFT] = gh_scm2double (ly_car (s));
114 shorten[RIGHT] = gh_scm2double (ly_cdr (s));
117 width -= shorten[LEFT] + shorten[RIGHT];
121 warning (_ ("Text_spanner too small"));
126 Real thick = me->paper_l ()->get_var ("stafflinethickness");
128 Molecule line = Line_spanner::line_molecule (me, width, 0);
130 Drul_array<Molecule> edge_line;
131 s = me->get_grob_property ("edge-height");
135 int dir = to_dir (me->get_grob_property ("direction"));
138 Real dy = gh_scm2double (index_cell (s, d)) * - dir;
141 SCM list = Line_spanner::line_atom (me, 0, dy);
142 Box b (Interval (0, thick),
146 edge_line[d] = Molecule (b, list);
149 while (flip (&d) != LEFT);
153 if (!edge[LEFT].empty_b ())
156 if (!edge_line[LEFT].empty_b ())
157 m.add_at_edge (X_AXIS, RIGHT, edge_line[LEFT], 0);
158 if (!line.empty_b ())
159 m.add_at_edge (X_AXIS, RIGHT, line, 0);
160 if (!edge_line[RIGHT].empty_b ())
161 m.add_at_edge (X_AXIS, RIGHT, edge_line[RIGHT], 0);
162 if (!edge[RIGHT].empty_b ())
163 m.add_at_edge (X_AXIS, RIGHT, edge[RIGHT], 0);
164 m.translate_axis (broken_left + extra_off[LEFT], X_AXIS);
166 return m.smobbed_copy ();