]> git.donarmstrong.com Git - lilypond.git/blob - lily/arpeggio-engraver.cc
Web-ja: update introduction
[lilypond.git] / lily / arpeggio-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2015 Jan Nieuwenhuizen <janneke@gnu.org>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "engraver.hh"
21
22 #include "arpeggio.hh"
23 #include "item.hh"
24 #include "note-column.hh"
25 #include "pointer-group-interface.hh"
26 #include "rhythmic-head.hh"
27 #include "separation-item.hh"
28 #include "side-position-interface.hh"
29 #include "stem.hh"
30 #include "stream-event.hh"
31
32 #include "translator.icc"
33
34 class Arpeggio_engraver : public Engraver
35 {
36 public:
37   TRANSLATOR_DECLARATIONS (Arpeggio_engraver);
38
39   void acknowledge_stem (Grob_info);
40   void acknowledge_rhythmic_head (Grob_info);
41   void acknowledge_note_column (Grob_info);
42
43 protected:
44   void process_music ();
45   void stop_translation_timestep ();
46   void listen_arpeggio (Stream_event *);
47 private:
48   Item *arpeggio_;
49   Stream_event *arpeggio_event_;
50 };
51
52 Arpeggio_engraver::Arpeggio_engraver (Context *c)
53   : Engraver (c)
54 {
55   arpeggio_ = 0;
56   arpeggio_event_ = 0;
57 }
58
59 void Arpeggio_engraver::listen_arpeggio (Stream_event *ev)
60 {
61   ASSIGN_EVENT_ONCE (arpeggio_event_, ev);
62 }
63
64 void
65 Arpeggio_engraver::acknowledge_stem (Grob_info info)
66 {
67   if (arpeggio_)
68     {
69       if (!arpeggio_->get_parent (Y_AXIS))
70         arpeggio_->set_parent (info.grob (), Y_AXIS);
71
72       Pointer_group_interface::add_grob (arpeggio_,
73                                          ly_symbol2scm ("stems"),
74                                          info.grob ());
75     }
76 }
77 void
78 Arpeggio_engraver::acknowledge_rhythmic_head (Grob_info info)
79 {
80   if (arpeggio_)
81
82     /*
83       We can't catch local key items (accidentals) from Voice context,
84       see Local_key_engraver
85     */
86     Side_position_interface::add_support (arpeggio_, info.grob ());
87 }
88
89 void
90 Arpeggio_engraver::acknowledge_note_column (Grob_info info)
91 {
92   if (arpeggio_)
93     Separation_item::add_conditional_item (info.grob (), arpeggio_);
94 }
95
96 void
97 Arpeggio_engraver::process_music ()
98 {
99   if (arpeggio_event_)
100     {
101       arpeggio_ = make_item ("Arpeggio", arpeggio_event_->self_scm ());
102     }
103 }
104
105 void
106 Arpeggio_engraver::stop_translation_timestep ()
107 {
108   arpeggio_ = 0;
109   arpeggio_event_ = 0;
110 }
111
112
113 void
114 Arpeggio_engraver::boot ()
115 {
116   ADD_LISTENER (Arpeggio_engraver, arpeggio);
117   ADD_ACKNOWLEDGER (Arpeggio_engraver, stem);
118   ADD_ACKNOWLEDGER (Arpeggio_engraver, rhythmic_head);
119   ADD_ACKNOWLEDGER (Arpeggio_engraver, note_column);
120 }
121
122 ADD_TRANSLATOR (Arpeggio_engraver,
123                 /* doc */
124                 "Generate an Arpeggio symbol.",
125
126                 /* create */
127                 "Arpeggio",
128
129                 /* read */
130                 "",
131
132                 /* write */
133                 ""
134                );