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"
15 #include "paper-column.hh"
17 #include "paper-def.hh"
18 #include "volta-spanner.hh"
20 #include "dimension-cache.hh"
21 #include "pointer.tcc"
23 Volta_spanner::Volta_spanner ()
26 dim_cache_ [Y_AXIS]->set_callback (dim_callback);
30 Volta_spanner::do_brew_molecule_p () const
32 Molecule* mol_p = new Molecule;
34 if (!bar_arr_.size ())
37 bool no_vertical_start = false;
38 bool no_vertical_end = last_b_;
39 Spanner *orig_span = dynamic_cast<Spanner*> (original_l_);
40 if (orig_span && (orig_span->broken_into_l_arr_[0] != (Spanner*)this))
41 no_vertical_start = true;
42 if (orig_span && (orig_span->broken_into_l_arr_.top () != (Spanner*)this))
43 no_vertical_end = true;
44 if (bar_arr_.top ()->type_str_.length_i () > 1)
45 no_vertical_end = false;
47 Real interline_f = paper_l ()->get_var ("interline");
48 Real internote_f = interline_f/2;
49 Real t = paper_l ()->get_var ("volta_thick");
51 Real dx = internote_f;
52 Real w = extent (X_AXIS).length () - dx - get_broken_left_end_align ();
53 Real h = paper_l()->get_var ("volta_spanner_height");
54 Molecule volta (lookup_l ()->volta (h, w, t, no_vertical_start, no_vertical_end));
57 Molecule num (lookup_l ()->text ("volta", number_str_, paper_l ()));
58 Real dy = bar_arr_.top ()->extent (Y_AXIS) [UP] >
59 bar_arr_[0]->extent (Y_AXIS) [UP];
62 for (int i = 0; i < note_column_arr_.size (); i++)
63 dy = dy >? note_column_arr_[i]->extent (Y_AXIS)[BIGGER];
66 Molecule two (lookup_l ()->text ("number", "2", paper_l ()));
67 Real gap = two.dim_.x ().length () / 2;
68 Offset off (num.dim_.x ().length () + gap,
69 h / internote_f - gap);
71 mol_p->add_molecule (volta);
72 mol_p->add_molecule (num);
73 mol_p->translate (Offset (0, dy));
78 Volta_spanner::do_add_processing ()
82 set_bounds (LEFT, bar_arr_[0]);
83 set_bounds (RIGHT, bar_arr_.top ());
88 Originally the following comment existed here
89 "in most cases, it's a lot better not no have height...",
90 but problems existed with collision between volta spanner
91 and above staff or lyrics for multi-staff music, so the proper
92 height is now being returned. Additional space should still
93 be added elsewhere so lyrics from above staff do not sit on
94 volta spanner. (Roy R. Rankin)
97 Volta_spanner::dim_callback (Dimension_cache const *c)
99 Volta_spanner * v = dynamic_cast<Volta_spanner*> (c->element_l ());
100 Real h = v->paper_l()->get_var ("volta_spanner_height") * 2.;
101 return Interval (0., h);
105 Volta_spanner::do_post_processing ()
108 translate_axis (bar_arr_[0]->extent (Y_AXIS)[UP], Y_AXIS);
109 translate_axis (get_broken_left_end_align (), X_AXIS);
113 Volta_spanner::do_substitute_element_pointer (Score_element* o, Score_element* n)
115 if (Note_column* c = dynamic_cast <Note_column*> (o))
116 note_column_arr_.substitute (c, dynamic_cast<Note_column*> (n));
117 else if (Bar* c = dynamic_cast <Bar*> (o))
118 bar_arr_.substitute (c, dynamic_cast<Bar*> (n));
122 Volta_spanner::add_bar (Bar* c)
129 Volta_spanner::add_column (Note_column* c)
131 note_column_arr_.push (c);