2 volta-spanner.cc -- implement Volta_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "molecule.hh"
14 #include "note-column.hh"
17 #include "paper-def.hh"
18 #include "volta-spanner.hh"
21 #include "pointer.tcc"
23 Volta_spanner::Volta_spanner ()
29 Volta_spanner::do_brew_molecule_p () const
31 Molecule* mol_p = new Molecule;
33 if (!column_arr_.size ())
36 Real interline_f = paper_l ()->get_realvar (interline_scm_sym);
37 Real internote_f = interline_f/2;
38 Real t = paper_l ()->get_realvar (volta_thick_scm_sym);
40 Real dx = internote_f;
41 Real w = extent (X_AXIS).length () - dx;
42 Molecule volta (lookup_l ()->volta (w, t, interline_f, last_b_));
43 Real h = volta.dim_.y ().length ();
45 Molecule num (lookup_l ()->text ("volta", number_str_, paper_l ()));
46 Real dy = column_arr_.top ()->extent (Y_AXIS) [UP] >
47 column_arr_[0]->extent (Y_AXIS) [UP];
50 for (int i = 0; i < note_column_arr_.size (); i++)
51 dy = dy >? note_column_arr_[i]->extent (Y_AXIS)[BIGGER];
54 Molecule two (lookup_l ()->text ("number", "2", paper_l ()));
55 Real gap = two.dim_.x ().length () / 2;
56 Offset off (num.dim_.x ().length () + gap,
57 h / internote_f - gap);
59 mol_p->add_molecule (volta);
60 mol_p->add_molecule (num);
61 mol_p->translate (Offset (0, dy));
66 Volta_spanner::do_add_processing ()
68 if (column_arr_.size ())
70 set_bounds (LEFT, column_arr_[0]);
71 set_bounds (RIGHT, column_arr_.top ());
76 Volta_spanner::do_height () const
79 in most cases, it's a lot better not no have height...
86 Volta_spanner::do_post_processing ()
88 if (column_arr_.size())
89 translate_axis (column_arr_[0]->extent (Y_AXIS)[UP], Y_AXIS);
93 Volta_spanner::do_substitute_element_pointer (Score_element* o, Score_element* n)
95 if (Note_column* c = dynamic_cast <Note_column*> (o))
96 note_column_arr_.substitute (c, dynamic_cast<Note_column*> (n));
97 else if (Bar* c = dynamic_cast <Bar*> (o))
98 column_arr_.substitute (c, dynamic_cast<Bar*> (n));
102 Volta_spanner::add_column (Bar* c)
104 column_arr_.push (c);
109 Volta_spanner::add_column (Note_column* c)
111 note_column_arr_.push (c);