]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-arpeggio-engraver.cc
Run `make grand-replace'.
[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--2008 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 "pointer-group-interface.hh"
14 #include "side-position-interface.hh"
15 #include "staff-symbol-referencer.hh"
16 #include "item.hh"
17
18 /**
19    Make arpeggios that span multiple staves.  Catch arpeggios, and span a
20    Span_arpeggio over them if we find more than two arpeggios.
21 */
22 class Span_arpeggio_engraver : public Engraver
23 {
24 public:
25   TRANSLATOR_DECLARATIONS (Span_arpeggio_engraver);
26   DECLARE_ACKNOWLEDGER (arpeggio);
27
28 protected:
29   void process_acknowledged ();
30   void stop_translation_timestep ();
31
32 private:
33   Item *span_arpeggio_;
34   vector<Grob*> arpeggios_;
35 };
36
37 Span_arpeggio_engraver::Span_arpeggio_engraver ()
38 {
39   span_arpeggio_ = 0;
40 }
41
42 void
43 Span_arpeggio_engraver::acknowledge_arpeggio (Grob_info info)
44 {
45   if (info.origin_contexts (this).size ()) // huh? what's this test for? 
46     arpeggios_.push_back (info.grob ());
47 }
48
49 void
50 Span_arpeggio_engraver::process_acknowledged ()
51 {
52   /*
53     connectArpeggios is slightly brusque; we should really read a grob
54     property of the caught non-span arpeggios. That way, we can have
55
56     both non-connected and connected arps in one pianostaff.
57
58   */
59   if (!span_arpeggio_ && arpeggios_.size () > 1
60       && to_boolean (get_property ("connectArpeggios")))
61     {
62       span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
63       span_arpeggio_->set_property ("cross-staff", SCM_BOOL_T);
64     }
65 }
66
67 void
68 Span_arpeggio_engraver::stop_translation_timestep ()
69 {
70   if (span_arpeggio_)
71     {
72       /*
73         we do this very late, to make sure we also catch `extra'
74         side-pos support like accidentals.
75       */
76       for (vsize j = 0; j < arpeggios_.size (); j++)
77         {
78           extract_grob_set (arpeggios_[j], "stems", stems);
79           for (vsize i = 0; i < stems.size (); i++)
80             Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("stems"),
81                                                stems[i]);
82
83           extract_grob_set (arpeggios_[j], "side-support-elements", sses);
84           for (vsize i = 0; i < sses.size (); i++)
85             Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("side-support-elements"),
86                                                sses[i]);
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_[j]->set_property ("transparent", SCM_BOOL_T);
93         }
94
95
96       span_arpeggio_->set_parent (arpeggios_[0]->get_parent (Y_AXIS), Y_AXIS);
97       span_arpeggio_ = 0;
98     }
99   arpeggios_.clear ();
100 }
101
102 #include "translator.icc"
103
104 ADD_ACKNOWLEDGER (Span_arpeggio_engraver, arpeggio);
105 ADD_TRANSLATOR (Span_arpeggio_engraver,
106                 /* doc */
107                 "Make arpeggios that span multiple staves.",
108
109                 /* create */
110                 "Arpeggio ",
111
112                 /* read */
113                 "connectArpeggios ",
114
115                 /* write */
116                 ""
117                 );