X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhyphen-engraver.cc;h=20d2a7c9380d3d4cd13fbb8cbae1d2a9f98ab916;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=a9ea53054e7e4b96f356bdc95a8b9c3f411dd97e;hpb=fcc5f76615e024803904a055902fdc6a3b24dccb;p=lilypond.git diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index a9ea53054e..20d2a7c938 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--2007 Glen Prideaux , + Copyright (C) 1999--2015 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" @@ -31,8 +42,8 @@ public: protected: - DECLARE_ACKNOWLEDGER (lyric_syllable); - DECLARE_TRANSLATOR_LISTENER (hyphen); + void acknowledge_lyric_syllable (Grob_info); + void listen_hyphen (Stream_event *); virtual void finalize (); @@ -40,7 +51,8 @@ protected: void process_music (); }; -Hyphen_engraver::Hyphen_engraver () +Hyphen_engraver::Hyphen_engraver (Context *c) + : Engraver (c) { hyphen_ = 0; finished_hyphen_ = 0; @@ -52,18 +64,17 @@ 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); } -IMPLEMENT_TRANSLATOR_LISTENER (Hyphen_engraver, hyphen); void Hyphen_engraver::listen_hyphen (Stream_event *ev) { @@ -77,7 +88,7 @@ completize_hyphen (Spanner *sp) { extract_item_set (sp, "heads", heads); if (heads.size ()) - sp->set_bound (RIGHT, heads.back ()); + sp->set_bound (RIGHT, heads.back ()); } } @@ -89,10 +100,10 @@ Hyphen_engraver::finalize () completize_hyphen (hyphen_); if (!hyphen_->get_bound (RIGHT)) - { - hyphen_->warning (_ ("removing unterminated hyphen")); - hyphen_->suicide (); - } + { + hyphen_->warning (_ ("removing unterminated hyphen")); + hyphen_->suicide (); + } hyphen_ = 0; } @@ -102,11 +113,11 @@ Hyphen_engraver::finalize () completize_hyphen (finished_hyphen_); if (!finished_hyphen_->get_bound (RIGHT)) - { - if (finished_ev_) - finished_hyphen_->warning (_ ("unterminated hyphen; removing")); - finished_hyphen_->suicide (); - } + { + if (finished_ev_) + finished_hyphen_->warning (_ ("unterminated hyphen; removing")); + finished_hyphen_->suicide (); + } finished_hyphen_ = 0; } } @@ -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,24 +150,30 @@ Hyphen_engraver::stop_translation_timestep () finished_hyphen_ = hyphen_; finished_ev_ = ev_; } - + hyphen_ = 0; ev_ = 0; } -ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable); + +void +Hyphen_engraver::boot () +{ + ADD_LISTENER (Hyphen_engraver, hyphen); + ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable); +} ADD_TRANSLATOR (Hyphen_engraver, - /* doc */ - "Create lyric hyphens and distance constraints between words.", + /* doc */ + "Create lyric hyphens and distance constraints between words.", - /* create */ - "LyricHyphen " - "LyricSpace ", + /* create */ + "LyricHyphen " + "LyricSpace ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + );