lilypond-1.3.19
[lilypond.git] / lily / note-heads-engraver.cc
blob0eadf768e4a375797f4f23c37b5f17352a305225
1 /*
2 head-grav.cc -- part of GNU LilyPond
4 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
5 */
7 #include "note-head.hh"
8 #include "note-heads-engraver.hh"
9 #include "paper-def.hh"
10 #include "musical-request.hh"
11 #include "dots.hh"
12 #include "dot-column.hh"
13 #include "staff-symbol-referencer.hh"
15 Note_heads_engraver::Note_heads_engraver()
19 bool
20 Note_heads_engraver::do_try_music (Music *m)
22 if (Note_req * n =dynamic_cast <Note_req *> (m))
24 note_req_l_arr_.push (n);
25 note_end_mom_ = note_end_mom_ >? now_mom () + m->length_mom ();
27 return true;
29 else if (Tonic_req* t = dynamic_cast<Tonic_req*> (m))
31 return true;
33 else if (Inversion_req* i = dynamic_cast<Inversion_req*> (m))
35 return true;
37 else if (Bass_req* b = dynamic_cast<Bass_req*> (m))
39 return true;
41 else if (Busy_playing_req * p = dynamic_cast<Busy_playing_req*> (m))
43 return now_mom () < note_end_mom_;
45 else if (Pitch_interrogate_req *p = dynamic_cast<Pitch_interrogate_req*> (m))
47 for (int i= note_req_l_arr_.size (); i--;)
48 p->pitch_arr_.push (note_req_l_arr_[i]->pitch_); // GUH UGH UGHUGH.
49 return true;
51 return false;
55 void
56 Note_heads_engraver::do_process_requests()
58 if (note_p_arr_.size ())
59 return ;
61 SCM noteheadstyle = get_property ("noteHeadStyle", 0);
62 for (int i=0; i < note_req_l_arr_.size (); i++)
64 Note_head *note_p = new Note_head;
66 Staff_symbol_referencer_interface si (note_p);
67 si.set_interface ();
70 Note_req * note_req_l = note_req_l_arr_[i];
72 note_p->set_elt_property ("duration-log",
73 gh_int2scm (note_req_l->duration_.durlog_i_ <? 2));
75 if (note_req_l->duration_.dots_i_)
77 Dots * d = new Dots;
79 Staff_symbol_referencer_interface sd (d);
80 sd.set_interface ();
82 note_p->add_dots (d);
83 d->set_elt_property ("dot-count", gh_int2scm (note_req_l->duration_.dots_i_));
84 announce_element (Score_element_info (d,0));
85 dot_p_arr_.push (d);
87 si.set_position(note_req_l->pitch_.steps ());
90 TODO: transparent note heads.
93 if (gh_string_p (noteheadstyle))
95 note_p->set_elt_property ("style", noteheadstyle);
98 Score_element_info itinf (note_p,note_req_l);
99 announce_element (itinf);
100 note_p_arr_.push (note_p);
104 void
105 Note_heads_engraver::do_pre_move_processing()
107 for (int i=0; i < note_p_arr_.size (); i++)
109 typeset_element (note_p_arr_[i]);
111 note_p_arr_.clear ();
112 for (int i=0; i < dot_p_arr_.size (); i++)
114 typeset_element (dot_p_arr_[i]);
116 dot_p_arr_.clear ();
118 note_req_l_arr_.clear ();
124 ADD_THIS_TRANSLATOR(Note_heads_engraver);