2 span-bar-grav.cc -- implement Span_bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "lily-guile.hh"
13 #include "span-bar.hh"
14 #include "engraver.hh"
19 Make bars that span multiple "staves". Catch bars, and span a
20 Span_bar over them if we find more than 2 bars. Vertical alignment
21 of staves 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.
26 class Span_bar_engraver : public Engraver
29 Link_array<Item> bar_l_arr_;
32 VIRTUAL_COPY_CONS (Translator);
35 virtual void acknowledge_grob (Grob_info);
36 virtual void stop_translation_timestep ();
41 Span_bar_engraver::Span_bar_engraver ()
49 Span_bar_engraver::acknowledge_grob (Grob_info i)
51 int depth = i.origin_trans_l_arr (this).size ();
53 && Bar::has_interface (i.elem_l_))
55 Item * it = dynamic_cast<Item*> (i.elem_l_);
58 if (bar_l_arr_.size () >= 2 && !spanbar_p_)
60 spanbar_p_ = new Item (get_property ("SpanBar"));
61 Span_bar::set_interface (spanbar_p_);
62 spanbar_p_->set_parent (bar_l_arr_[0], X_AXIS);
64 announce_grob (spanbar_p_,0);
69 Span_bar_engraver::stop_translation_timestep ()
73 for (int i=0; i < bar_l_arr_.size () ; i++)
74 Span_bar::add_bar (spanbar_p_,bar_l_arr_[i]);
76 SCM vissym =ly_symbol2scm ("visibility-lambda");
77 SCM vis = bar_l_arr_[0]->get_grob_property (vissym);
78 if (scm_equal_p (spanbar_p_->get_grob_property (vissym), vis) != SCM_BOOL_T)
79 spanbar_p_->set_grob_property (vissym, vis);
81 typeset_grob (spanbar_p_);
84 bar_l_arr_.set_size (0);
89 ADD_THIS_TRANSLATOR (Span_bar_engraver);