2 span-bar-grav.cc -- implement Span_bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "dimension-cache.hh"
10 #include "lily-guile.hh"
11 #include "span-bar.hh"
12 #include "engraver.hh"
16 Make bars that span multiple "staffs". Catch bars, and span a
17 Span_bar over them if we find more than 2 bars. Vertical alignment
18 of staffs changes the appearance of spanbars. It is up to the
19 aligner (Vertical_align_engraver, in this case, to add extra
20 dependencies to the spanbars.
23 class Span_bar_engraver : public Engraver
25 Span_bar * spanbar_p_;
26 Link_array<Bar> bar_l_arr_;
29 VIRTUAL_COPY_CONS(Translator);
32 virtual void acknowledge_element (Score_element_info);
33 virtual void do_pre_move_processing();
34 virtual Span_bar* get_span_bar_p(SCM) const;
38 Span_bar_engraver::Span_bar_engraver()
44 Span_bar_engraver::get_span_bar_p(SCM s) const
46 Span_bar * sp= new Span_bar (s);
52 Span_bar_engraver::acknowledge_element (Score_element_info i)
54 int depth = i.origin_trans_l_arr (this).size();
56 && dynamic_cast<Bar *> (i.elem_l_))
58 bar_l_arr_.push (dynamic_cast<Bar *> (i.elem_l_));
60 if (bar_l_arr_.size() >= 2 && !spanbar_p_)
62 spanbar_p_ = get_span_bar_p (get_property ("basicSpanBarProperties"));
63 spanbar_p_->set_elt_property ("glyph", bar_l_arr_[0]->get_elt_property ("glyph"));
64 spanbar_p_->set_elt_property ("visibility-lambda",
65 bar_l_arr_[0]->get_elt_property ("visibility-lambda"));
67 spanbar_p_->set_parent (bar_l_arr_[0], Y_AXIS);
68 spanbar_p_->set_parent (bar_l_arr_[0], X_AXIS);
70 announce_element (Score_element_info (spanbar_p_,0));
75 Span_bar_engraver::do_pre_move_processing()
79 for (int i=0; i < bar_l_arr_.size() ; i++)
80 spanbar_p_->add_bar (bar_l_arr_[i]);
81 typeset_element (spanbar_p_);
84 bar_l_arr_.set_size (0);
89 ADD_THIS_TRANSLATOR(Span_bar_engraver);