]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-bar.cc
release: 0.0.73pre
[lilypond.git] / lily / span-bar.cc
1 /*
2   span-bar.cc -- implement Span_bar
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #include "span-bar.hh"
11 #include "lookup.hh"
12 #include "symbol.hh"
13 #include "paper-def.hh"
14 #include "molecule.hh"
15 #include "vertical-align-elem.hh"
16
17 void
18 Span_bar::add(Bar*b)
19 {
20     b->spanned_i_ ++;
21     spanning_l_arr_.push(b);
22     add_dependency( b );
23 }
24
25
26
27 void
28 Span_bar::do_substitute_dependency(Score_elem*o, Score_elem*n)
29 {
30     Bar * bold = 0;
31     if  (o->is_type_b(Bar::static_name() )) 
32         bold = (Bar*)o->item();
33     else
34         return;
35
36     bold->spanned_i_ --;
37     Bar * b =0;
38     if (n && n->is_type_b(Bar::static_name() )) {
39         b = (Bar*)n->item();
40         b->spanned_i_ ++;
41     }
42     
43     spanning_l_arr_.substitute( bold , b);
44
45 }
46
47 void
48 Span_bar::set(Vertical_align_element *a)
49 {
50     add_dependency( a );
51 }
52     
53
54 void
55 Span_bar::do_pre_processing()
56 {
57     if ( spanning_l_arr_.size () < 1) {
58         transparent_b_ = true;
59         empty_b_ =true;
60     } else {
61         type_str_ = spanning_l_arr_[0]->type_str_;
62         if (type_str_ =="") {
63             transparent_b_=true;
64             empty_b_ = true;
65         }
66     }
67 }
68
69 Molecule*
70 Span_bar::brew_molecule_p()const
71 {
72     Interval y;
73     for (int i=0; i < spanning_l_arr_.size(); i++)
74         y.unite( spanning_l_arr_[i]->height() );
75     Symbol s = paper()->lookup_l()->bar(type_str_, y.length());
76         Molecule*output = new Molecule(Atom(s));
77     output->translate_y (  y[-1] );
78
79     return output;
80 }
81
82 IMPLEMENT_STATIC_NAME(Span_bar);
83 IMPLEMENT_IS_TYPE_B1(Span_bar,Bar);