(staff_eligible): new function.
[lilypond.git] / lily / arpeggio-engraver.cc
blobde5eb15e1c3bb559dab68e1c4ac88b40950b6560
1 /*
2 arpeggio-engraver.cc -- implement Arpeggio_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "engraver.hh"
10 #include "group-interface.hh"
11 #include "item.hh"
12 #include "event.hh"
13 #include "arpeggio.hh"
14 #include "stem.hh"
15 #include "rhythmic-head.hh"
16 #include "side-position-interface.hh"
17 #include "note-column.hh"
19 class Arpeggio_engraver : public Engraver
21 public:
22 TRANSLATOR_DECLARATIONS(Arpeggio_engraver);
23 protected:
24 virtual void acknowledge_grob (Grob_info);
25 virtual void process_music ();
27 virtual void stop_translation_timestep ();
28 virtual bool try_music (Music *);
30 private:
31 Item* arpeggio_;
32 Music *arpeggio_req_;
35 Arpeggio_engraver::Arpeggio_engraver ()
37 arpeggio_ = 0;
38 arpeggio_req_ = 0;
41 bool
42 Arpeggio_engraver::try_music (Music* m)
44 if (!arpeggio_req_)
46 arpeggio_req_ = m;
48 return true;
51 void
52 Arpeggio_engraver::acknowledge_grob (Grob_info info)
54 if (arpeggio_)
56 if (Stem::has_interface (info.grob_))
58 if (!arpeggio_->get_parent (Y_AXIS))
59 arpeggio_->set_parent (info.grob_, Y_AXIS);
61 Pointer_group_interface::add_grob (arpeggio_, ly_symbol2scm ("stems"), info.grob_);
65 We can't catch local key items (accidentals) from Voice context,
66 see Local_key_engraver
68 else if (Rhythmic_head::has_interface (info.grob_))
70 Side_position_interface::add_support (arpeggio_, info.grob_);
72 else if (Note_column::has_interface (info.grob_ ))
74 info.grob_->set_grob_property ("arpeggio", arpeggio_->self_scm ());
79 void
80 Arpeggio_engraver::process_music ()
82 if (arpeggio_req_)
84 arpeggio_ = new Item (get_property ("Arpeggio"));
85 announce_grob(arpeggio_, arpeggio_req_->self_scm());
89 void
90 Arpeggio_engraver::stop_translation_timestep ()
92 if (arpeggio_)
94 typeset_grob (arpeggio_);
95 arpeggio_ = 0;
97 arpeggio_req_ = 0;
103 ENTER_DESCRIPTION(Arpeggio_engraver,
104 /* descr */ "Generate an Arpeggio from a Arpeggio_req",
105 /* creats*/ "Arpeggio",
106 /* accepts */ "arpeggio-event",
107 /* acks */ "stem-interface rhythmic-head-interface note-column-interface",
108 /* reads */ "",
109 /* write */ "");