]> git.donarmstrong.com Git - lilypond.git/blob - lily/tuplet-spanner.cc
partial: 1.1.6.jcn
[lilypond.git] / lily / tuplet-spanner.cc
1 /*
2   plet-spanner.cc -- implement Plet_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 "p-col.hh"
15 #include "paper-def.hh"
16 #include "tuplet-spanner.hh"
17 #include "stem.hh"
18 #include "text-def.hh"
19 #include "note-column.hh"
20
21 Plet_spanner::Plet_spanner ()
22 {
23   visibility_i_ = 3;
24
25   tdef_p_.set_p(new Text_def);
26   tdef_p_->align_dir_ = CENTER;
27   tdef_p_->style_str_ = "italic";
28 }
29
30 Molecule*
31 Plet_spanner::brew_molecule_p () const
32 {
33   Molecule* mol_p = new Molecule;
34
35   if (column_arr_.size ()){
36     Real w = width ().length ();
37     Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_]
38       - column_arr_[0]->extent (Y_AXIS) [dir_];
39
40   
41     Atom num (tdef_p_->get_atom (paper (), CENTER));
42     num.translate (Offset (w/2, dy/2));
43
44     if (visibility_i_ >= 1)
45       mol_p->add_atom (num);
46
47     mol_p->add_atom (lookup_l ()->plet (dy, w, dir_));
48   }
49   return mol_p;
50 }
51   
52 void
53 Plet_spanner::do_add_processing ()
54 {
55   if (column_arr_.size ())
56     {
57       
58       set_bounds (LEFT, column_arr_[0]);
59       set_bounds (RIGHT, column_arr_.top ());  
60     }
61 }
62   
63 void
64 Plet_spanner::do_post_processing ()
65 {
66     if (column_arr_.size())
67         translate_axis (column_arr_[0]->extent (Y_AXIS)[dir_], Y_AXIS);
68 }
69
70 void
71 Plet_spanner::do_substitute_dependency (Score_element* o, Score_element* n)
72 {
73   if (Note_column *onc = dynamic_cast <Note_column *> (o))
74     column_arr_.substitute (onc, dynamic_cast<Note_column*> (n));
75 }
76   
77 void
78 Plet_spanner::set_default_dir ()
79 {
80   dir_ = UP;
81   for (int i=0; i < column_arr_.size (); i ++) 
82     {
83       if (column_arr_[i]->dir_ < 0) 
84         {
85           dir_ = DOWN;
86           break;
87         }
88     }
89 }
90
91
92 void
93 Plet_spanner::add_column (Note_column*n)
94 {
95   column_arr_.push (n);
96   add_dependency (n);
97 }
98