]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-bar-engraver.cc
66b317e5b1d03eb09e3f0f988f0fd6e030fad87f
[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--2001 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 "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.
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   TRANSLATOR_DECLARATIONS(Span_bar_engraver);
33 protected:
34   virtual void acknowledge_grob (Grob_info);
35   virtual void stop_translation_timestep ();
36
37 };
38
39
40 Span_bar_engraver::Span_bar_engraver ()
41 {
42   spanbar_p_ =0;
43 }
44
45
46
47 void
48 Span_bar_engraver::acknowledge_grob (Grob_info i)
49 {
50   int depth = i.origin_trans_l_arr (this).size ();
51   if (depth > 1
52       && Bar::has_interface (i.grob_l_))
53     {
54       Item * it = dynamic_cast<Item*> (i.grob_l_);
55       bar_l_arr_.push (it);
56
57       if (bar_l_arr_.size () >= 2 && !spanbar_p_) 
58         {
59           spanbar_p_ = new Item (get_property ("SpanBar"));
60           Span_bar::set_interface (spanbar_p_);
61           spanbar_p_->set_parent (bar_l_arr_[0], X_AXIS);
62
63           announce_grob (spanbar_p_,0);
64         }
65     }
66 }
67 void
68 Span_bar_engraver::stop_translation_timestep ()
69 {
70   if (spanbar_p_) 
71     {
72       for (int i=0; i < bar_l_arr_.size () ; i++)
73         Span_bar::add_bar (spanbar_p_,bar_l_arr_[i]);
74
75       SCM vissym =ly_symbol2scm ("visibility-lambda");
76       SCM vis = bar_l_arr_[0]->get_grob_property (vissym);        
77       if (scm_equal_p (spanbar_p_->get_grob_property (vissym), vis) != SCM_BOOL_T)
78         spanbar_p_->set_grob_property (vissym, vis);
79
80       typeset_grob (spanbar_p_);
81       spanbar_p_ =0;
82     }
83   bar_l_arr_.set_size (0);
84 }
85
86
87
88
89
90
91
92 ENTER_DESCRIPTION(Span_bar_engraver,
93 /* descr */       "This engraver makes cross-staff barlines: It catches all normal
94 bar lines, and draws a single span-bar across them.",
95 /* creats*/       "SpanBar",
96 /* acks  */       "bar-line-interface",
97 /* reads */       "",
98 /* write */       "");