2 multi-measure-rest.cc -- implement Multi_measure_rest
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "multi-measure-rest.hh"
12 #include "paper-def.hh"
13 #include "paper-column.hh" // urg
16 #include "molecule.hh"
18 #include "group-interface.hh"
20 #include "staff-symbol-referencer.hh"
23 Multi_measure_rest::set_interface (Score_element*me)
25 me->set_elt_property ("columns", SCM_EOL);
30 * variable-sized multi-measure rest symbol: |====| ??
32 MAKE_SCHEME_CALLBACK(Multi_measure_rest,brew_molecule);
34 Multi_measure_rest::brew_molecule (SCM smob)
36 Score_element *me = unsmob_element (smob);
37 Spanner * sp = dynamic_cast<Spanner*> (me);
39 = Staff_symbol_referencer::staff_space (me);
45 Item * col = sp->get_bound (d)->column_l ();
47 Interval coldim = col->extent (X_AXIS)
48 + col->relative_coordinate (0, X_AXIS);
50 sp_iv[d] = coldim[-d] ;
52 while ((flip (&d)) != LEFT);
56 Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS);
58 we gotta stay clear of sp_iv, so move a bit to the right if
61 x_off += (sp_iv[LEFT] - rx) >? 0;
66 x_off += sp_iv.length ()/ 2;
72 SCM m (me->get_elt_property ("measure-count"));
75 measures = gh_scm2int (m);
79 if (measures <= me->paper_l() ->get_var ("multi_measure_rest_expand_limit"))
82 Build a rest from smaller parts. Distances inbetween are
83 really variable, see Wanske pp. 125 */
105 Real pad = s.empty_b ()
106 ? 0.0 : me->paper_l ()->get_var ("multi_measure_rest_padding");
108 Molecule r (me->lookup_l ()->afm_find ("rests-" + to_str (k)));
110 r.translate_axis (staff_space, Y_AXIS);
112 s.add_at_edge (X_AXIS, RIGHT, r, pad);
116 s.align_to (X_AXIS, CENTER);
120 String idx = ("rests-") + to_str (-4);
121 s = me->lookup_l ()->afm_find (idx);
124 mol.add_molecule (s);
128 Molecule s (me->lookup_l ()->text ("number", to_str (measures), me->paper_l ()));
129 s.align_to (X_AXIS, CENTER);
130 s.translate_axis (3.0 * staff_space, Y_AXIS);
131 mol.add_molecule (s);
133 mol.translate_axis (x_off, X_AXIS);
134 return mol.create_scheme();
138 UGH. JUNKME elt prop "columns" isn't really needed.
141 Multi_measure_rest::add_column (Score_element*me,Item* c)
143 Pointer_group_interface gi (me, "columns");
146 add_bound_item (dynamic_cast<Spanner*> (me),c);
150 MAKE_SCHEME_CALLBACK (Multi_measure_rest, set_spacing_rods);
153 Multi_measure_rest::set_spacing_rods (SCM smob)
155 Score_element*me = unsmob_element (smob);
157 Spanner*sp = dynamic_cast<Spanner*> (me);
158 if (!(sp->get_bound (LEFT) && sp->get_bound (RIGHT)))
160 programming_error ("Multi_measure_rest::get_rods (): I am not spanned!");
161 return SCM_UNDEFINED;
164 Item * l = sp->get_bound (LEFT)->column_l ();
165 Item * r = sp->get_bound (RIGHT)->column_l ();
166 Item * lb = l->find_prebroken_piece (RIGHT);
167 Item * rb = r->find_prebroken_piece (LEFT);
169 Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}};
170 for (int i=0; i < 4; i++)
172 Item * l = combinations[i][0];
173 Item *r = combinations[i][1];
179 rod.item_l_drul_[LEFT] = l;
180 rod.item_l_drul_[RIGHT] = r;
183 should do something more advanced.
185 rod.distance_f_ = l->extent (X_AXIS)[BIGGER] - r->extent (X_AXIS)[SMALLER]
186 + me->paper_l ()->get_var ("multi_measure_rest_x_minimum");
190 return SCM_UNDEFINED;