X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftext-spanner-engraver.cc;h=b9c7b75fb94589b62f3d5bf9b421fdb0de19d2cf;hb=67ff565b4ada90eeb753a866b22ddb4eaa8c6234;hp=731488e3134c3f98f9faabc0c303c0b77ce76887;hpb=108cf0e8c08c8e15e2a800feb161cfad9057daa8;p=lilypond.git diff --git a/lily/text-spanner-engraver.cc b/lily/text-spanner-engraver.cc index 731488e313..b9c7b75fb9 100644 --- a/lily/text-spanner-engraver.cc +++ b/lily/text-spanner-engraver.cc @@ -1,14 +1,32 @@ /* - text-spanner-engraver.cc -- implement Text_spanner_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2000--2011 Jan Nieuwenhuizen - (c) 2000--2005 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" + +#include "international.hh" #include "note-column.hh" +#include "pointer-group-interface.hh" #include "side-position-interface.hh" -#include "engraver.hh" +#include "spanner.hh" +#include "stream-event.hh" + +#include "translator.icc" class Text_spanner_engraver : public Engraver { @@ -16,16 +34,16 @@ public: TRANSLATOR_DECLARATIONS (Text_spanner_engraver); protected: virtual void finalize (); + DECLARE_TRANSLATOR_LISTENER (text_span); DECLARE_ACKNOWLEDGER (note_column); - virtual bool try_music (Music *); void stop_translation_timestep (); void process_music (); private: Spanner *span_; Spanner *finished_; - Music *current_event_; - Drul_array event_drul_; + Stream_event *current_event_; + Drul_array event_drul_; void typeset_all (); }; @@ -38,17 +56,12 @@ Text_spanner_engraver::Text_spanner_engraver () event_drul_[STOP] = 0; } -bool -Text_spanner_engraver::try_music (Music *m) +IMPLEMENT_TRANSLATOR_LISTENER (Text_spanner_engraver, text_span); +void +Text_spanner_engraver::listen_text_span (Stream_event *ev) { - if (m->is_mus_type ("text-span-event")) - { - Direction d = to_dir (m->get_property ("span-direction")); - event_drul_[d] = m; - return true; - } - - return false; + Direction d = to_dir (ev->get_property ("span-direction")); + ASSIGN_EVENT_ONCE (event_drul_[d], ev); } void @@ -57,10 +70,11 @@ Text_spanner_engraver::process_music () if (event_drul_[STOP]) { if (!span_) - event_drul_[STOP]->origin ()->warning (_ ("can't find start of text spanner")); + event_drul_[STOP]->origin ()->warning (_ ("cannot find start of text spanner")); else { finished_ = span_; + announce_end_grob (finished_, SCM_EOL); span_ = 0; current_event_ = 0; } @@ -81,20 +95,6 @@ Text_spanner_engraver::process_music () } } -void -Text_spanner_engraver::acknowledge_note_column (Grob_info info) -{ - Spanner *spans[2] ={span_, finished_}; - for (int i = 0; i < 2; i++) - { - if (spans[i]) - { - Side_position_interface::add_support (spans[i], info.grob ()); - add_bound_item (spans[i], dynamic_cast (info.grob ())); - } - } -} - void Text_spanner_engraver::typeset_all () { @@ -135,11 +135,34 @@ Text_spanner_engraver::finalize () } } -#include "translator.icc" + +void +Text_spanner_engraver::acknowledge_note_column (Grob_info info) +{ + if (span_) { + Pointer_group_interface::add_grob (span_, + ly_symbol2scm ("note-columns"), + info.grob()); + add_bound_item (span_, info.grob ()); + } else if (finished_) { + Pointer_group_interface::add_grob (finished_, ly_symbol2scm ("note-columns"), + info.grob()); + add_bound_item (finished_, info.grob ()); + } +} + ADD_ACKNOWLEDGER (Text_spanner_engraver, note_column); + ADD_TRANSLATOR (Text_spanner_engraver, - /* doc */ "Create text spanner from a Music.", - /* create */ "TextSpanner", - /* accept */ "text-span-event", - /* read */ "", - /* write */ ""); + /* doc */ + "Create text spanner from an event.", + + /* create */ + "TextSpanner ", + + /* read */ + "", + + /* write */ + "" + );