]> git.donarmstrong.com Git - lilypond.git/blob - lily/volta-spanner.cc
partial: 1.1.7.jcn
[lilypond.git] / lily / volta-spanner.cc
1 /*
2   volta-spanner.cc -- implement Volta_spanner
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "atom.hh"
10 #include "box.hh"
11 #include "debug.hh"
12 #include "lookup.hh"
13 #include "molecule.hh"
14 #include "note-column.hh"
15 #include "p-col.hh"
16 #include "paper-def.hh"
17 #include "volta-spanner.hh"
18 #include "stem.hh"
19 #include "text-def.hh"
20
21 /*
22    Hmm, should probably make generic Bracket_spanner,
23    or and derive Plet and volta spanner from that.
24  */
25
26 Volta_spanner::Volta_spanner ()
27 {
28   dir_ = UP;
29   last_b_ = false;
30   tdef_p_.set_p (new Text_def);
31   tdef_p_->align_dir_ = CENTER;
32   tdef_p_->style_str_ = "nummer";
33 }
34
35 Molecule*
36 Volta_spanner::brew_molecule_p () const
37 {
38   Molecule* mol_p = new Molecule;
39
40   if (column_arr_.size ()){
41     Real w = width ().length ();
42     Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_]
43       - column_arr_[0]->extent (Y_AXIS) [dir_];
44
45     Atom num (tdef_p_->get_atom (paper (), CENTER));
46     mol_p->add_atom (num);
47     mol_p->add_atom (lookup_l ()->volta (w, last_b_));
48   }
49   return mol_p;
50 }
51   
52 void
53 Volta_spanner::do_add_processing ()
54 {
55   if (column_arr_.size ())
56     {
57       set_bounds (LEFT, column_arr_[0]);
58       set_bounds (RIGHT, column_arr_.top ());  
59     }
60 }
61   
62 void
63 Volta_spanner::do_post_processing ()
64 {
65     if (column_arr_.size())
66         translate_axis (column_arr_[0]->extent (Y_AXIS)[dir_], Y_AXIS);
67 }
68
69 void
70 Volta_spanner::do_substitute_dependency (Score_element* o, Score_element* n)
71 {
72   if (Note_column *onc = dynamic_cast <Note_column *> (o))
73     column_arr_.substitute (onc, dynamic_cast<Note_column*> (n));
74 }
75   
76 void
77 Volta_spanner::add_column (Note_column*n)
78 {
79   column_arr_.push (n);
80   add_dependency (n);
81 }
82