* lily/ledger-line-engraver.cc: new file.
[lilypond.git] / lily / span-arpeggio-engraver.cc
blob50c7be72c83fc74bfb5cfab9187d6e33db0358fe
1 /*
2 span-arpeggio-engraver.cc -- implement Span_arpeggio_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
8 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 */
11 #include "engraver.hh"
12 #include "lily-guile.hh"
13 #include "item.hh"
14 #include "arpeggio.hh"
15 #include "group-interface.hh"
16 #include "side-position-interface.hh"
17 #include "staff-symbol-referencer.hh"
20 /**
21 Make arpeggios that span multiple staves. Catch arpeggios, and span a
22 Span_arpeggio over them if we find more than two arpeggios.
24 class Span_arpeggio_engraver : public Engraver
26 public:
27 TRANSLATOR_DECLARATIONS (Span_arpeggio_engraver);
29 protected:
30 virtual void acknowledge_grob (Grob_info);
31 virtual void process_acknowledged_grobs ();
32 virtual void stop_translation_timestep ();
34 private:
35 Item *span_arpeggio_;
36 Link_array<Grob> arpeggios_;
40 Span_arpeggio_engraver::Span_arpeggio_engraver ()
42 span_arpeggio_ = 0;
45 void
46 Span_arpeggio_engraver::acknowledge_grob (Grob_info info)
48 if (Arpeggio::has_interface (info.grob_)
49 && info.origin_contexts (this).size ()) // huh? what's this test for?
51 arpeggios_.push (info.grob_);
55 void
56 Span_arpeggio_engraver::process_acknowledged_grobs ()
59 connectArpeggios is slightly brusque; we should really read a grob
60 property of the caught non-span arpeggios. That way, we can have
62 both non-connected and connected arps in one pianostaff.
65 if (!span_arpeggio_ && arpeggios_.size () > 1
66 && to_boolean (get_property ("connectArpeggios")))
68 span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
73 void
74 Span_arpeggio_engraver::stop_translation_timestep ()
76 if (span_arpeggio_)
79 we do this very late, to make sure we also catch `extra'
80 side-pos support like accidentals.
82 for (int i=0; i < arpeggios_.size (); i ++)
84 for (SCM s = arpeggios_[i]->get_property ("stems");
85 ly_c_pair_p (s); s = ly_cdr (s))
86 Group_interface::add_thing (span_arpeggio_, ly_symbol2scm ("stems"), ly_car (s));
87 for (SCM s = arpeggios_[i]->get_property ("side-support-elements");
88 ly_c_pair_p (s); s = ly_cdr (s))
89 Group_interface::add_thing (span_arpeggio_, ly_symbol2scm ("side-support-elements"), ly_car (s));
92 we can't kill the children, since we don't want to the
93 previous note to bump into the span arpeggio; so we make
94 it transparent. */
95 arpeggios_[i]->set_property ("print-function", SCM_EOL);
98 span_arpeggio_ = 0;
100 arpeggios_.clear ();
105 ENTER_DESCRIPTION (Span_arpeggio_engraver,
106 /* descr */ "",
107 /* creats*/ "Arpeggio",
108 /* accepts */ "",
109 /* acks */ "arpeggio-interface",
110 /* reads */ "connectArpeggios",
111 /* write */ "");