]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-brace-item.cc
patch::: 0.0.75.jcn6: pats
[lilypond.git] / lily / span-brace-item.cc
1 /*
2   span-brace-item.cc -- implement Span_brace_item
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7            Jan Nieuwenhuizen <jan@digicash.com>
8 */
9
10 #include "span-brace-item.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 IMPLEMENT_STATIC_NAME(Span_brace_item);
18 IMPLEMENT_IS_TYPE_B1( Span_brace_item, Item );
19
20 void
21 Span_brace_item::add( Bar* b )
22 {
23     b->spanned_i_++;
24     spanning_l_arr_.push( b );
25     add_dependency( b );
26 }
27
28 void
29 Span_brace_item::do_substitute_dependency( Score_elem* o, Score_elem* n )
30 {
31     Bar* bold = 0;
32     if ( o->is_type_b( Bar::static_name() ) ) 
33         bold = (Bar*)o->item();
34     else
35         return;
36
37     bold->spanned_i_--;
38     Bar* b = 0;
39     if ( n && n->is_type_b( Bar::static_name() ) ) {
40         b = (Bar*)n->item();
41         b->spanned_i_++;
42     }
43     
44     spanning_l_arr_.substitute( bold, b );
45 }
46
47 void
48 Span_brace_item::set( Vertical_align_element* a )
49 {
50     add_dependency( a );
51 }
52     
53
54 void
55 Span_brace_item::do_pre_processing()
56 {
57     if ( spanning_l_arr_.size () < 1 ) {
58         transparent_b_ = true;
59         empty_b_ = true;
60     } 
61     else { // 0: nobreak, 1: pre, 2: post
62         empty_b_ = ( break_status_i() != 2 );
63         transparent_b_ = ( break_status_i() != 1 );
64     }
65 }
66
67 Molecule*
68 Span_brace_item::brew_molecule_p() const
69 {
70     Interval y;
71     for ( int i = 0; i < spanning_l_arr_.size(); i++ )
72         y.unite( spanning_l_arr_[ i ]->height() );
73     // ugh, one extra staff @ 16pt
74 //    Real length_f = y.length() + spanning_l_arr_[ 0 ]->height().length();
75 //    Real length_f = y.length() + 16;
76     Real length_f = y.length() - 6;
77     Symbol s = paper()->lookup_l()->vbrace( length_f );
78     Molecule* mol_p = new Molecule( Atom ( s ) );
79 //    mol_p->translate_y( - ( length_f + 16 ) / 2 );
80     // urgh, what's wrong here?
81     mol_p->translate_y( - length_f / 2 - 6 );
82
83     return mol_p;
84 }
85