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