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
17 #include "molecule.hh"
19 #include "group-interface.hh"
21 #include "staff-symbol-referencer.hh"
23 Multi_measure_rest::Multi_measure_rest ()
25 set_elt_property ("columns", SCM_EOL);
31 * variable-sized multi-measure rest symbol: |====| ??
34 Multi_measure_rest::do_brew_molecule () const
37 = staff_symbol_referencer (this).staff_space ();
43 Item * col = spanned_drul_[d]->column_l ();
45 Interval coldim = col->extent (X_AXIS)
46 + col->relative_coordinate (0, X_AXIS);
48 sp_iv[d] = coldim[-d] ;
50 while ((flip (&d)) != LEFT);
54 Real rx = spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS);
56 we gotta stay clear of sp_iv, so move a bit to the right if
59 x_off += (sp_iv[LEFT] - rx) >? 0;
64 x_off += sp_iv.length ()/ 2;
70 SCM m (get_elt_property ("measure-count"));
73 measures = gh_scm2int (m);
77 if (measures <= paper_l() ->get_var ("multi_measure_rest_expand_limit"))
80 Build a rest from smaller parts. Distances inbetween are
81 really variable, see Wanske pp. 125 */
103 Real pad = s.empty_b ()
104 ? 0.0 : paper_l ()->get_var ("multi_measure_rest_padding");
106 Molecule r (lookup_l ()->afm_find ("rests-" + to_str (k)));
108 r.translate_axis (staff_space, Y_AXIS);
110 s.add_at_edge (X_AXIS, RIGHT, r, pad);
114 s.align_to (X_AXIS, CENTER);
118 String idx = ("rests-") + to_str (-4);
119 s = lookup_l ()->afm_find (idx);
122 mol.add_molecule (s);
126 Molecule s (lookup_l ()->text ("number", to_str (measures), paper_l ()));
127 s.align_to (X_AXIS, CENTER);
128 s.translate_axis (3.0 * staff_space, Y_AXIS);
129 mol.add_molecule (s);
131 mol.translate_axis (x_off, X_AXIS);
136 UGH. JUNKME elt prop "columns" isn't really needed.
140 Multi_measure_rest::do_add_processing ()
142 if (gh_pair_p (get_elt_property ("columns")))
144 Link_array<Item> column_arr (Group_interface__extract_elements (this, (Item*)0, "columns"));
146 set_bounds (LEFT, column_arr[0 >? column_arr.size () - 2]);
147 set_bounds (RIGHT, column_arr.top ());
150 // set columns to SCM_EOL?
154 Multi_measure_rest::do_post_processing ()
156 if (!gh_pair_p (get_elt_property ("columns")))
157 set_elt_property ("transparent", SCM_BOOL_T);
163 Multi_measure_rest::add_column (Item* c)
165 Group_interface gi (this, "columns");
174 Multi_measure_rest::get_rods () const
178 if (!(spanned_drul_[LEFT] && spanned_drul_[RIGHT]))
180 programming_error ("Multi_measure_rest::get_rods (): I am not spanned!");
184 Item * l = spanned_drul_[LEFT]->column_l ();
185 Item * r = spanned_drul_[RIGHT]->column_l ();
186 Item * lb = l->find_broken_piece (RIGHT);
187 Item * rb = r->find_broken_piece (LEFT);
189 Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}};
190 for (int i=0; i < 4; i++)
192 Item * l = combinations[i][0];
193 Item *r = combinations[i][1];
199 rod.item_l_drul_[LEFT] = l;
200 rod.item_l_drul_[RIGHT] = r;
203 should do something more advanced.
205 rod.distance_f_ = l->extent (X_AXIS)[BIGGER] - r->extent (X_AXIS)[SMALLER]
206 + paper_l ()->get_var ("multi_measure_rest_x_minimum");