lilypond-1.3.31
[lilypond.git] / lily / head-grav.cc
blob5820c5fa5fdff9b379e327f7c001976ac1ff6d2b
1 /*
2 head-grav.cc -- part of GNU LilyPond
4 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
5 */
7 #include "note-head.hh"
8 #include "head-grav.hh"
9 #include "paper-def.hh"
10 #include "musical-request.hh"
11 #include "dots.hh"
13 Note_head_engraver::Note_head_engraver()
15 dot_p_=0;
16 note_p_ = 0;
17 note_req_l_ =0;
20 bool
21 Note_head_engraver::do_try_request (Request *req_l)
23 if (note_req_l_)
24 return false;
26 if (!(req_l->musical() && req_l->musical ()->note ()))
28 return false;
30 note_req_l_=req_l->musical()->rhythmic ();
31 return true;
34 void
35 Note_head_engraver::do_process_requests()
37 if (!note_req_l_ || note_p_)
38 return;
40 note_p_ = new Note_head;
41 note_p_->balltype_i_ = note_req_l_->duration_.durlog_i_;
42 note_p_->dots_i_ = note_req_l_->duration_.dots_i_;
43 if (note_p_->dots_i_)
45 dot_p_ = new Dots;
46 note_p_->dots_l_ = dot_p_;
47 announce_element (Score_elem_info (dot_p_,0));
50 note_p_->position_i_ = note_req_l_->note()->pitch_.steps ();
52 Staff_info inf = get_staff_info();
53 if (inf.c0_position_i_l_)
54 note_p_->position_i_ += *inf.c0_position_i_l_;
57 Score_elem_info itinf (note_p_,note_req_l_);
58 announce_element (itinf);
61 void
62 Note_head_engraver::do_pre_move_processing()
64 if (note_p_)
66 typeset_element (note_p_);
67 note_p_ = 0;
69 if (dot_p_)
71 typeset_element (dot_p_);
72 dot_p_ =0;
75 void
76 Note_head_engraver::do_post_move_processing()
78 note_req_l_ = 0;
82 IMPLEMENT_IS_TYPE_B1(Note_head_engraver,Engraver);
83 ADD_THIS_TRANSLATOR(Note_head_engraver);