]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-bar-engraver.cc
release: 1.3.69
[lilypond.git] / lily / span-bar-engraver.cc
1 /*
2   span-bar-grav.cc -- implement Span_bar_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #include "lily-guile.hh"
11 #include "bar.hh"
12 #include "item.hh"
13 #include "span-bar.hh"
14 #include "engraver.hh"
15
16
17 /** 
18
19   Make bars that span multiple "staffs". Catch bars, and span a
20   Span_bar over them if we find more than 2 bars.  Vertical alignment
21   of staffs changes the appearance of spanbars.  It is up to the
22   aligner (Vertical_align_engraver, in this case, to add extra
23   dependencies to the spanbars.
24
25   */
26 class Span_bar_engraver : public Engraver
27 {
28   Item * spanbar_p_;
29   Link_array<Item> bar_l_arr_;
30
31 public:
32   VIRTUAL_COPY_CONS(Translator);
33   Span_bar_engraver();
34 protected:
35   virtual void acknowledge_element (Score_element_info);
36   virtual void do_pre_move_processing();
37
38 };
39
40
41 Span_bar_engraver::Span_bar_engraver()
42 {
43   spanbar_p_ =0;
44 }
45
46
47
48 void
49 Span_bar_engraver::acknowledge_element (Score_element_info i)
50 {
51   int depth = i.origin_trans_l_arr (this).size();
52   if (depth > 1
53       && Bar::has_interface (i.elem_l_))
54     {
55       Item * it = dynamic_cast<Item*>(i.elem_l_);
56       bar_l_arr_.push (it);
57
58       if (bar_l_arr_.size() >= 2 && !spanbar_p_) 
59         {
60           spanbar_p_ = new Item (get_property ("basicSpanBarProperties"));
61           Span_bar::set_interface (spanbar_p_);
62           spanbar_p_->set_elt_property ("glyph", bar_l_arr_[0]->get_elt_property ("glyph"));
63           spanbar_p_->set_elt_property ("visibility-lambda",
64                                         bar_l_arr_[0]->get_elt_property ("visibility-lambda"));   
65                                         
66           spanbar_p_->set_parent (bar_l_arr_[0], Y_AXIS);
67           spanbar_p_->set_parent (bar_l_arr_[0], X_AXIS);
68
69           announce_element (Score_element_info (spanbar_p_,0));
70         }
71     }
72 }
73 void
74 Span_bar_engraver::do_pre_move_processing()
75 {
76   if (spanbar_p_) 
77     {
78       for (int i=0; i < bar_l_arr_.size() ; i++)
79         Span_bar::add_bar( spanbar_p_,bar_l_arr_[i]);
80       typeset_element (spanbar_p_);
81       spanbar_p_ =0;
82     }
83   bar_l_arr_.set_size (0);
84 }
85
86
87
88 ADD_THIS_TRANSLATOR(Span_bar_engraver);
89
90
91