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>
11 #include "duration.hh"
13 #include "staff-symbol-referencer.hh"
15 #include "rhythmic-head.hh"
19 class Rest_engraver : public Engraver
25 virtual bool try_music (Music *);
26 virtual void stop_translation_timestep ();
27 virtual void start_translation_timestep ();
28 virtual void process_music ();
31 TRANSLATOR_DECLARATIONS (Rest_engraver);
35 Should merge with Note_head_engraver
37 Rest_engraver::Rest_engraver ()
45 Rest_engraver::start_translation_timestep ()
51 Rest_engraver::stop_translation_timestep ()
58 Rest_engraver::process_music ()
60 if (rest_req_ && !rest_)
62 rest_ = make_item ("Rest", rest_req_->self_scm ());
64 int durlog = unsmob_duration (rest_req_->get_property ("duration"))->duration_log ();
66 rest_->set_property ("duration-log",
67 scm_int2num (durlog));
69 int dots = unsmob_duration (rest_req_->get_property ("duration"))->dot_count ();
73 dot_ = make_item ("Dots", SCM_EOL);
75 Rhythmic_head::set_dots (rest_, dot_);
76 dot_->set_parent (rest_, Y_AXIS);
77 dot_->set_property ("dot-count", scm_int2num (dots));
80 Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch"));
83 This is ridiculous -- rests don't have pitch, but we act as if
88 int pos = p->steps ();
89 SCM c0 = get_property ("middleCPosition");
90 if (scm_is_number (c0))
91 pos += scm_to_int (c0);
93 rest_->set_property ("staff-position", scm_int2num (pos));
99 Rest_engraver::try_music (Music *m)
101 if (m->is_mus_type ("rest-event"))
109 ADD_TRANSLATOR (Rest_engraver,
111 /* creats*/ "Rest Dots",
112 /* accepts */ "rest-event",
114 /* reads */ "middleCPosition",