X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fglissando-engraver.cc;h=66afed64034ed9ca01d54f9dc76bb0074d3b4971;hb=96e14d746b102f223acf6b6f4cdb8b0f0a11cd24;hp=9435968bd3127637f15a0fa16bfa558ec1c8165a;hpb=06dbc712c654888708b9feabbd0affe9ff2e4902;p=lilypond.git diff --git a/lily/glissando-engraver.cc b/lily/glissando-engraver.cc index 9435968bd3..66afed6403 100644 --- a/lily/glissando-engraver.cc +++ b/lily/glissando-engraver.cc @@ -1,36 +1,38 @@ -/* +/* note-head-line-engraver.cc -- implement Note_head_line_engraver - + source file of the GNU LilyPond music typesetter - - (c) 2000--2003 Jan Nieuwenhuizen - */ -#include "warn.hh" -#include "event.hh" -#include "spanner.hh" -#include "rhythmic-head.hh" + (c) 2000--2007 Jan Nieuwenhuizen +*/ + #include "engraver.hh" -/** - Create line-spanner grobs for glissandi lines that connect note - heads. -*/ +#include "international.hh" +#include "rhythmic-head.hh" +#include "spanner.hh" +#include "stream-event.hh" +#include "warn.hh" +#include "item.hh" + +#include "translator.icc" + class Glissando_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS(Glissando_engraver); + TRANSLATOR_DECLARATIONS (Glissando_engraver); protected: - virtual void acknowledge_grob (Grob_info); + DECLARE_TRANSLATOR_LISTENER (glissando); + DECLARE_ACKNOWLEDGER (rhythmic_head); virtual void finalize (); - virtual void stop_translation_timestep (); - virtual bool try_music (Music *); - virtual void process_music (); + + void stop_translation_timestep (); + void process_music (); private: - Spanner *line_; - Spanner *last_line_; - Music* event_; + Spanner *line_; + Spanner *last_line_; + Stream_event *event_; }; Glissando_engraver::Glissando_engraver () @@ -39,55 +41,47 @@ Glissando_engraver::Glissando_engraver () event_ = 0; } -bool -Glissando_engraver::try_music (Music* m) +IMPLEMENT_TRANSLATOR_LISTENER (Glissando_engraver, glissando); +void +Glissando_engraver::listen_glissando (Stream_event *ev) { - if (!event_) - { - event_ = m; - return true; - } - return false; + ASSIGN_EVENT_ONCE (event_, ev); } void Glissando_engraver::process_music () { if (event_) - { - last_line_ = line_; - - line_ = new Spanner (get_property ("Glissando")); - announce_grob (line_, event_->self_scm ()); - } + line_ = make_spanner ("Glissando", event_->self_scm ()); } - void -Glissando_engraver::acknowledge_grob (Grob_info info) +Glissando_engraver::acknowledge_rhythmic_head (Grob_info info) { - if (Rhythmic_head::has_interface (info.grob_)) - { - Grob * g = info.grob_; - if (line_) - line_->set_bound (LEFT, g); + Grob *g = info.grob (); + if (line_) + line_->set_bound (LEFT, g); - if (last_line_) - last_line_->set_bound (RIGHT, g); - } + if (last_line_) + { + last_line_->set_bound (RIGHT, g); + announce_end_grob (last_line_, g->self_scm ()); + } } - void Glissando_engraver::stop_translation_timestep () { if (last_line_ && last_line_->get_bound (RIGHT)) { - typeset_grob (last_line_); - last_line_ =0; + last_line_ = 0; + } + if (line_) + { + if (last_line_) + programming_error ("overwriting glissando"); + last_line_ = line_; } - - last_line_ = line_; line_ = 0; event_ = 0; } @@ -97,24 +91,29 @@ Glissando_engraver::finalize () { if (line_) { - String msg = _("Unterminated glissando."); - + string msg = _ ("unterminated glissando"); + if (event_) event_->origin ()->warning (msg); else warning (msg); - + line_->suicide (); - line_ =0; + line_ = 0; } } +ADD_ACKNOWLEDGER (Glissando_engraver, rhythmic_head); +ADD_TRANSLATOR (Glissando_engraver, + /* doc */ + "Engrave glissandi.", + + /* create */ + "Glissando ", + /* read */ + "", -ENTER_DESCRIPTION(Glissando_engraver, -/* descr */ "Engrave a glissandi", -/* creats*/ "Glissando", -/* accepts */ "glissando-event", -/* acks */ "rhythmic-head-interface", -/* reads */ "followVoice", -/* write */ ""); + /* write */ + "" + );