]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-bar-engraver.cc
(Paper_column): copy rank_. This fixes
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "bar-line.hh"
10 #include "item.hh"
11 #include "span-bar.hh"
12 #include "engraver.hh"
13
14 /** 
15
16   Make bars that span multiple "staves". Catch bars, and span a
17   Span_bar over them if we find more than 2 bars.  Vertical alignment
18   of staves 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.
21
22   */
23 class Span_bar_engraver : public Engraver
24 {
25   Item *spanbar_;
26   Link_array<Item> bars_;
27
28 public:
29   TRANSLATOR_DECLARATIONS (Span_bar_engraver);
30 protected:
31   virtual void acknowledge_grob (Grob_info);
32   virtual void stop_translation_timestep ();
33 };
34
35 Span_bar_engraver::Span_bar_engraver ()
36 {
37   spanbar_ = 0;
38 }
39
40 void
41 Span_bar_engraver::acknowledge_grob (Grob_info i)
42 {
43   int depth = i.origin_contexts (this).size ();
44   if (depth && Bar_line::has_interface (i.grob_))
45     {
46       Item * it = dynamic_cast<Item*> (i.grob_);
47       bars_.push (it);
48
49       if (bars_.size () >= 2 && !spanbar_) 
50         {
51           spanbar_ = make_item ("SpanBar", SCM_EOL);
52
53           spanbar_->set_parent (bars_[0], X_AXIS);
54           
55         }
56     }
57 }
58
59 void
60 Span_bar_engraver::stop_translation_timestep ()
61 {
62   if (spanbar_) 
63     {
64       for (int i= 0; i < bars_.size () ; i++)
65         Span_bar::add_bar (spanbar_,bars_[i]);
66
67       SCM vissym =ly_symbol2scm ("break-visibility");
68       SCM vis = bars_[0]->internal_get_property (vissym);         
69       if (ly_c_equal_p (spanbar_->internal_get_property (vissym), vis))
70         spanbar_->internal_set_property (vissym, vis);
71
72       
73       spanbar_ = 0;
74     }
75   bars_.set_size (0);
76 }
77
78
79 ENTER_DESCRIPTION (Span_bar_engraver,
80 /* descr */       "This engraver makes cross-staff barlines: It catches all normal "
81 "bar lines, and draws a single span-bar across them.",
82 /* creats*/       "SpanBar",
83 /* accepts */     "",
84 /* acks  */      "bar-line-interface",
85 /* reads */       "",
86 /* write */       "");