lilypond-0.1.59
[lilypond.git] / lily / span-bar.cc
bloba371dc019d312527a0ccf65250ea5acfeedeeb57
1 /*
2 span-bar.cc -- implement Span_bar
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
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"
17 void
18 Span_bar::add (Bar*b)
20 spanning_l_arr_.push (b);
21 add_dependency (b);
26 void
27 Span_bar::do_substitute_dependency (Score_elem*o, Score_elem*n)
29 spanning_l_arr_.unordered_substitute (o, n);
33 void
34 Span_bar::set (Vertical_align_element *a)
36 add_dependency (a);
40 Interval
41 Span_bar::do_width() const
43 return paper()->lookup_l ()->bar (type_str_, 40 PT).dim_.x (); // ugh
46 void
47 Span_bar::do_pre_processing()
49 Bar::do_pre_processing ();
51 if (spanning_l_arr_.size() < 1)
53 transparent_b_ = true;
54 set_empty (true);
56 if (type_str_.empty_b ())
58 transparent_b_=true;
59 set_empty (true);
61 else if (type_str_ == "|:")
63 type_str_ = ".|";
65 else if (type_str_ == ":|")
67 type_str_ = "|.";
71 Atom
72 Span_bar::get_bar_sym (Real dy) const
74 return paper()->lookup_l ()->bar (type_str_, dy);
78 Molecule*
79 Span_bar::brew_molecule_p() const
81 Interval y_int;
82 for (int i=0; i < spanning_l_arr_.size(); i++)
84 Axis_group_element *common =
85 common_group (spanning_l_arr_[i], Y_AXIS);
87 Real y = spanning_l_arr_[i]->relative_coordinate (common, Y_AXIS)
88 -relative_coordinate (common,Y_AXIS);
90 y_int.unite (y + spanning_l_arr_[i]->height());
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;
100 IMPLEMENT_IS_TYPE_B1(Span_bar,Bar);
102 Span_bar::Span_bar()
104 type_str_ = "";