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"
18 class Rest_engraver : public Engraver
24 virtual bool try_music (Music *);
25 void start_translation_timestep ();
26 void process_music ();
29 TRANSLATOR_DECLARATIONS (Rest_engraver);
33 Should merge with Note_head_engraver
35 Rest_engraver::Rest_engraver ()
43 Rest_engraver::start_translation_timestep ()
51 Rest_engraver::process_music ()
53 if (rest_event_ && !rest_)
55 rest_ = make_item ("Rest", rest_event_->self_scm ());
57 int durlog = unsmob_duration (rest_event_->get_property ("duration"))->duration_log ();
59 rest_->set_property ("duration-log",
60 scm_from_int (durlog));
62 int dots = unsmob_duration (rest_event_->get_property ("duration"))->dot_count ();
66 dot_ = make_item ("Dots", SCM_EOL);
68 Rhythmic_head::set_dots (rest_, dot_);
69 dot_->set_parent (rest_, Y_AXIS);
70 dot_->set_property ("dot-count", scm_from_int (dots));
73 Pitch *p = unsmob_pitch (rest_event_->get_property ("pitch"));
76 This is ridiculous -- rests don't have pitch, but we act as if
81 int pos = p->steps ();
82 SCM c0 = get_property ("middleCPosition");
83 if (scm_is_number (c0))
84 pos += scm_to_int (c0);
86 rest_->set_property ("staff-position", scm_from_int (pos));
92 Rest_engraver::try_music (Music *m)
94 if (m->is_mus_type ("rest-event"))
102 #include "translator.icc"
104 ADD_TRANSLATOR (Rest_engraver,
106 /* create */ "Rest Dots",
107 /* accept */ "rest-event",
108 /* read */ "middleCPosition",