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