]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-bar.cc
release: 0.1.61
[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--1998 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "dimen.hh"
10 #include "span-bar.hh"
11 #include "lookup.hh"
12 #include "atom.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   spanning_l_arr_.push (b);
21   add_dependency (b);
22 }
23
24
25
26 void
27 Span_bar::do_substitute_dependency (Score_elem*o, Score_elem*n)
28 {
29   spanning_l_arr_.unordered_substitute (o, n);
30 }
31
32
33 void
34 Span_bar::set (Vertical_align_element *a)
35 {
36   add_dependency (a);
37 }
38   
39
40 Interval
41 Span_bar::do_width() const
42 {
43   return paper()->lookup_l ()->bar (type_str_, 40 PT).dim_.x (); // ugh
44 }
45
46 void
47 Span_bar::do_pre_processing()
48 {
49   Bar::do_pre_processing ();
50   
51   if (spanning_l_arr_.size() < 1) 
52     {
53       transparent_b_ = true;
54       set_empty (true);   
55     }
56   if (type_str_.empty_b ()) 
57     {
58       transparent_b_=true;
59       set_empty (true);
60     }
61   else if (type_str_ == "|:") 
62     {
63       type_str_ = ".|";
64     }
65   else if (type_str_ == ":|")
66     {
67       type_str_ = "|.";
68     }
69 }
70
71 Atom
72 Span_bar::get_bar_sym (Real dy) const
73 {
74   return paper()->lookup_l ()->bar (type_str_, dy);
75 }
76
77
78 Molecule*
79 Span_bar::brew_molecule_p() const
80 {
81   Interval y_int;
82   for (int i=0; i < spanning_l_arr_.size(); i++) 
83     {
84       Axis_group_element *common = 
85         common_group (spanning_l_arr_[i], Y_AXIS);
86         
87       Real y = spanning_l_arr_[i]->relative_coordinate (common, Y_AXIS)  
88         -relative_coordinate (common,Y_AXIS);
89
90       y_int.unite (y + spanning_l_arr_[i]->height());
91     }
92
93   Atom s = get_bar_sym (y_int.length());
94   Molecule*output = new Molecule (Atom (s));
95   output->translate_axis (y_int.center(), Y_AXIS);
96   return output;
97 }
98
99
100 IMPLEMENT_IS_TYPE_B1(Span_bar,Bar);
101
102 Span_bar::Span_bar()
103 {
104   type_str_ = "";
105 }