flower-1.1.4
[lilypond.git] / src / headreg.cc
blobdc5d72d572aa1ab02782c6c2965ab0348794c2fa
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 "paper-def.hh"
10 #include "complex-walker.hh"
11 #include "musicalrequest.hh"
13 Notehead_register::Notehead_register()
15 note_p_ = 0;
16 set_feature(Features::dir(0));
17 post_move_processing();
20 bool
21 Notehead_register::try_request(Request *req_l)
23 if (req_l->note() || req_l->rest())
24 note_req_l_=req_l->rhythmic();
25 else
26 return false;
28 return true;
30 void
31 Notehead_register::set_feature(Features d)
33 if(d.direction_i_ || d.initialiser_b_)
34 dir_i_ = d.direction_i_;
37 void
38 Notehead_register::process_requests()
40 if (!note_req_l_)
41 return;
44 if (note_req_l_->note()) {
45 Notehead*n_p = new Notehead(8); // ugh
46 note_p_ = n_p;
47 n_p->set_rhythmic(note_req_l_->rhythmic());
48 n_p->position = note_req_l_->note()->height() +
49 *get_staff_info().c0_position_i_;
50 } else {
51 note_p_ = new Rest ( note_req_l_->rhythmic()->balltype,
52 note_req_l_->rhythmic()->dots);
53 if (note_req_l_->rhythmic()->balltype <= 2)
54 note_p_->translate(
55 Offset(0,
56 6 * paper()->internote()));
58 Staff_elem_info itinf(note_p_,note_req_l_);
59 announce_element(itinf);
62 void
63 Notehead_register::pre_move_processing()
65 if (note_p_) {
66 if (dir_i_ && note_p_->name() == Rest::static_name())
67 note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote()));
68 typeset_element(note_p_);
69 note_p_ = 0;
72 void
73 Notehead_register::post_move_processing()
75 note_req_l_ = 0;