]> git.donarmstrong.com Git - lilypond.git/blob - src/headreg.cc
release: 0.0.31
[lilypond.git] / src / headreg.cc
1 /*
2   headreg.cc -- part of LilyPond
3
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"
11
12
13 Notehead_register::Notehead_register(Complex_walker*w_l)
14     :Request_register(w_l)
15 {
16     note_p_ = 0;
17     set_dir(0);
18 }
19
20 bool
21 Notehead_register::try_request(Request *req_l) 
22 {
23     if (req_l->note() || req_l->rest())
24         accepted_req_arr_.push(req_l);
25     else
26         return false;
27
28     return true;
29 }
30 void
31 Notehead_register::set_dir(int d)
32 {
33     dir_i_ = d;
34 }
35
36 void
37 Notehead_register::process_request()
38 {
39     if (!accepted_req_arr_.size())
40         return;
41     
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()));
56     }
57     Staff_elem_info itinf(note_p_,req_l,this);
58     announce_element(itinf);
59 }
60
61 void
62 Notehead_register::do_pre_move_process()
63 {
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;
69     }
70 }