2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "engraver.hh"
23 #include "duration.hh"
26 #include "rhythmic-head.hh"
27 #include "staff-symbol-referencer.hh"
28 #include "stream-event.hh"
30 #include "translator.icc"
32 class Rest_engraver : public Engraver
34 Stream_event *rest_event_;
38 void start_translation_timestep ();
39 void process_music ();
40 DECLARE_TRANSLATOR_LISTENER (rest);
42 TRANSLATOR_DECLARATIONS (Rest_engraver);
46 Should merge with Note_head_engraver
48 Rest_engraver::Rest_engraver ()
56 Rest_engraver::start_translation_timestep ()
64 Rest_engraver::process_music ()
66 if (rest_event_ && !rest_)
68 rest_ = make_item ("Rest", rest_event_->self_scm ());
69 Pitch *p = unsmob_pitch (rest_event_->get_property ("pitch"));
73 int pos = p->steps ();
74 SCM c0 = get_property ("middleCPosition");
75 if (scm_is_number (c0))
76 pos += scm_to_int (c0);
78 rest_->set_property ("staff-position", scm_from_int (pos));
83 IMPLEMENT_TRANSLATOR_LISTENER (Rest_engraver, rest);
85 Rest_engraver::listen_rest (Stream_event *ev)
87 ASSIGN_EVENT_ONCE (rest_event_, ev);
90 ADD_TRANSLATOR (Rest_engraver,