]> git.donarmstrong.com Git - lilypond.git/blob - lily/head-reg.cc
release: 0.0.64
[lilypond.git] / lily / head-reg.cc
1 /*
2   headreg.cc -- part of LilyPond
3
4   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
6
7 #include "notehead.hh"
8 #include "head-reg.hh"
9 #include "paper-def.hh"
10 #include "complex-walker.hh"
11 #include "musical-request.hh"
12
13 Notehead_register::Notehead_register()
14 {
15     note_p_ = 0;
16     post_move_processing();
17 }
18
19 bool
20 Notehead_register::try_request(Request *req_l) 
21 {
22     if (req_l->note() || req_l->rest())
23         note_req_l_=req_l->rhythmic();
24     else
25         return false;
26
27     return true;
28 }
29
30 void
31 Notehead_register::process_requests()
32 {
33     if (!note_req_l_)
34         return;
35     
36     Notehead*n_p = new Notehead(8);     // ugh
37     note_p_ = n_p;
38     n_p->set_rhythmic(note_req_l_->rhythmic());
39
40     if (note_req_l_->note()) {
41         n_p->position_i_ = note_req_l_->note()->height() +
42             *get_staff_info().c0_position_i_l_;
43     } else if (note_req_l_->rest()) {
44         n_p->rest_b_ = true;
45         if (note_req_l_->rhythmic()->duration_.type_i_ <= 2)
46             note_p_->translate(
47                 Offset(0,
48                        6 * paper()->internote()));
49     }
50     
51     Score_elem_info itinf(note_p_,note_req_l_);
52     announce_element(itinf);
53 }
54
55 void
56 Notehead_register::pre_move_processing()
57 {
58     if (note_p_) {
59         typeset_element(note_p_);
60         note_p_ = 0;
61     }
62 }
63 void
64 Notehead_register::post_move_processing()
65 {
66     note_req_l_ = 0;
67 }
68
69 IMPLEMENT_STATIC_NAME(Notehead_register);
70 ADD_THIS_REGISTER(Notehead_register);