2 volta-spanner.cc -- implement Volta_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 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
26 Volta_spanner::Volta_spanner ()
30 number_p_.set_p (new Text_def);
31 number_p_->align_dir_ = LEFT;
32 dot_p_.set_p (new Text_def);
33 dot_p_->align_dir_ = LEFT;
37 Volta_spanner::do_brew_molecule_p () const
39 Molecule* mol_p = new Molecule;
41 if (!column_arr_.size ())
47 Real internote_f = paper ()->internote_f ();
48 Real dx = internote_f;
49 Real w = extent (X_AXIS).length () - dx;
50 Atom volta (lookup_l ()->volta (w, last_b_));
51 Real h = volta.dim_.y ().length ();
52 Atom num (number_p_->get_atom (paper (), LEFT));
53 Atom dot (dot_p_->get_atom (paper (), LEFT));
54 Real dy = column_arr_.top ()->extent (Y_AXIS) [UP] >
55 column_arr_[0]->extent (Y_AXIS) [UP];
59 UGH. Must use extent ()[dir_]
61 for (int i = 0; i < note_column_arr_.size (); i++)
62 dy = dy >? note_column_arr_[i]->extent (Y_AXIS).max ();
65 Real gap = num.dim_.x ().length () / 2;
66 Offset off (num.dim_.x ().length () + gap,
67 (h - num.dim_.y ().length ()) / internote_f - gap);
69 Real dotheight = dot.dim_.y ().length () / 7;
70 off -= Offset (0, dotheight);
72 mol_p->add_atom (volta);
73 mol_p->add_atom (num);
74 mol_p->add_atom (dot);
75 mol_p->translate (Offset (0, dy));
80 Volta_spanner::do_add_processing ()
82 if (column_arr_.size ())
84 set_bounds (LEFT, column_arr_[0]);
85 set_bounds (RIGHT, column_arr_.top ());
88 number_p_->style_str_ = "number-1";
89 dot_p_->text_str_ = ".";
90 dot_p_->style_str_ = "bold";
94 Volta_spanner::do_height () const
97 in most cases, it's a lot better not no have height...
104 Volta_spanner::do_post_processing ()
106 if (column_arr_.size())
107 translate_axis (column_arr_[0]->extent (Y_AXIS)[UP], Y_AXIS);
111 Volta_spanner::do_substitute_dependency (Score_element* o, Score_element* n)
113 if (Note_column* c = dynamic_cast <Note_column*> (o))
114 note_column_arr_.substitute (c, dynamic_cast<Note_column*> (n));
115 else if (Bar* c = dynamic_cast <Bar*> (o))
116 column_arr_.substitute (c, dynamic_cast<Bar*> (n));
120 Volta_spanner::add_column (Bar* c)
122 column_arr_.push (c);
127 Volta_spanner::add_column (Note_column* c)
129 note_column_arr_.push (c);