WEB: Found more hardcoded names, yay! Fix linking to essay, images in essay.
[lilypond/patrick.git] / lily / rest-engraver.cc
blob12d1f84a2e727a7a00994334fb4199729b6ff1e1
1 /*
2 rest-engraver.cc -- implement Rest_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "engraver.hh"
11 #include "dots.hh"
12 #include "duration.hh"
13 #include "item.hh"
14 #include "pitch.hh"
15 #include "rhythmic-head.hh"
16 #include "staff-symbol-referencer.hh"
17 #include "stream-event.hh"
19 #include "translator.icc"
21 class Rest_engraver : public Engraver
23 Stream_event *rest_event_;
24 Item *dot_;
25 Grob *rest_;
26 protected:
27 void start_translation_timestep ();
28 void process_music ();
29 DECLARE_TRANSLATOR_LISTENER (rest);
30 public:
31 TRANSLATOR_DECLARATIONS (Rest_engraver);
35 Should merge with Note_head_engraver
37 Rest_engraver::Rest_engraver ()
39 rest_event_ = 0;
40 rest_ = 0;
41 dot_ = 0;
44 void
45 Rest_engraver::start_translation_timestep ()
47 rest_event_ = 0;
48 rest_ = 0;
49 dot_ = 0;
52 void
53 Rest_engraver::process_music ()
55 if (rest_event_ && !rest_)
57 rest_ = make_item ("Rest", rest_event_->self_scm ());
58 Pitch *p = unsmob_pitch (rest_event_->get_property ("pitch"));
60 if (p)
62 int pos = p->steps ();
63 SCM c0 = get_property ("middleCPosition");
64 if (scm_is_number (c0))
65 pos += scm_to_int (c0);
67 rest_->set_property ("staff-position", scm_from_int (pos));
72 IMPLEMENT_TRANSLATOR_LISTENER (Rest_engraver, rest);
73 void
74 Rest_engraver::listen_rest (Stream_event *ev)
76 ASSIGN_EVENT_ONCE (rest_event_, ev);
79 ADD_TRANSLATOR (Rest_engraver,
80 /* doc */
81 "Engrave rests.",
83 /* create */
84 "Rest ",
86 /* read */
87 "middleCPosition ",
89 /* write */