X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftuplet-engraver.cc;h=6ec076d044256679622fc8898970dea67b5f8bf5;hb=e7020dbb36a9e9c10bda48e5197213e8a3bacef6;hp=1aaa75a3c825a38b868ebb80984db09d68011bc9;hpb=94375d04f45b415ad705fd444fdb344416f116d9;p=lilypond.git diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 1aaa75a3c8..6ec076d044 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -3,13 +3,13 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2001 Han-Wen Nienhuys + (c) 1998--2004 Han-Wen Nienhuys */ -#include "command-request.hh" -#include "tuplet-spanner.hh" + +#include "tuplet-bracket.hh" #include "note-column.hh" #include "time-scaled-music.hh" #include "beam.hh" @@ -20,35 +20,35 @@ class Tuplet_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS(Tuplet_engraver); + TRANSLATOR_DECLARATIONS (Tuplet_engraver); protected: - Link_array time_scaled_music_arr_; - /// when does the scaled music stop? Array order is synced with time_scaled_music_arr_ + Link_array time_scaled_musics_; + /// when does the scaled music stop? Array order is synced with time_scaled_musics_ Array stop_moments_; - /// when does the current spanner stop? Array order is synced with time_scaled_music_arr_ + /// when does the current spanner stop? Array order is synced with time_scaled_musics_ Array span_stop_moments_; - /// The spanners. Array order is synced with time_scaled_music_arr_ - Link_array started_span_p_arr_; + /// The spanners. Array order is synced with time_scaled_musics_ + Link_array started_spanners_; virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual bool try_music (Music*r); virtual void start_translation_timestep (); - virtual void create_grobs (); + virtual void process_acknowledged_grobs (); }; bool -Tuplet_engraver::try_music (Music *r) +Tuplet_engraver::try_music (Music *c) { - if (Time_scaled_music * c = dynamic_cast (r)) + if (c->is_mus_type ("time-scaled-music")) { - Music *el = c->element (); - if (!dynamic_cast (el)) + Music *el = unsmob_music (c->get_property ("element")); + if (el && !el->is_mus_type ("event-chord")) { - time_scaled_music_arr_.push (c); - Rational m = now_mom ().main_part_ + c->length_mom ().main_part_; + time_scaled_musics_.push (c); + Rational m = now_mom ().main_part_ + c->get_length ().main_part_; stop_moments_.push (m); SCM s = get_property ("tupletSpannerDuration"); @@ -63,44 +63,40 @@ Tuplet_engraver::try_music (Music *r) } void -Tuplet_engraver::create_grobs () +Tuplet_engraver::process_acknowledged_grobs () { - SCM v = get_property ("tupletInvisible"); - if (to_boolean (v)) - return; - - for (int i= 0; i < time_scaled_music_arr_.size (); i++) + for (int i= 0; i < time_scaled_musics_.size (); i++) { - if (i < started_span_p_arr_.size () && started_span_p_arr_[i]) + if (i < started_spanners_.size () && started_spanners_[i]) continue; - Spanner* glep = new Spanner (get_property ("TupletBracket")); - Tuplet_bracket::set_interface (glep); - if (i >= started_span_p_arr_.size ()) - started_span_p_arr_.push (glep); + Spanner* glep = make_spanner ("TupletBracket"); + + if (i >= started_spanners_.size ()) + started_spanners_.push (glep); else - started_span_p_arr_[i] = glep; + started_spanners_[i] = glep; SCM proc = get_property ("tupletNumberFormatFunction"); - if (gh_procedure_p (proc)) + if (ly_c_procedure_p (proc)) { - SCM t = gh_apply (proc, scm_list_n (time_scaled_music_arr_[i]->self_scm (), SCM_UNDEFINED)); - glep->set_grob_property ("text", t); + SCM t = scm_apply_0 (proc, scm_list_n (time_scaled_musics_[i]->self_scm (), SCM_UNDEFINED)); + glep->set_property ("text", t); } - announce_grob (glep, time_scaled_music_arr_ [i]); + announce_grob (glep, time_scaled_musics_ [i]->self_scm ()); } } void Tuplet_engraver::acknowledge_grob (Grob_info i) { - if (Note_column::has_interface (i.grob_l_)) + if (Note_column::has_interface (i.grob_)) { - for (int j =0; j (i.grob_l_)); + for (int j =0; j (i.grob_)); } } @@ -114,14 +110,18 @@ Tuplet_engraver::start_translation_timestep () if (unsmob_moment (s)) tsd = unsmob_moment (s)->main_part_; - for (int i= started_span_p_arr_.size (); i--;) + for (int i= started_spanners_.size (); i--;) { if (now.main_part_ >= span_stop_moments_[i]) { - if (started_span_p_arr_[i]) + if (Spanner *sp = started_spanners_[i]) { - typeset_grob (started_span_p_arr_[i]); - started_span_p_arr_[i] =0; + if (!sp->get_bound (RIGHT)) + sp->set_bound (RIGHT, sp->get_bound (LEFT)); + + typeset_grob (sp); + + started_spanners_[i] =0; } if (tsd.to_bool ()) @@ -130,10 +130,10 @@ Tuplet_engraver::start_translation_timestep () if (now.main_part_ >= stop_moments_[i]) { - started_span_p_arr_.del (i); + started_spanners_.del (i); stop_moments_.del (i); span_stop_moments_.del (i); - time_scaled_music_arr_.del (i); + time_scaled_musics_.del (i); } } } @@ -141,20 +141,21 @@ Tuplet_engraver::start_translation_timestep () void Tuplet_engraver::finalize () { - for (int i=0; i < started_span_p_arr_.size (); i++) + for (int i=0; i < started_spanners_.size (); i++) { - if (started_span_p_arr_[i]) - typeset_grob (started_span_p_arr_[i]); + if (started_spanners_[i]) + typeset_grob (started_spanners_[i]); } } -Tuplet_engraver::Tuplet_engraver(){} +Tuplet_engraver::Tuplet_engraver (){} -ENTER_DESCRIPTION(Tuplet_engraver, +ENTER_DESCRIPTION (Tuplet_engraver, /* descr */ "Catch Time_scaled_music and generate appropriate bracket ", /* creats*/ "TupletBracket", -/* acks */ "note-column-interface", -/* reads */ "tupletNumberFormatFunction tupletSpannerDuration tupletInvisible", +/* accepts */ "time-scaled-music", +/* acks */ "note-column-interface", +/* reads */ "tupletNumberFormatFunction tupletSpannerDuration", /* write */ "");