lilypond-1.1.33
[lilypond.git] / lily / multi-measure-rest.cc
blob4c23334b7d2b8f8a0ca58df0c960ed402f74f599
1 /*
2 multi-measure-rest.cc -- implement Multi_measure_rest
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999, 1999 Jan Nieuwenhuizen <janneke@gnu.org>
8 */
10 #include "multi-measure-rest.hh"
11 #include "debug.hh"
12 #include "paper-def.hh"
13 #include "p-col.hh" // urg
14 #include "bar.hh"
15 #include "lookup.hh"
16 #include "rest.hh"
17 #include "script.hh"
18 #include "text-def.hh"
19 #include "molecule.hh"
20 #include "misc.hh"
23 Multi_measure_rest::Multi_measure_rest ()
25 measures_i_ = 0;
28 void
29 Multi_measure_rest::do_print () const
31 DOUT << "measures_i_ " << measures_i_;
34 Molecule*
35 Multi_measure_rest::do_brew_molecule_p () const
38 [TODO] 17
39 * variable-sized multi-measure rest symbol: |====| ??
40 * build 3, 5, 6, 7, 8 symbols (how far, property?)
41 from whole, brevis and longa rests
43 Molecule* mol_p = new Molecule;
44 if (!column_arr_.size ())
45 return mol_p;
47 Molecule s;
48 if (measures_i_ == 1 || measures_i_ == 2 || measures_i_ == 4)
50 s = (lookup_l ()->rest (- intlog2(measures_i_), 0));
51 s.translate_axis (-s.extent ()[X_AXIS].length () / 2, X_AXIS);
53 else
55 s = (lookup_l ()->rest (-4, 0));
57 mol_p->add_molecule (s);
58 Real interline_f = paper ()->interline_f ();
59 if (measures_i_ == 1)
61 mol_p->translate_axis (interline_f, Y_AXIS);
64 if (measures_i_ > 1)
66 Text_def text;
67 text.text_str_ = to_str (measures_i_);
68 text.style_str_ = "number";
69 text.align_dir_ = CENTER;
70 Molecule s = text.get_molecule (paper (), UP);
71 s.translate_axis (3.0 * interline_f, Y_AXIS);
72 mol_p->add_molecule (s);
75 return mol_p;
78 void
79 Multi_measure_rest::do_add_processing ()
81 if (column_arr_.size ())
83 set_bounds (LEFT, column_arr_[0 >? column_arr_.size () - 2]);
84 set_bounds (RIGHT, column_arr_[column_arr_.size () - 1]);
88 void
89 Multi_measure_rest::do_post_processing ()
91 if (column_arr_.size ())
92 translate_axis (extent (X_AXIS).length () / 2, X_AXIS);
95 void
96 Multi_measure_rest::do_substitute_element_pointer (Score_element* o, Score_element* n)
98 if (Item* c = dynamic_cast <Item*> (o))
99 column_arr_.substitute (c, dynamic_cast<Item*> (n));
102 void
103 Multi_measure_rest::add_column (Item* c)
105 column_arr_.push (c);
106 add_dependency (c);
110 Array<Rod>
111 Multi_measure_rest::get_rods () const
113 Array<Rod> a;
114 Rod r;
115 r.item_l_drul_ = spanned_drul_;
116 r.distance_f_ = paper ()->get_var ("mmrest_x_minimum");
117 a.push (r);
118 return a;