X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Farpeggio-engraver.cc;h=58dd2c6fcd866e26fb9026596cd2061ddf55a247;hb=77706635f33adff837dc7af0482f51ff3f0f5cb1;hp=8a5513c3e6229a2c0757c7a4d23ba2b65e848d2a;hpb=94375d04f45b415ad705fd444fdb344416f116d9;p=lilypond.git diff --git a/lily/arpeggio-engraver.cc b/lily/arpeggio-engraver.cc index 8a5513c3e6..58dd2c6fcd 100644 --- a/lily/arpeggio-engraver.cc +++ b/lily/arpeggio-engraver.cc @@ -1,119 +1,117 @@ -/* - arpeggio-engraver.cc -- implement Arpeggio_engraver - - source file of the GNU LilyPond music typesetter - - (c) 2000--2001 Jan Nieuwenhuizen - */ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2000--2010 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 "group-interface.hh" -#include "item.hh" -#include "musical-request.hh" + +#include "pointer-group-interface.hh" #include "arpeggio.hh" #include "stem.hh" -#include "local-key-item.hh" #include "rhythmic-head.hh" #include "side-position-interface.hh" -#include "staff-symbol-referencer.hh" +#include "stream-event.hh" +#include "note-column.hh" +#include "item.hh" + +#include "translator.icc" class Arpeggio_engraver : public Engraver { public: - TRANSLATOR_DECLARATIONS(Arpeggio_engraver); -protected: - virtual void acknowledge_grob (Grob_info); - virtual void create_grobs (); - virtual void stop_translation_timestep (); - virtual bool try_music (Music *); + TRANSLATOR_DECLARATIONS (Arpeggio_engraver); + void acknowledge_stem (Grob_info); + void acknowledge_rhythmic_head (Grob_info); +protected: + void process_music (); + void stop_translation_timestep (); + DECLARE_TRANSLATOR_LISTENER (arpeggio); private: - Item* arpeggio_; - Arpeggio_req *arpeggio_req_; - Link_array stems_; - Link_array supports_; + Item *arpeggio_; + Stream_event *arpeggio_event_; }; Arpeggio_engraver::Arpeggio_engraver () { arpeggio_ = 0; - arpeggio_req_ = 0; + arpeggio_event_ = 0; } -bool -Arpeggio_engraver::try_music (Music* m) +IMPLEMENT_TRANSLATOR_LISTENER (Arpeggio_engraver, arpeggio); +void Arpeggio_engraver::listen_arpeggio (Stream_event *ev) { - if (!arpeggio_req_) - { - if (Arpeggio_req *a = dynamic_cast (m)) - { - arpeggio_req_ = a; - return true; - } - } - return false; + ASSIGN_EVENT_ONCE (arpeggio_event_, ev); } void -Arpeggio_engraver::acknowledge_grob (Grob_info info) +Arpeggio_engraver::acknowledge_stem (Grob_info info) { - if (arpeggio_req_) + if (arpeggio_) { - if (Stem::has_interface (info.grob_l_)) - { - stems_.push (info.grob_l_); - } - - /* - We can't catch local key items (accidentals) from Voice context, - see Local_key_engraver - */ - else if (Rhythmic_head::has_interface (info.grob_l_)) - { - supports_.push (info.grob_l_); - } + if (!arpeggio_->get_parent (Y_AXIS)) + arpeggio_->set_parent (info.grob (), Y_AXIS); + + Pointer_group_interface::add_grob (arpeggio_, + ly_symbol2scm ("stems"), + info.grob ()); } } +void +Arpeggio_engraver::acknowledge_rhythmic_head (Grob_info info) +{ + if (arpeggio_) + + /* + We can't catch local key items (accidentals) from Voice context, + see Local_key_engraver + */ + Side_position_interface::add_support (arpeggio_, info.grob ()); +} void -Arpeggio_engraver::create_grobs () +Arpeggio_engraver::process_music () { - if (!arpeggio_ && !stems_.empty ()) + if (arpeggio_event_) { - arpeggio_ = new Item (get_property ("Arpeggio")); - arpeggio_->set_parent (stems_[0], Y_AXIS); - - for (int i = 0; i < stems_.size (); i++) - { - Pointer_group_interface::add_element (arpeggio_, "stems", stems_[i]); - } - for (int i = 0; i < supports_.size (); i++) - { - Side_position_interface::add_support (arpeggio_, supports_[i]); - } - announce_grob (arpeggio_, arpeggio_req_); + arpeggio_ = make_item ("Arpeggio", arpeggio_event_->self_scm ()); } } void Arpeggio_engraver::stop_translation_timestep () { - if (arpeggio_) - { - typeset_grob (arpeggio_); - arpeggio_ = 0; - } - arpeggio_req_ = 0; - stems_.clear (); - supports_.clear (); + arpeggio_ = 0; + arpeggio_event_ = 0; } +ADD_ACKNOWLEDGER (Arpeggio_engraver, stem); +ADD_ACKNOWLEDGER (Arpeggio_engraver, rhythmic_head); + +ADD_TRANSLATOR (Arpeggio_engraver, + /* doc */ + "Generate an Arpeggio symbol.", + /* create */ + "Arpeggio", + /* read */ + "", -ENTER_DESCRIPTION(Arpeggio_engraver, -/* descr */ "Generate an Arpeggio from a Arpeggio_req", -/* creats*/ "Arpeggio", -/* acks */ "stem-interface rhythmic-head-interface", -/* reads */ "", -/* write */ ""); + /* write */ + "" + );