lilypond-0.0.32
[lilypond.git] / src / headreg.cc
blob94ad2291e19e04785b31c3e29066176f60bf2eaa
1 /*
2 headreg.cc -- part of LilyPond
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
6 #include "rest.hh"
7 #include "notehead.hh"
8 #include "headreg.hh"
9 #include "paperdef.hh"
10 #include "complexwalker.hh"
13 Notehead_register::Notehead_register(Complex_walker*w_l)
14 :Request_register(w_l)
16 note_p_ = 0;
17 set_dir(0);
20 bool
21 Notehead_register::try_request(Request *req_l)
23 if (req_l->note() || req_l->rest())
24 accepted_req_arr_.push(req_l);
25 else
26 return false;
28 return true;
30 void
31 Notehead_register::set_dir(int d)
33 dir_i_ = d;
36 void
37 Notehead_register::process_request()
39 if (!accepted_req_arr_.size())
40 return;
42 Request* req_l = accepted_req_arr_.top();
43 if (req_l->note()) {
44 Notehead*n_p = new Notehead(8); // ugh
45 note_p_ = n_p;
46 n_p->set_rhythmic(req_l->rhythmic());
47 n_p->position = req_l->note()->height() +
48 walk_l_->clef_.c0_position_i_;
49 } else {
50 note_p_ = new Rest ( req_l->rhythmic()->balltype,
51 req_l->rhythmic()->dots);
52 if (req_l->rhythmic()->balltype <= 2)
53 note_p_->translate(
54 Offset(0,
55 6 * paper()->internote()));
57 Staff_elem_info itinf(note_p_,req_l,this);
58 announce_element(itinf);
61 void
62 Notehead_register::do_pre_move_process()
64 if (note_p_) {
65 if (dir_i_ && note_p_->name() == String("Rest"))
66 note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote()));
67 typeset_element(note_p_);
68 note_p_ = 0;