X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhyphen-engraver.cc;h=55696e93159309020de7d28f640fabbafee2ff3d;hb=1c72394c0ae30ba289f869059ec2532eac8d4015;hp=e4f4f3a9918656e9923eabfcb711f44a0e45eecb;hpb=9f3572d98bb948c9689cd1f75401a029451fa001;p=lilypond.git diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index e4f4f3a991..55696e9315 100644 --- a/lily/hyphen-engraver.cc +++ b/lily/hyphen-engraver.cc @@ -1,11 +1,22 @@ /* - hyphen-engraver.cc -- implement Hyphen_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter - - (c) 1999--2006 Glen Prideaux , + Copyright (C) 1999--2011 Glen Prideaux , Han-Wen Nienhuys , Jan Nieuwenhuizen + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "engraver.hh" @@ -13,12 +24,15 @@ #include "item.hh" #include "pointer-group-interface.hh" #include "spanner.hh" +#include "stream-event.hh" #include "warn.hh" +#include "translator.icc" + class Hyphen_engraver : public Engraver { - Music *ev_; - Music *finished_ev_; + Stream_event *ev_; + Stream_event *finished_ev_; Spanner *hyphen_; Spanner *finished_hyphen_; @@ -29,9 +43,9 @@ public: protected: DECLARE_ACKNOWLEDGER (lyric_syllable); + DECLARE_TRANSLATOR_LISTENER (hyphen); virtual void finalize (); - virtual bool try_music (Music *); void stop_translation_timestep (); void process_music (); @@ -49,25 +63,22 @@ void Hyphen_engraver::acknowledge_lyric_syllable (Grob_info i) { Item *item = i.item (); - + if (!hyphen_) hyphen_ = make_spanner ("LyricSpace", item->self_scm ()); if (hyphen_) hyphen_->set_bound (LEFT, item); - + if (finished_hyphen_) finished_hyphen_->set_bound (RIGHT, item); } -bool -Hyphen_engraver::try_music (Music *r) +IMPLEMENT_TRANSLATOR_LISTENER (Hyphen_engraver, hyphen); +void +Hyphen_engraver::listen_hyphen (Stream_event *ev) { - if (ev_) - return false; - - ev_ = r; - return true; + ASSIGN_EVENT_ONCE (ev_, ev); } void @@ -126,7 +137,7 @@ Hyphen_engraver::stop_translation_timestep () finished_hyphen_ = 0; finished_ev_ = 0; } - + if (finished_hyphen_ && hyphen_) { programming_error ("hyphen not finished yet"); @@ -139,19 +150,24 @@ Hyphen_engraver::stop_translation_timestep () finished_hyphen_ = hyphen_; finished_ev_ = ev_; } - + hyphen_ = 0; ev_ = 0; } -#include "translator.icc" - ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable); ADD_TRANSLATOR (Hyphen_engraver, - /* doc */ "Create lyric hyphens and " - "distance constraints between words.", - /* create */ "LyricHyphen LyricSpace", - /* accept */ "hyphen-event", - /* read */ "", - /* write */ ""); + /* doc */ + "Create lyric hyphens and distance constraints between words.", + + /* create */ + "LyricHyphen " + "LyricSpace ", + + /* read */ + "", + + /* write */ + "" + );