2 auto-plet-engraver.cc -- implement Auto_plet_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "tuplet-engraver.hh"
11 #include "command-request.hh"
12 #include "tuplet-spanner.hh"
13 #include "note-column.hh"
14 #include "time-scaled-music.hh"
16 #include "music-list.hh"
19 Tuplet_engraver::do_try_music (Music *r)
21 if (Time_scaled_music * c = dynamic_cast<Time_scaled_music *> (r))
23 Music *el = c->element_l ();
24 if (!dynamic_cast<Request_chord*> (el))
26 time_scaled_music_arr_.push (c);
27 stop_moments_.push (now_mom () + c->length_mom ());
35 Tuplet_engraver::do_process_requests ()
38 SCM prop = get_property ("tupletDirection", 0);
42 prop = get_property ("tupletVisibility", 0);
43 if (gh_number_p(prop))
44 visibility = gh_scm2int (prop); // bool ?
46 for (int i= started_span_p_arr_.size ();
47 i < time_scaled_music_arr_.size (); i++)
49 Tuplet_spanner* glep = new Tuplet_spanner;
50 started_span_p_arr_.push (glep);
51 glep->set_elt_property ("text",
52 ly_str02scm (to_str (time_scaled_music_arr_[i]->den_i_).ch_C()));
54 glep->set_elt_property("tuplet-visibility",
55 gh_int2scm (visibility));
57 glep->set_elt_property("dir-forced", gh_int2scm (dir));
58 announce_element (Score_element_info (glep, time_scaled_music_arr_ [i]));
63 Tuplet_engraver::acknowledge_element (Score_element_info i)
65 bool grace= to_boolean (i.elem_l_->get_elt_property ("grace"));
66 SCM wg = get_property ("weAreGraceContext",0);
67 bool wgb = to_boolean (wg);
71 if (Note_column *nc = dynamic_cast<Note_column *> (i.elem_l_))
73 for (int j =0; j <started_span_p_arr_.size (); j++)
74 started_span_p_arr_[j]->add_column (nc);
76 else if (Beam *b = dynamic_cast<Beam *> (i.elem_l_))
78 for (int j = 0; j < started_span_p_arr_.size (); j++)
79 started_span_p_arr_[j]->add_beam (b);
84 Tuplet_engraver::do_post_move_processing ()
86 Moment now = now_mom ();
87 for (int i= started_span_p_arr_.size (); i--; )
89 if (now >= stop_moments_[i])
91 typeset_element (started_span_p_arr_[i]);
92 started_span_p_arr_.del (i);
94 time_scaled_music_arr_.del(i);
100 Tuplet_engraver::do_removal_processing ()
102 for (int i=0; i < started_span_p_arr_.size (); i++)
104 typeset_element (started_span_p_arr_[i]);
108 ADD_THIS_TRANSLATOR(Tuplet_engraver);