]> git.donarmstrong.com Git - lilypond.git/blob - lily/arpeggio-engraver.cc
* configure.in: Test for and accept lmodern if EC fonts not found.
[lilypond.git] / lily / arpeggio-engraver.cc
1 /*   
2   arpeggio-engraver.cc -- implement Arpeggio_engraver
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7  */
8
9 #include "engraver.hh"
10 #include "group-interface.hh"
11 #include "arpeggio.hh"
12 #include "stem.hh"
13 #include "rhythmic-head.hh"
14 #include "side-position-interface.hh"
15 #include "note-column.hh"
16
17 class Arpeggio_engraver : public Engraver
18 {
19 public:
20   TRANSLATOR_DECLARATIONS (Arpeggio_engraver); 
21 protected:
22   virtual void acknowledge_grob (Grob_info);
23   virtual void process_music ();
24
25   virtual void stop_translation_timestep ();
26   virtual bool try_music (Music *);
27
28 private:
29   Item* arpeggio_; 
30   Music *arpeggio_req_;
31 };
32
33 Arpeggio_engraver::Arpeggio_engraver ()
34 {
35   arpeggio_ = 0;
36   arpeggio_req_ = 0;
37 }
38
39 bool
40 Arpeggio_engraver::try_music (Music* m)
41 {
42   if (!arpeggio_req_)
43     {
44       arpeggio_req_ = m;
45     }
46   return true;
47 }
48
49 void
50 Arpeggio_engraver::acknowledge_grob (Grob_info info)
51 {
52   if (arpeggio_)
53     {
54       if (Stem::has_interface (info.grob_))
55         {
56           if (!arpeggio_->get_parent  (Y_AXIS))
57             arpeggio_->set_parent (info.grob_, Y_AXIS);
58       
59           Pointer_group_interface::add_grob (arpeggio_, ly_symbol2scm ("stems"), info.grob_);
60         }
61       
62       /*
63         We can't catch local key items (accidentals) from Voice context,
64         see Local_key_engraver
65       */
66       else if (Rhythmic_head::has_interface (info.grob_))
67         {
68           Side_position_interface::add_support (arpeggio_, info.grob_);
69         }
70       else if (Note_column::has_interface (info.grob_ ))
71         {
72           info.grob_->set_property ("arpeggio", arpeggio_->self_scm ());
73         }
74     }
75 }
76
77 void
78 Arpeggio_engraver::process_music ()
79 {
80   if (arpeggio_req_)
81     {
82       arpeggio_ = make_item ("Arpeggio",arpeggio_req_->self_scm ());
83     }
84 }
85
86 void
87 Arpeggio_engraver::stop_translation_timestep ()
88 {
89   arpeggio_ = 0;
90   arpeggio_req_ = 0;
91 }
92
93
94
95
96 ENTER_DESCRIPTION (Arpeggio_engraver,
97 /* descr */       "Generate an Arpeggio from a Arpeggio_req",
98 /* creats*/       "Arpeggio",
99 /* accepts */     "arpeggio-event",
100 /* acks  */       "stem-interface rhythmic-head-interface note-column-interface",
101 /* reads */       "",
102 /* write */       "");