2 head-grav.cc -- part of GNU LilyPond
4 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 #include "rhythmic-head.hh"
9 #include "paper-def.hh"
10 #include "musical-request.hh"
12 #include "dot-column.hh"
13 #include "staff-symbol-referencer.hh"
14 #include "engraver.hh"
21 class Note_heads_engraver : public Engraver
23 Link_array<Item> note_p_arr_;
24 Link_array<Item> dot_p_arr_;
25 Link_array<Note_req> note_req_l_arr_;
28 VIRTUAL_COPY_CONS(Translator);
29 Note_heads_engraver();
32 virtual bool do_try_music (Music *req_l) ;
33 virtual void do_process_music();
34 virtual void do_pre_move_processing();
41 Note_heads_engraver::Note_heads_engraver()
46 Note_heads_engraver::do_try_music (Music *m)
48 if (Note_req * n =dynamic_cast <Note_req *> (m))
50 note_req_l_arr_.push (n);
51 note_end_mom_ = note_end_mom_ >? now_mom () + m->length_mom ();
55 else if (Tonic_req* t = dynamic_cast<Tonic_req*> (m))
59 else if (Inversion_req* i = dynamic_cast<Inversion_req*> (m))
63 else if (Bass_req* b = dynamic_cast<Bass_req*> (m))
67 else if (Busy_playing_req * p = dynamic_cast<Busy_playing_req*> (m))
69 return now_mom () < note_end_mom_;
76 Note_heads_engraver::do_process_music()
78 if (note_p_arr_.size ())
81 for (int i=0; i < note_req_l_arr_.size (); i++)
83 Item *note_p = new Item (get_property ("basicNoteHeadProperties"));
85 Staff_symbol_referencer::set_interface (note_p);
89 Note_req * note_req_l = note_req_l_arr_[i];
91 note_p->set_elt_property ("duration-log",
92 gh_int2scm (note_req_l->duration_.durlog_i_ <? 2));
94 if (note_req_l->duration_.dots_i_)
96 Item * d = new Item (get_property ("basicDotsProperties"));
98 Staff_symbol_referencer::set_interface (d);
100 Rhythmic_head::set_dots (note_p, d);
102 if (note_req_l->duration_.dots_i_
103 != gh_scm2int (d->get_elt_property ("dot-count")))
104 d->set_elt_property ("dot-count", gh_int2scm (note_req_l->duration_.dots_i_));
106 d->set_parent (note_p, Y_AXIS);
107 d->add_offset_callback (Dots::quantised_position_callback, Y_AXIS);
108 announce_element (d,0);
112 note_p->set_elt_property("staff-position", gh_int2scm (note_req_l->pitch_.steps ()));
114 announce_element (note_p,note_req_l);
115 note_p_arr_.push (note_p);
120 Note_heads_engraver::do_pre_move_processing()
122 for (int i=0; i < note_p_arr_.size (); i++)
124 typeset_element (note_p_arr_[i]);
126 note_p_arr_.clear ();
127 for (int i=0; i < dot_p_arr_.size (); i++)
129 typeset_element (dot_p_arr_[i]);
133 note_req_l_arr_.clear ();
139 ADD_THIS_TRANSLATOR(Note_heads_engraver);