]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-heads-engraver.cc
release: 1.3.0
[lilypond.git] / lily / note-heads-engraver.cc
1 /*
2   head-grav.cc -- part of GNU LilyPond
3
4   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
5 */
6
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
14 Note_heads_engraver::Note_heads_engraver()
15 {
16 }
17
18 bool
19 Note_heads_engraver::do_try_music (Music *m) 
20 {
21   if (Note_req * n =dynamic_cast <Note_req *> (m))
22     {
23       note_req_l_arr_.push (n);
24       notes_end_pq_.insert (now_mom () + m->length_mom ());
25       
26       return true;
27     }
28   else if (Tonic_req* t = dynamic_cast<Tonic_req*> (m))
29     {
30       return true;
31     }
32   else if (Busy_playing_req * p = dynamic_cast<Busy_playing_req*> (m))
33     {
34       return notes_end_pq_.size ();
35     }
36   else if (Pitch_interrogate_req *p = dynamic_cast<Pitch_interrogate_req*> (m))
37     {
38       for (int i= note_req_l_arr_.size (); i--;)
39         p->pitch_arr_.push (note_req_l_arr_[i]->pitch_); // GUH UGH UGHUGH.
40       return true;
41     }
42   return false;
43   
44 }
45
46 void
47 Note_heads_engraver::do_process_requests()
48 {
49   if (note_p_arr_.size ())
50     return ;
51   
52   SCM noteheadstyle = get_property ("noteHeadStyle", 0);
53   for (int i=0; i < note_req_l_arr_.size (); i++)
54     {
55       Note_head *note_p  = new Note_head;
56       Note_req * note_req_l = note_req_l_arr_[i];
57       note_p->balltype_i_ = note_req_l->duration_.durlog_i_;
58
59       if (note_req_l->duration_.dots_i_)
60         {
61           Dots * d = new Dots;
62           note_p->dots_l_ = d;
63           d->dots_i_ = note_req_l->duration_.dots_i_;
64
65           SCM dir = get_property ("verticalDirection",0);
66           if (isdir_b (dir))
67             {
68               d->resolve_dir_ = to_dir (dir);
69             }
70           
71           announce_element (Score_element_info (d,0));
72           dot_p_arr_.push (d);
73         }
74       note_p->position_i_  = note_req_l->pitch_.steps ();
75
76       if (gh_string_p (noteheadstyle))
77         {
78           if (ly_scm2string (noteheadstyle) == "transparent")
79             note_p->set_elt_property (transparent_scm_sym, SCM_BOOL_T);
80           else 
81             note_p->set_elt_property (style_scm_sym, noteheadstyle);
82         }
83       
84       Score_element_info itinf (note_p,note_req_l);
85       announce_element (itinf);
86       note_p_arr_.push (note_p);
87     }
88 }
89  
90 void
91 Note_heads_engraver::do_pre_move_processing()
92 {
93   for (int i=0; i < note_p_arr_.size (); i++)
94     {
95       typeset_element (note_p_arr_[i]);
96     }
97   note_p_arr_.clear ();
98   for (int i=0; i < dot_p_arr_.size (); i++)
99     {
100       typeset_element (dot_p_arr_[i]);
101     }
102   dot_p_arr_.clear ();
103   
104   note_req_l_arr_.clear ();
105 }
106
107 void
108 Note_heads_engraver::do_post_move_processing()
109 {
110   Moment n (now_mom ());
111   while (notes_end_pq_.size () && notes_end_pq_.front () <=n)
112     notes_end_pq_.get ();
113 }
114
115
116
117 ADD_THIS_TRANSLATOR(Note_heads_engraver);