]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-arpeggio-engraver.cc
5ae4d1295d5dad78283ab0b245cda19c98836d53
[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 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "engraver.hh"
10 #include "lily-guile.hh"
11 #include "item.hh"
12 #include "arpeggio.hh"
13 #include "span-arpeggio.hh"
14 #include "group-interface.hh"
15 #include "side-position-interface.hh"
16 #include "staff-symbol-referencer.hh"
17
18
19 /** 
20   Make arpeggios that span multiple staffs.  Catch arpeggios, and span a
21   Span_arpeggio over them if we find more than two arpeggios.
22   */
23 class Span_arpeggio_engraver : public Engraver
24 {
25 public:
26   VIRTUAL_COPY_CONS (Translator);
27   Span_arpeggio_engraver ();
28
29 protected:
30   virtual void acknowledge_element (Score_element_info);
31   virtual void process_acknowledged ();
32   virtual void do_pre_move_processing ();
33
34 private:
35   Item *span_arpeggio_;
36   Link_array<Score_element> arpeggios_;
37 };
38
39
40 Span_arpeggio_engraver::Span_arpeggio_engraver ()
41 {
42   span_arpeggio_ = 0;
43 }
44
45 void
46 Span_arpeggio_engraver::acknowledge_element (Score_element_info info)
47 {
48     if (info.origin_trans_l_arr (this).size ()
49         && Arpeggio::has_interface (info.elem_l_))
50     {
51       arpeggios_.push (info.elem_l_);
52     }
53 }
54
55 void
56 Span_arpeggio_engraver::process_acknowledged ()
57 {
58   /*
59     connectArpeggios is slightly brusque; we should really read a elt
60     property of the caught non-span arpeggios. That way, we can have
61
62     both non-connected and connected arps in one pianostaff.
63     
64
65   */
66   if (!span_arpeggio_ && arpeggios_.size () > 1
67       && to_boolean (get_property ("connectArpeggios")))
68     {
69       span_arpeggio_ = new Item (get_property ("Arpeggio"));
70       announce_element (span_arpeggio_, 0);      
71     }
72 }
73
74 void
75 Span_arpeggio_engraver::do_pre_move_processing ()
76 {
77   if (span_arpeggio_) 
78     {
79       /*
80         we do this very late, to make sure we also catch `extra'
81         side-pos support like accidentals.
82        */
83       for (int i=0; i < arpeggios_.size (); i ++)
84         {
85           for (SCM s = arpeggios_[i]->get_elt_property ("stems");
86                gh_pair_p (s); s = gh_cdr (s))
87             Group_interface::add_thing (span_arpeggio_, "stems", gh_car (s));
88           for (SCM s = arpeggios_[i]->get_elt_property ("side-support-elements");
89                gh_pair_p (s); s = gh_cdr (s))
90             Group_interface::add_thing (span_arpeggio_, "side-support-elements", gh_car (s));
91
92           /*
93             we can't kill the children, since we don't want to the
94             previous note to bump into the span arpeggio; so we make
95             it transparent.  */
96           arpeggios_[i]->set_elt_property ("molecule-callback", SCM_BOOL_T);
97         }
98       
99       typeset_element (span_arpeggio_);
100       span_arpeggio_ = 0;
101     }
102   arpeggios_.clear ();
103 }
104
105 ADD_THIS_TRANSLATOR (Span_arpeggio_engraver);
106