2 rest-engraver.cc -- implement Rest_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "staff-symbol-referencer.hh"
12 #include "rhythmic-head.hh"
13 #include "engraver.hh"
15 class Rest_engraver : public Engraver
21 virtual bool try_music (Music *);
22 virtual void stop_translation_timestep ();
23 virtual void start_translation_timestep ();
24 virtual void process_music ();
27 TRANSLATOR_DECLARATIONS (Rest_engraver);
32 Should merge with Note_head_engraver
34 Rest_engraver::Rest_engraver ()
42 Rest_engraver::start_translation_timestep ()
48 Rest_engraver::stop_translation_timestep ()
55 Rest_engraver::process_music ()
57 if (rest_req_ && !rest_)
59 rest_ = make_item ("Rest", rest_req_->self_scm ());
61 int durlog = unsmob_duration (rest_req_->get_property ("duration"))-> duration_log ();
63 rest_->set_property ("duration-log",
64 scm_int2num (durlog));
66 int dots = unsmob_duration (rest_req_->get_property ("duration"))->dot_count ();
70 dot_ = make_item ("Dots", SCM_EOL);
72 Rhythmic_head::set_dots (rest_, dot_);
73 dot_->set_parent (rest_, Y_AXIS);
74 dot_->set_property ("dot-count", scm_int2num (dots));
78 Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch"));
81 This is ridiculous -- rests don't have pitch, but we act as if
86 int pos = p->steps ();
87 SCM c0 = get_property ("middleCPosition");
88 if (scm_is_number (c0))
89 pos += scm_to_int (c0);
91 rest_->set_property ("staff-position", scm_int2num (pos));
98 Rest_engraver::try_music (Music *m)
100 if (m->is_mus_type ("rest-event"))
108 ADD_TRANSLATOR (Rest_engraver,
110 /* creats*/ "Rest Dots",
111 /* accepts */ "rest-event",
113 /* reads */ "middleCPosition",