2 rest-grav.cc -- implement Rest_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "staff-symbol-referencer.hh"
10 #include "musical-request.hh"
12 #include "rhythmic-head.hh"
13 #include "engraver.hh"
16 class Rest_engraver : public Engraver
18 Rest_req *rest_req_l_;
22 virtual bool try_music (Music *);
23 virtual void stop_translation_timestep ();
24 virtual void start_translation_timestep ();
25 virtual void process_music ();
28 TRANSLATOR_DECLARATIONS(Rest_engraver);
33 Should merge with Note_head_engraver
35 Rest_engraver::Rest_engraver ()
43 Rest_engraver::start_translation_timestep ()
49 Rest_engraver::stop_translation_timestep ()
53 typeset_grob (rest_p_);
58 typeset_grob (dot_p_);
64 Rest_engraver::process_music ()
66 if (rest_req_l_ && !rest_p_)
68 rest_p_ = new Item (get_property ("Rest"));
72 int durlog = unsmob_duration (rest_req_l_->get_mus_property ("duration"))-> duration_log ();
74 rest_p_->set_grob_property ("duration-log",
77 int dots =unsmob_duration (rest_req_l_->get_mus_property ("duration"))->dot_count ();
81 dot_p_ = new Item (get_property ("Dots"));
83 Rhythmic_head::set_dots (rest_p_, dot_p_);
84 dot_p_->set_parent (rest_p_, Y_AXIS);
85 dot_p_->set_grob_property ("dot-count", gh_int2scm (dots));
86 announce_grob (dot_p_, SCM_EOL);
89 Pitch *p = unsmob_pitch (rest_req_l_->get_mus_property ("pitch"));
92 This is ridiculous -- rests don't have pitch, but we act as if
98 SCM c0 = get_property ("centralCPosition");
100 pos += gh_scm2int (c0);
102 rest_p_->set_grob_property ("staff-position", gh_int2scm (pos));
105 announce_grob(rest_p_, rest_req_l_->self_scm());
110 Rest_engraver::try_music (Music *m)
112 if (Rest_req *r = dynamic_cast <Rest_req *> (m))
122 ENTER_DESCRIPTION(Rest_engraver,
124 /* creats*/ "Rest Dots",
126 /* reads */ "centralCPosition",