2 multi-measure-rest.cc -- implement Multi_measure_rest
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 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"
22 Multi_measure_rest::Multi_measure_rest ()
25 set_elt_property ("columns", SCM_EOL);
29 Multi_measure_rest::do_print () const
32 DEBUG_OUT << "measures_i_ " << measures_i_;
40 * variable-sized multi-measure rest symbol: |====| ??
42 * build 3, 5, 6, 7, 8 symbols (how far, property?)
43 from whole, brevis and longa rests
47 Multi_measure_rest::do_brew_molecule_p () const
53 Item * col = spanned_drul_[d]->column_l ();
55 Interval coldim = col->extent (X_AXIS)
56 + col->relative_coordinate (0, X_AXIS);
58 sp_iv[d] = coldim[-d] ;
60 while ((flip (&d)) != LEFT);
61 Molecule *mol_p = new Molecule;
64 Real rx = spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS);
66 we gotta stay clear of sp_iv, so move a bit to the right if
69 x_off += (sp_iv[LEFT] - rx) >? 0;
74 x_off += sp_iv.length ()/ 2;
78 bool rest_symbol=true;
79 SCM alt_symbol_sym =get_elt_property ("alt-symbol");
80 if (alt_symbol_sym != SCM_UNDEFINED)
82 s = lookup_l () -> afm_find (ly_scm2string (alt_symbol_sym));
85 else if (measures_i_ == 1 || measures_i_ == 2 || measures_i_ == 4)
87 s = lookup_l ()->afm_find ("rests-" + to_str (- intlog2(measures_i_)));
88 s.translate_axis (-s.extent ()[X_AXIS].length () / 2, X_AXIS);
92 String idx = ("rests-") + to_str (-4);
93 s = lookup_l ()->afm_find (idx);
96 mol_p->add_molecule (s);
97 Real interline_f = staff_line_leading_f ();
98 if (measures_i_ == 1 && rest_symbol)
100 mol_p->translate_axis (interline_f, Y_AXIS);
102 else if (measures_i_ > 1)
104 Molecule s (lookup_l ()->text ("number", to_str (measures_i_), paper_l ()));
105 s.align_to (X_AXIS, CENTER);
106 s.translate_axis (3.0 * interline_f, Y_AXIS);
107 mol_p->add_molecule (s);
109 mol_p->translate_axis (x_off, X_AXIS);
114 UGH. JUNKME elt prop "columns" isn't really needed.
118 Multi_measure_rest::do_add_processing ()
120 if (gh_pair_p (get_elt_property ("columns")))
122 Link_array<Item> column_arr (Group_interface__extract_elements (this, (Item*)0, "columns"));
124 set_bounds (LEFT, column_arr[0 >? column_arr.size () - 2]);
125 set_bounds (RIGHT, column_arr.top ());
130 Multi_measure_rest::do_post_processing ()
132 if (!gh_pair_p (get_elt_property ("columns")))
133 set_elt_property ("transparent", SCM_BOOL_T);
139 Multi_measure_rest::add_column (Item* c)
141 Group_interface gi (this, "columns");
150 Multi_measure_rest::get_rods () const
154 if (!(spanned_drul_[LEFT] && spanned_drul_[RIGHT]))
156 programming_error ("Multi_measure_rest::get_rods (): I am not spanned!");
160 Item * l = spanned_drul_[LEFT]->column_l ();
161 Item * r = spanned_drul_[RIGHT]->column_l ();
162 Item * lb = l->find_broken_piece (RIGHT);
163 Item * rb = r->find_broken_piece (LEFT);
165 Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}};
166 for (int i=0; i < 4; i++)
168 Item * l = combinations[i][0];
169 Item *r = combinations[i][1];
175 rod.item_l_drul_[LEFT] = l;
176 rod.item_l_drul_[RIGHT] = r;
179 should do something more advanced.
181 rod.distance_f_ = l->extent (X_AXIS)[BIGGER] - r->extent (X_AXIS)[SMALLER]
182 + paper_l ()->get_var ("mmrest_x_minimum");