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);
31 Should merge with Note_head_engraver
33 Rest_engraver::Rest_engraver ()
41 Rest_engraver::start_translation_timestep ()
47 Rest_engraver::stop_translation_timestep ()
54 Rest_engraver::process_music ()
56 if (rest_req_ && !rest_)
58 rest_ = make_item ("Rest", rest_req_->self_scm ());
60 int durlog = unsmob_duration (rest_req_->get_property ("duration"))->duration_log ();
62 rest_->set_property ("duration-log",
63 scm_int2num (durlog));
65 int dots = unsmob_duration (rest_req_->get_property ("duration"))->dot_count ();
69 dot_ = make_item ("Dots", SCM_EOL);
71 Rhythmic_head::set_dots (rest_, dot_);
72 dot_->set_parent (rest_, Y_AXIS);
73 dot_->set_property ("dot-count", scm_int2num (dots));
76 Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch"));
79 This is ridiculous -- rests don't have pitch, but we act as if
84 int pos = p->steps ();
85 SCM c0 = get_property ("middleCPosition");
86 if (scm_is_number (c0))
87 pos += scm_to_int (c0);
89 rest_->set_property ("staff-position", scm_int2num (pos));
95 Rest_engraver::try_music (Music *m)
97 if (m->is_mus_type ("rest-event"))
105 ADD_TRANSLATOR (Rest_engraver,
107 /* creats*/ "Rest Dots",
108 /* accepts */ "rest-event",
110 /* reads */ "middleCPosition",