X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftime-signature-engraver.cc;h=1471129cd367a3a43498bcc4b8280a751c0aad29;hb=12b33a8040a80d5b4a1217faf0d4cc7529483cc0;hp=abf70356e227d8cf925ca8d4f95451110659721c;hpb=afa5829cd270e1b0c616b7ba5c5e6cdc0e920e5f;p=lilypond.git diff --git a/lily/time-signature-engraver.cc b/lily/time-signature-engraver.cc index abf70356e2..1471129cd3 100644 --- a/lily/time-signature-engraver.cc +++ b/lily/time-signature-engraver.cc @@ -1,70 +1,70 @@ /* - time_signature-reg.cc -- implement Time_signature_engraver + time-signature-engraver.cc -- implement Time_signature_engraver source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--2002 Han-Wen Nienhuys */ -#include "time-signature-engraver.hh" #include "time-signature.hh" #include "command-request.hh" -#include "timing-engraver.hh" -#include "engraver-group.hh" +#include "engraver.hh" +#include "engraver-group-engraver.hh" -Time_signature_engraver::Time_signature_engraver() +/** + generate time_signatures. + */ +class Time_signature_engraver : public Engraver +{ + Item * time_signature_p_; + SCM last_time_fraction_; + +protected: + virtual void stop_translation_timestep (); + virtual void process_music (); +public: + TRANSLATOR_DECLARATIONS(Time_signature_engraver); +}; + + +Time_signature_engraver::Time_signature_engraver () { time_signature_p_ =0; + last_time_fraction_ = SCM_BOOL_F; } void -Time_signature_engraver::do_process_requests() +Time_signature_engraver::process_music () { - Translator * result = - daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh - - if (!result) - { - warning (_ ("lost in time") + ": " + _ ("can't find") - + " Timing_translator"); - return ; - } - - Timing_engraver * timing_grav_l= dynamic_cast (result); - - Time_signature_change_req *req = timing_grav_l->time_signature_req_l(); - if (req) + /* + not rigorously safe, since the value might get GC'd and + reallocated in the same spot */ + SCM fr= get_property ("timeSignatureFraction"); + if (!time_signature_p_ && last_time_fraction_ != fr) { - Array args; - args.push (req->beats_i_); - args.push (req->one_beat_i_); - - time_signature_p_ = new Time_signature (); - time_signature_p_->args_ = args; - time_signature_p_->break_priority_i_ = 1; // ugh - } + last_time_fraction_ = fr; + time_signature_p_ = new Item (get_property ("TimeSignature")); + time_signature_p_->set_grob_property ("fraction",fr); - - if (time_signature_p_) - announce_element (Score_element_info (time_signature_p_, req)); + if (time_signature_p_) + announce_grob(time_signature_p_, SCM_EOL); + } } void -Time_signature_engraver::do_pre_move_processing() +Time_signature_engraver::stop_translation_timestep () { if (time_signature_p_) { - Scalar sigstyle = get_property ("timeSignatureStyle", 0); - if (sigstyle.length_i ()) - { - time_signature_p_->time_sig_type_str_ = sigstyle; - } - - typeset_element (time_signature_p_); + typeset_grob (time_signature_p_); time_signature_p_ =0; } } - - -ADD_THIS_TRANSLATOR(Time_signature_engraver); + +ENTER_DESCRIPTION(Time_signature_engraver, +/* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes", +/* creats*/ "TimeSignature", +/* acks */ "", +/* reads */ "", +/* write */ "");