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-spanner.hh"
13 #include "dimensions.hh"
14 #include "paper-def.hh"
16 #include "paper-column.hh"
17 #include "staff-symbol-referencer.hh"
22 type: "line", "dashed-line", "dotted-line"
24 edge-text: ("le" . "re")
31 - vertical start / vertical end (fixme-name) |
32 - contination types (vert. star, vert. end) |-> eat volta-spanner
34 - more texts/positions
38 MAKE_SCHEME_CALLBACK (Text_spanner, brew_molecule, 1);
41 Text_spanner::brew_molecule (SCM smob)
43 Score_element *me= unsmob_element (smob);
44 Spanner *spanner = dynamic_cast<Spanner*> (me);
46 Real staff_space = Staff_symbol_referencer::staff_space (me);
47 Real line = me->paper_l ()->get_var ("stafflinethickness");
50 Drul_array<bool> broken;
54 Paper_column* s = dynamic_cast<Paper_column*>(spanner->get_bound (d)); // UGH
55 broken[d] = (!s->musical_b ());
57 while (flip (&d) != LEFT);
59 SCM s = me->get_elt_property ("text-style");
60 String text_style = "italic";
62 text_style = ly_scm2string (s);
64 SCM edge_text = me->get_elt_property ("edge-text");
65 Drul_array<Molecule> edge;
66 if (gh_pair_p (edge_text))
68 edge[LEFT] = me->lookup_l ()->text (text_style,
69 ly_scm2string (gh_car (edge_text)),
71 if (!edge[LEFT].empty_b ())
72 edge[LEFT].align_to (Y_AXIS, CENTER);
73 edge[RIGHT] = me->lookup_l ()->text (text_style,
74 ly_scm2string (gh_cdr (edge_text)),
76 if (!edge[RIGHT].empty_b ())
77 edge[RIGHT].align_to (Y_AXIS, CENTER);
80 Drul_array<Real> shorten;
84 s = me->get_elt_property ("shorten");
87 shorten[LEFT] = gh_scm2double (gh_car (s)) * staff_space;
88 shorten[RIGHT] = gh_scm2double (gh_cdr (s)) * staff_space;
91 Real broken_left = spanner->get_broken_left_end_align ();
92 Real width = spanner->spanner_length ();
93 width += spanner->get_bound (RIGHT)->extent (X_AXIS).length ();
95 width -= shorten[LEFT] + shorten[RIGHT];
96 width -= edge[LEFT].extent (X_AXIS).length ()
97 + edge[RIGHT].extent (X_AXIS).length ();
101 warning (_ ("Text_spanner too small"));
106 String type = "dashed-line";
107 s = me->get_elt_property ("type");
109 type = ly_scm2string (s);
114 || type == "dashed-line"
115 || type == "dotted-line")
118 s = me->get_elt_property ("line-thickness");
120 thick *= gh_scm2double (s);
122 // maybe these should be in line-thickness?
123 Real length = staff_space;
124 s = me->get_elt_property ("dash-length");
126 length = gh_scm2double (s) * staff_space;
128 Real period = 2 * length + thick;
129 s = me->get_elt_property ("dash-period");
131 period = gh_scm2double (s) * staff_space;
133 if (type == "dotted-line")
137 length = period + thick;
139 Real on = length - thick;
140 Real off = period - on;
143 at = gh_list (ly_symbol2scm ("dashed-line"),
144 gh_double2scm (thick),
147 gh_double2scm (width),
150 Box b (Interval (0, width), Interval (-height / 2, height / 2));
151 Molecule span (b, at);
154 if (!edge[LEFT].empty_b ())
157 if (!span.empty_b ())
158 m.add_at_edge (X_AXIS, RIGHT, span, 0);
159 if (!edge[RIGHT].empty_b ())
160 m.add_at_edge (X_AXIS, RIGHT, edge[RIGHT], 0);
161 m.translate_axis (broken_left, X_AXIS);
163 return m.create_scheme ();