X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fphrasing-slur-engraver.cc;h=6d9aac7af68d64fb5b7220acc2ebccb0f37435d0;hb=b90c35d90388f7febb6cef6978913bdab8514a43;hp=319c2668834fd627c89e707570be4463872be8eb;hpb=fc3e875d6bf06f0680e897faffdcab36ad975a03;p=lilypond.git diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index 319c266883..6d9aac7af6 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -1,185 +1,84 @@ /* - phrasing-slur-engraver.cc -- implement Phrasing_slur_engraver + This file is part of LilyPond, the GNU music typesetter. - (c) 1997--2001 Han-Wen Nienhuys + Copyright (C) 1997--2012 Han-Wen Nienhuys + + 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 "musical-request.hh" -#include "slur.hh" -#include "debug.hh" -#include "note-column.hh" -#include "translator-group.hh" #include "engraver.hh" + +#include "context.hh" +#include "directional-element-interface.hh" +#include "international.hh" +#include "note-column.hh" +#include "slur.hh" +#include "slur-proto-engraver.hh" #include "spanner.hh" +#include "stream-event.hh" +#include "warn.hh" -class Phrasing_slur_engraver : public Engraver -{ - Link_array requests_arr_; - Link_array new_phrasing_slur_req_l_arr_; - Link_array phrasing_slur_l_stack_; - Link_array end_phrasing_slur_l_arr_; - Moment last_start_; +#include "translator.icc" +class Phrasing_slur_engraver : public Slur_proto_engraver +{ protected: - virtual bool try_music (Music*); - virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); - virtual void finalize (); - virtual void create_grobs (); + DECLARE_TRANSLATOR_LISTENER (phrasing_slur); + DECLARE_ACKNOWLEDGER (slur); public: - VIRTUAL_COPY_CONS (Translator); - Phrasing_slur_engraver (); + TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver); }; -Phrasing_slur_engraver::Phrasing_slur_engraver () -{ - last_start_ = Moment (-1); -} - -bool -Phrasing_slur_engraver::try_music (Music *req_l) +Phrasing_slur_engraver::Phrasing_slur_engraver () : + Slur_proto_engraver (0, "PhrasingSlur", "phrasing slur", "phrasing-slur-event") { - if (Span_req *sl = dynamic_cast (req_l)) - { - String t = ly_scm2string (sl->get_mus_property ("span-type")); - if (t == "abort") - { - for (int i = 0; i < phrasing_slur_l_stack_.size (); i++) - { - phrasing_slur_l_stack_[i]->suicide (); - } - phrasing_slur_l_stack_.clear (); - for (int i = 0; i < end_phrasing_slur_l_arr_.size (); i++) - { - end_phrasing_slur_l_arr_[i]->suicide (); - } - end_phrasing_slur_l_arr_.clear (); - requests_arr_.clear (); - new_phrasing_slur_req_l_arr_.clear (); - } - else if (t == "phrasing-slur") - { - /* - Let's not start more than one phrasing slur per moment. - */ - if (sl->get_span_dir () == START) - { - if (now_mom () > last_start_) - { - new_phrasing_slur_req_l_arr_.push (sl); - last_start_ = now_mom (); - return true; - } - } - else - { - new_phrasing_slur_req_l_arr_.push (sl); - return true; - } - } - } - return false; } +IMPLEMENT_TRANSLATOR_LISTENER (Phrasing_slur_engraver, phrasing_slur); void -Phrasing_slur_engraver::acknowledge_grob (Grob_info info) +Phrasing_slur_engraver::listen_phrasing_slur (Stream_event *ev) { - if (Note_column::has_interface (info.elem_l_)) - { - Grob *e =info.elem_l_; - for (int i = 0; i < phrasing_slur_l_stack_.size (); i++) - Slur::add_column (phrasing_slur_l_stack_[i], e); - for (int i = 0; i < end_phrasing_slur_l_arr_.size (); i++) - Slur::add_column (end_phrasing_slur_l_arr_[i], e); - } + internal_listen_slur (ev); } void -Phrasing_slur_engraver::finalize () +Phrasing_slur_engraver::acknowledge_slur (Grob_info info) { - for (int i = 0; i < phrasing_slur_l_stack_.size (); i++) - { -#if 0 - typeset_grob (phrasing_slur_l_stack_[i]); -#else - /* - Let's not typeset unterminated stuff - */ - phrasing_slur_l_stack_[i]->suicide (); -#endif - } - phrasing_slur_l_stack_.clear (); - SCM wg = get_property ("weAreGraceContext"); - bool wgb = to_boolean (wg); - if (!wgb) - for (int i=0; i < requests_arr_.size (); i++) - { - requests_arr_[i]->origin ()->warning (_ ("unterminated phrasing slur")); - } + acknowledge_extra_object (info); } -void -Phrasing_slur_engraver::create_grobs () -{ - Link_array start_phrasing_slur_l_arr; - for (int i=0; i< new_phrasing_slur_req_l_arr_.size (); i++) - { - Span_req* phrasing_slur_req_l = new_phrasing_slur_req_l_arr_[i]; - // end phrasing slur: move the phrasing slur to other array - if (phrasing_slur_req_l->get_span_dir () == STOP) - { - if (phrasing_slur_l_stack_.empty ()) - phrasing_slur_req_l->origin ()->warning (_f ("can't find start of phrasing slur")); - else - { - Grob* phrasing_slur = phrasing_slur_l_stack_.pop (); - SCM s = get_property ("phrasingSlurEndAttachment"); - if (gh_symbol_p (s)) - { - index_set_cell (phrasing_slur->get_grob_property ("attachment"), STOP, s); - } - end_phrasing_slur_l_arr_.push (phrasing_slur); - requests_arr_.pop (); - } - } - else if (phrasing_slur_req_l->get_span_dir () == START) - { - // push a new phrasing_slur onto stack. - // (use temp. array to wait for all phrasing_slur STOPs) - Grob* phrasing_slur = new Spanner (get_property ("PhrasingSlur")); - Slur::set_interface (phrasing_slur); - SCM s = get_property ("phrasingSlurBeginAttachment"); - if (gh_symbol_p (s)) - { - index_set_cell (phrasing_slur->get_grob_property ("attachment"), START, s); - } - start_phrasing_slur_l_arr.push (phrasing_slur); - requests_arr_.push (phrasing_slur_req_l); - announce_grob (phrasing_slur, phrasing_slur_req_l); - } - } - for (int i=0; i < start_phrasing_slur_l_arr.size (); i++) - phrasing_slur_l_stack_.push (start_phrasing_slur_l_arr[i]); - new_phrasing_slur_req_l_arr_.clear (); -} +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, inline_accidental); +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, fingering) +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, note_column); +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, slur); +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, script); +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, dots); +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, text_script); +ADD_END_ACKNOWLEDGER (Phrasing_slur_engraver, tie); +ADD_ACKNOWLEDGER (Phrasing_slur_engraver, tuplet_number); -void -Phrasing_slur_engraver::stop_translation_timestep () -{ - for (int i = 0; i < end_phrasing_slur_l_arr_.size (); i++) - { - typeset_grob (end_phrasing_slur_l_arr_[i]); - } - end_phrasing_slur_l_arr_.clear (); -} +ADD_TRANSLATOR (Phrasing_slur_engraver, + /* doc */ + "Print phrasing slurs. Similar to @ref{Slur_engraver}.", -void -Phrasing_slur_engraver::start_translation_timestep () -{ - new_phrasing_slur_req_l_arr_.clear (); -} + /* create */ + "PhrasingSlur ", + /* read */ + "", -ADD_THIS_TRANSLATOR (Phrasing_slur_engraver); + /* write */ + "" + );