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"
20 #include "text-def.hh"
21 #include "pointer.tcc"
23 template class P<Text_def>; // UGH
25 Volta_spanner::Volta_spanner ()
29 number_p_.set_p (new Text_def);
30 number_p_->align_dir_ = LEFT;
34 Volta_spanner::do_brew_molecule_p () const
36 Molecule* mol_p = new Molecule;
38 if (!column_arr_.size ())
44 Real internote_f = paper_l ()->get_realvar (interline_scm_sym)/2.0;
46 Real dx = internote_f;
47 Real w = extent (X_AXIS).length () - dx;
48 Molecule volta (lookup_l ()->volta (w, last_b_));
49 Real h = volta.dim_.y ().length ();
50 Molecule num (number_p_->get_molecule (paper_l (), LEFT));
51 Real dy = column_arr_.top ()->extent (Y_AXIS) [UP] >
52 column_arr_[0]->extent (Y_AXIS) [UP];
56 UGH. Must use extent ()[dir_]
58 for (int i = 0; i < note_column_arr_.size (); i++)
59 dy = dy >? note_column_arr_[i]->extent (Y_AXIS).max ();
63 two_text.text_str_ = "2";
64 two_text.style_str_ = number_p_->style_str_;
65 Molecule two (two_text.get_molecule (paper_l (), LEFT));
66 Real gap = two.dim_.x ().length () / 2;
67 Offset off (num.dim_.x ().length () + gap,
68 h / internote_f - gap);
70 mol_p->add_molecule (volta);
71 mol_p->add_molecule (num);
72 mol_p->translate (Offset (0, dy));
77 Volta_spanner::do_add_processing ()
79 if (column_arr_.size ())
81 set_bounds (LEFT, column_arr_[0]);
82 set_bounds (RIGHT, column_arr_.top ());
85 // number_p_->style_str_ = "number-1";
86 number_p_->style_str_ = "volta";
90 Volta_spanner::do_height () const
93 in most cases, it's a lot better not no have height...
100 Volta_spanner::do_post_processing ()
102 if (column_arr_.size())
103 translate_axis (column_arr_[0]->extent (Y_AXIS)[UP], Y_AXIS);
107 Volta_spanner::do_substitute_element_pointer (Score_element* o, Score_element* n)
109 if (Note_column* c = dynamic_cast <Note_column*> (o))
110 note_column_arr_.substitute (c, dynamic_cast<Note_column*> (n));
111 else if (Bar* c = dynamic_cast <Bar*> (o))
112 column_arr_.substitute (c, dynamic_cast<Bar*> (n));
116 Volta_spanner::add_column (Bar* c)
118 column_arr_.push (c);
123 Volta_spanner::add_column (Note_column* c)
125 note_column_arr_.push (c);