]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-bar.cc
release: 0.0.76
[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 #include "dimen.hh"
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   A no-op if not yet output: the span_bar slavish follows what it spans
48  */
49 void
50 Span_bar::translate_y(Real y)
51 {
52     if (status() == OUTPUT)
53         Score_elem::translate_y(y);
54 }
55
56 void
57 Span_bar::set(Vertical_align_element *a)
58 {
59     add_dependency( a );
60 }
61     
62
63 Interval
64 Span_bar::do_width() const
65 {
66     return paper()->lookup_l()->bar(type_str_, 40 PT).dim.x; // ugh
67 }
68 void
69 Span_bar::do_pre_processing()
70 {
71     if ( spanning_l_arr_.size () < 1) {
72         transparent_b_ = true;
73         empty_b_ =true;
74     } else {
75         if  (type_str_ == "")
76             type_str_ = spanning_l_arr_[0]->type_str_;
77         if (type_str_ =="") {
78             transparent_b_=true;
79             empty_b_ = true;
80         }
81     }
82 }
83
84 Symbol
85 Span_bar::get_bar_sym(Real dy) const
86 {
87     return paper()->lookup_l()->bar(type_str_, dy);
88 }
89
90 Molecule*
91 Span_bar::brew_molecule_p()const
92 {
93     Interval y;
94     for (int i=0; i < spanning_l_arr_.size(); i++)
95         y.unite( spanning_l_arr_[i]->height() );
96     Symbol s = get_bar_sym(y.length());
97         Molecule*output = new Molecule(Atom(s));
98     output->translate_y (  y[-1] );
99
100     return output;
101 }
102
103 IMPLEMENT_STATIC_NAME(Span_bar);
104 IMPLEMENT_IS_TYPE_B1(Span_bar,Bar);