X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fslash-repeat-engraver.cc;h=7844faf6041302064fcb8d098f3fc70748021a91;hb=ecc41fd08c437396edb27d1fb82c977e7404803e;hp=aa5b52c405ccc72ec952aa9fed23a580711b59fd;hpb=70d5609d63efe8a9b42ff763b79348bf99953bf2;p=lilypond.git diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index aa5b52c405..7844faf604 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -1,33 +1,41 @@ /* - slash-repeat-engraver.cc -- implement Slash_repeat_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2000--2012 Han-Wen Nienhuys , Erik Sandberg + - (c) 2000--2006 Han-Wen Nienhuys , Erik Sandberg + 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 "repeated-music.hh" -#include "global-context.hh" -#include "warn.hh" -#include "misc.hh" -#include "spanner.hh" #include "item.hh" -#include "percent-repeat-iterator.hh" -#include "bar-line.hh" -#include "score-engraver.hh" +#include "engraver.hh" +#include "stream-event.hh" -/** - This acknowledges repeated music with "percent" style. It typesets - a slash sign. +#include "translator.icc" + +/* + This acknowledges repeated music with "percent" style. It typesets + a slash sign or double percent sign. */ class Slash_repeat_engraver : public Engraver { public: TRANSLATOR_DECLARATIONS (Slash_repeat_engraver); protected: - Music *slash_; + Stream_event *slash_; protected: - virtual bool try_music (Music *); + DECLARE_TRANSLATOR_LISTENER (repeat_slash); void process_music (); }; @@ -36,24 +44,11 @@ Slash_repeat_engraver::Slash_repeat_engraver () slash_ = 0; } -bool -Slash_repeat_engraver::try_music (Music *m) +IMPLEMENT_TRANSLATOR_LISTENER (Slash_repeat_engraver, repeat_slash); +void +Slash_repeat_engraver::listen_repeat_slash (Stream_event *ev) { - /*todo: separate events for percent and slash */ - if (m->is_mus_type ("percent-event")) - { - Moment meas_length - = robust_scm2moment (get_property ("measureLength"), Moment (0)); - - if (m->get_length () < meas_length) - slash_ = m; - else - return false; - - return true; - } - - return false; + ASSIGN_EVENT_ONCE (slash_, ev); } void @@ -61,16 +56,26 @@ Slash_repeat_engraver::process_music () { if (slash_) { - make_item ("RepeatSlash", slash_->self_scm ()); + SCM count = slash_->get_property ("slash-count"); + if (scm_to_int (count) == 0) + make_item ("DoubleRepeatSlash", slash_->self_scm ()); + else + make_item ("RepeatSlash", slash_->self_scm ()); slash_ = 0; } } -#include "translator.icc" - ADD_TRANSLATOR (Slash_repeat_engraver, - /* doc */ "Make beat repeats.", - /* create */ "RepeatSlash", - /* accept */ "percent-event", - /* read */ "measureLength", - /* write */ ""); + /* doc */ + "Make beat repeats.", + + /* create */ + "DoubleRepeatSlash " + "RepeatSlash ", + + /* read */ + "", + + /* write */ + "" + );