]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-arpeggio-engraver.cc
(Paper_column): copy rank_. This fixes
[lilypond.git] / lily / span-arpeggio-engraver.cc
1 /*
2   span-arpeggio-engraver.cc -- implement Span_arpeggio_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7
8   Han-Wen Nienhuys <hanwen@xs4all.nl>
9 */
10
11 #include "engraver.hh"
12 #include "arpeggio.hh"
13 #include "group-interface.hh"
14 #include "side-position-interface.hh"
15 #include "staff-symbol-referencer.hh"
16
17 /** 
18   Make arpeggios that span multiple staves.  Catch arpeggios, and span a
19   Span_arpeggio over them if we find more than two arpeggios.
20   */
21 class Span_arpeggio_engraver : public Engraver
22 {
23 public:
24   TRANSLATOR_DECLARATIONS (Span_arpeggio_engraver);
25   
26 protected:
27   virtual void acknowledge_grob (Grob_info);
28   virtual void process_acknowledged_grobs ();
29   virtual void stop_translation_timestep ();
30
31 private:
32   Item *span_arpeggio_;
33   Link_array<Grob> arpeggios_;
34 };
35
36
37 Span_arpeggio_engraver::Span_arpeggio_engraver ()
38 {
39   span_arpeggio_ = 0;
40 }
41
42 void
43 Span_arpeggio_engraver::acknowledge_grob (Grob_info info)
44 {
45   if (Arpeggio::has_interface (info.grob_)
46       && info.origin_contexts (this).size ()) // huh? what's this test for? 
47     {
48       arpeggios_.push (info.grob_);
49     }
50 }
51
52 void
53 Span_arpeggio_engraver::process_acknowledged_grobs ()
54 {
55   /*
56     connectArpeggios is slightly brusque; we should really read a grob
57     property of the caught non-span arpeggios. That way, we can have
58
59     both non-connected and connected arps in one pianostaff.
60
61   */
62   if (!span_arpeggio_ && arpeggios_.size () > 1
63       && to_boolean (get_property ("connectArpeggios")))
64     {
65       span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
66             
67     }
68 }
69
70 void
71 Span_arpeggio_engraver::stop_translation_timestep ()
72 {
73   if (span_arpeggio_) 
74     {
75       /*
76         we do this very late, to make sure we also catch `extra'
77         side-pos support like accidentals.
78        */
79       for (int i= 0; i < arpeggios_.size (); i ++)
80         {
81           for (SCM s = arpeggios_[i]->get_property ("stems");
82                scm_is_pair (s); s = scm_cdr (s))
83             Group_interface::add_thing (span_arpeggio_, ly_symbol2scm ("stems"), scm_car (s));
84           for (SCM s = arpeggios_[i]->get_property ("side-support-elements");
85                scm_is_pair (s); s = scm_cdr (s))
86             Group_interface::add_thing (span_arpeggio_, ly_symbol2scm ("side-support-elements"), scm_car (s));
87
88           /*
89             we can't kill the children, since we don't want to the
90             previous note to bump into the span arpeggio; so we make
91             it transparent.  */
92           arpeggios_[i]->set_property ("print-function", SCM_EOL);
93         }
94       
95       span_arpeggio_ = 0;
96     }
97   arpeggios_.clear ();
98 }
99
100
101
102 ENTER_DESCRIPTION (Span_arpeggio_engraver,
103 /* descr */       "",
104 /* creats*/       "Arpeggio",
105 /* accepts */     "",
106 /* acks  */      "arpeggio-interface",
107 /* reads */       "connectArpeggios",
108 /* write */       "");