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"
13 #include "font-interface.hh"
14 #include "dimensions.hh"
15 #include "paper-def.hh"
17 #include "paper-column.hh"
18 #include "staff-symbol-referencer.hh"
22 - vertical start / vertical end (fixme-name) |
23 - contination types (vert. star, vert. end) |-> eat volta-spanner
25 - more texts/positions
29 MAKE_SCHEME_CALLBACK (Text_spanner, brew_molecule, 1);
32 Text_spanner::brew_molecule (SCM smob)
34 Score_element *me= unsmob_element (smob);
35 Spanner *spanner = dynamic_cast<Spanner*> (me);
37 Real staff_space = Staff_symbol_referencer::staff_space (me);
38 Real thickness = me->paper_l ()->get_var ("stafflinethickness");
41 Drul_array<bool> broken;
45 Paper_column* s = dynamic_cast<Paper_column*>(spanner->get_bound (d)); // UGH
46 broken[d] = (!s->musical_b ());
48 while (flip (&d) != LEFT);
51 SCM s = me->get_elt_property ("text-style");
53 String text_style = "italic";
55 text_style = ly_scm2string (s);
58 SCM properties = Font_interface::font_alist_chain (me);
60 SCM edge_text = me->get_elt_property ("edge-text");
61 Drul_array<Molecule> edge;
62 if (gh_pair_p (edge_text))
67 SCM text = index_cell (edge_text, d);
68 edge[d] = Text_item::text2molecule (me, text, properties);
69 if (!edge[d].empty_b ())
70 edge[d].align_to (Y_AXIS, CENTER);
72 while (flip (&d) != LEFT);
75 Drul_array<Real> shorten;
79 SCM s = me->get_elt_property ("shorten");
82 shorten[LEFT] = gh_scm2double (gh_car (s)) * staff_space;
83 shorten[RIGHT] = gh_scm2double (gh_cdr (s)) * staff_space;
86 Real broken_left = spanner->get_broken_left_end_align ();
87 Real width = spanner->spanner_length ();
88 Score_element *bnd = spanner->get_bound (RIGHT);
89 width += bnd->extent (bnd, X_AXIS).length ();
91 width -= shorten[LEFT] + shorten[RIGHT];
92 width -= edge[LEFT].extent (X_AXIS).length ()
93 + edge[RIGHT].extent (X_AXIS).length ();
97 warning (_ ("Text_spanner too small"));
102 String type = "dashed-line";
103 s = me->get_elt_property ("type");
105 type = ly_scm2string (s);
108 Drul_array<Molecule> edge_line;
110 || type == "dashed-line"
111 || type == "dotted-line")
113 Real thick = thickness;
114 s = me->get_elt_property ("line-thickness");
116 thick *= gh_scm2double (s);
118 // maybe these should be in line-thickness?
119 Real length = staff_space;
120 s = me->get_elt_property ("dash-length");
122 length = gh_scm2double (s) * staff_space;
124 Real period = 2 * length + thick;
125 s = me->get_elt_property ("dash-period");
127 period = gh_scm2double (s) * staff_space;
129 if (type == "dotted-line")
133 length = period + thick;
135 Real on = length - thick;
136 Real off = period - on;
138 SCM list = gh_list (ly_symbol2scm ("dashed-line"),
139 gh_double2scm (thick),
142 gh_double2scm (width),
146 Box b (Interval (0, width), Interval (-thick / 2, thick / 2));
147 line = Molecule (b, list);
149 s = me->get_elt_property ("edge-height");
153 int dir = to_dir (me->get_elt_property ("direction"));
156 Real dy = gh_scm2double (index_cell (s, d)) * - dir;
159 SCM list = gh_list (ly_symbol2scm ("dashed-line"),
160 gh_double2scm (thick),
167 Box b (Interval (0, thick),
171 edge_line[d] = Molecule (b, list);
174 while (flip (&d) != LEFT);
179 if (!edge[LEFT].empty_b ())
182 if (!edge_line[LEFT].empty_b ())
183 m.add_at_edge (X_AXIS, RIGHT, edge_line[LEFT], 0);
184 if (!line.empty_b ())
185 m.add_at_edge (X_AXIS, RIGHT, line, 0);
186 if (!edge_line[RIGHT].empty_b ())
187 m.add_at_edge (X_AXIS, RIGHT, edge_line[RIGHT], 0);
188 if (!edge[RIGHT].empty_b ())
189 m.add_at_edge (X_AXIS, RIGHT, edge[RIGHT], 0);
190 m.translate_axis (broken_left, X_AXIS);
192 return m.smobbed_copy ();