* lily/ledger-line-engraver.cc: new file.
[lilypond.git] / lily / rest-engraver.cc
blob245da72e0038bcd58f60aad5a5d08e669c58a183
1 /*
2 rest-grav.cc -- implement Rest_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "item.hh"
9 #include "staff-symbol-referencer.hh"
10 #include "event.hh"
11 #include "dots.hh"
12 #include "rhythmic-head.hh"
13 #include "engraver.hh"
16 class Rest_engraver : public Engraver
18 Music *rest_req_;
19 Item * dot_;
20 Grob* rest_;
21 protected:
22 virtual bool try_music (Music *);
23 virtual void stop_translation_timestep ();
24 virtual void start_translation_timestep ();
25 virtual void process_music ();
27 public:
28 TRANSLATOR_DECLARATIONS (Rest_engraver);
33 Should merge with Note_head_engraver
35 Rest_engraver::Rest_engraver ()
37 rest_req_ =0;
38 rest_ =0;
39 dot_ =0;
42 void
43 Rest_engraver::start_translation_timestep ()
45 rest_req_ =0;
48 void
49 Rest_engraver::stop_translation_timestep ()
51 rest_ =0;
52 dot_ =0;
55 void
56 Rest_engraver::process_music ()
58 if (rest_req_ && !rest_)
60 rest_ = make_item ("Rest", rest_req_->self_scm ());
62 int durlog = unsmob_duration (rest_req_->get_property ("duration"))-> duration_log ();
64 rest_->set_property ("duration-log",
65 scm_int2num (durlog));
67 int dots =unsmob_duration (rest_req_->get_property ("duration"))->dot_count ();
69 if (dots)
71 dot_ = make_item ("Dots", SCM_EOL);
73 Rhythmic_head::set_dots (rest_, dot_);
74 dot_->set_parent (rest_, Y_AXIS);
75 dot_->set_property ("dot-count", scm_int2num (dots));
79 Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch"));
82 This is ridiculous -- rests don't have pitch, but we act as if
83 our nose is bleeding.
85 if (p)
87 int pos= p->steps ();
88 SCM c0 = get_property ("middleCPosition");
89 if (ly_c_number_p (c0))
90 pos += ly_scm2int (c0);
92 rest_->set_property ("staff-position", scm_int2num (pos));
98 bool
99 Rest_engraver::try_music (Music *m)
101 if (m->is_mus_type ("rest-event"))
103 rest_req_ = m;
104 return true;
106 return false;
109 ENTER_DESCRIPTION (Rest_engraver,
110 /* descr */ "",
111 /* creats*/ "Rest Dots",
112 /* accepts */ "rest-event",
113 /* acks */ "",
114 /* reads */ "middleCPosition",
115 /* write */ "");