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"
18 ADD_THIS_TRANSLATOR (Tuplet_engraver);
21 Tuplet_engraver::do_try_music (Music *r)
23 if (Time_scaled_music * c = dynamic_cast<Time_scaled_music *> (r))
25 Music *el = c->element_l ();
26 if (!dynamic_cast<Request_chord*> (el))
28 time_scaled_music_arr_.push (c);
29 stop_moments_.push (now_mom () + c->length_mom ());
37 Tuplet_engraver::do_process_requests ()
40 SCM prop = get_property ("tupletDirection", 0);
44 prop = get_property ("tupletVisibility", 0);
45 if (gh_number_p(prop))
46 visibility = gh_scm2int (prop); // bool ?
48 for (int i= started_span_p_arr_.size ();
49 i < time_scaled_music_arr_.size (); i++)
51 Tuplet_spanner* glep = new Tuplet_spanner;
52 started_span_p_arr_.push (glep);
53 glep->set_elt_property ("text",
54 ly_str02scm (to_str (time_scaled_music_arr_[i]->den_i_).ch_C()));
56 glep->set_elt_property("tuplet-visibility",
57 gh_int2scm (visibility));
59 glep->set_elt_property("dir-forced", gh_int2scm (dir));
60 announce_element (Score_element_info (glep, time_scaled_music_arr_ [i]));
65 Tuplet_engraver::acknowledge_element (Score_element_info i)
67 bool grace= to_boolean (i.elem_l_->get_elt_property ("grace"));
68 SCM wg = get_property ("weAreGraceContext",0);
69 bool wgb = to_boolean (wg);
73 if (Note_column *nc = dynamic_cast<Note_column *> (i.elem_l_))
75 for (int j =0; j <started_span_p_arr_.size (); j++)
76 started_span_p_arr_[j]->add_column (nc);
78 else if (Beam *b = dynamic_cast<Beam *> (i.elem_l_))
80 for (int j = 0; j < started_span_p_arr_.size (); j++)
81 started_span_p_arr_[j]->add_beam (b);
86 Tuplet_engraver::do_post_move_processing ()
88 Moment now = now_mom ();
89 for (int i= started_span_p_arr_.size (); i--; )
91 if (now >= stop_moments_[i])
93 typeset_element (started_span_p_arr_[i]);
94 started_span_p_arr_.del (i);
96 time_scaled_music_arr_.del(i);
102 Tuplet_engraver::do_removal_processing ()
104 for (int i=0; i < started_span_p_arr_.size (); i++)
106 typeset_element (started_span_p_arr_[i]);