]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-bar-engraver.cc
(LY_DEFINE): use Scheme style naming for
[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
10 #include "lily-guile.hh"
11 #include "bar-line.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_;
29   Link_array<Item> bars_;
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_ =0;
43 }
44
45
46
47 void
48 Span_bar_engraver::acknowledge_grob (Grob_info i)
49 {
50   int depth = i.origin_contexts (this).size ();
51   if (depth && Bar_line::has_interface (i.grob_))
52     {
53       Item * it = dynamic_cast<Item*> (i.grob_);
54       bars_.push (it);
55
56       if (bars_.size () >= 2 && !spanbar_) 
57         {
58           spanbar_ = make_item ("SpanBar");
59
60           spanbar_->set_parent (bars_[0], X_AXIS);
61
62           announce_grob (spanbar_, SCM_EOL);
63         }
64     }
65 }
66 void
67 Span_bar_engraver::stop_translation_timestep ()
68 {
69   if (spanbar_) 
70     {
71       for (int i=0; i < bars_.size () ; i++)
72         Span_bar::add_bar (spanbar_,bars_[i]);
73
74       SCM vissym =ly_symbol2scm ("break-visibility");
75       SCM vis = bars_[0]->internal_get_property (vissym);         
76       if (scm_equal_p (spanbar_->internal_get_property (vissym), vis) != SCM_BOOL_T)
77         spanbar_->internal_set_property (vissym, vis);
78
79       typeset_grob (spanbar_);
80       spanbar_ =0;
81     }
82   bars_.set_size (0);
83 }
84
85
86
87
88
89
90
91 ENTER_DESCRIPTION(Span_bar_engraver,
92 /* descr */       "This engraver makes cross-staff barlines: It catches all normal "
93 "bar lines, and draws a single span-bar across them.",
94 /* creats*/       "SpanBar",
95 /* accepts */     "",
96 /* acks  */      "bar-line-interface",
97 /* reads */       "",
98 /* write */       "");