Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / rest-engraver.cc
blob8a5622ce468d1db15a8dc27d41e48b3339012d91
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2011 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"
22 #include "dots.hh"
23 #include "duration.hh"
24 #include "item.hh"
25 #include "pitch.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_;
35 Item *dot_;
36 Grob *rest_;
37 protected:
38 void start_translation_timestep ();
39 void process_music ();
40 DECLARE_TRANSLATOR_LISTENER (rest);
41 public:
42 TRANSLATOR_DECLARATIONS (Rest_engraver);
46 Should merge with Note_head_engraver
48 Rest_engraver::Rest_engraver ()
50 rest_event_ = 0;
51 rest_ = 0;
52 dot_ = 0;
55 void
56 Rest_engraver::start_translation_timestep ()
58 rest_event_ = 0;
59 rest_ = 0;
60 dot_ = 0;
63 void
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"));
71 if (p)
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);
84 void
85 Rest_engraver::listen_rest (Stream_event *ev)
87 ASSIGN_EVENT_ONCE (rest_event_, ev);
90 ADD_TRANSLATOR (Rest_engraver,
91 /* doc */
92 "Engrave rests.",
94 /* create */
95 "Rest ",
97 /* read */
98 "middleCPosition ",
100 /* write */