X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpercent-repeat-engraver.cc;h=398fbe9aa0f19f7652792b8d6ff392b40cfca75a;hb=e2c7a2ab964d7ab2b4d993634303327adf5e39f2;hp=57357cb55943d546e2824ad301009f80f31f1333;hpb=68f8545bd6a0221ee1100336e4ad49399a7ffaa4;p=lilypond.git diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index 57357cb559..398fbe9aa0 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -1,9 +1,20 @@ /* - new-chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2000--2010 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 . */ @@ -14,7 +25,6 @@ #include "international.hh" #include "item.hh" #include "misc.hh" -#include "percent-repeat-iterator.hh" #include "repeated-music.hh" #include "side-position-interface.hh" #include "spanner.hh" @@ -31,6 +41,7 @@ class Percent_repeat_engraver : public Engraver { void typeset_perc (); + bool check_count_visibility (SCM count); public: TRANSLATOR_DECLARATIONS (Percent_repeat_engraver); @@ -52,6 +63,10 @@ protected: Spanner *percent_; Spanner *percent_counter_; + + Grob *first_command_column_; + Moment command_moment_; + protected: virtual void finalize (); DECLARE_TRANSLATOR_LISTENER (percent); @@ -65,8 +80,28 @@ Percent_repeat_engraver::Percent_repeat_engraver () { percent_ = 0; percent_counter_ = 0; - percent_event_ = 0; + + first_command_column_ = 0; + command_moment_ = Moment (-1); +} + +void +Percent_repeat_engraver::start_translation_timestep () +{ + if (now_mom ().main_part_ != command_moment_.main_part_) + { + first_command_column_ = unsmob_grob (get_property ("currentCommandColumn")); + command_moment_ = now_mom (); + } + + if (stop_mom_.main_part_ == now_mom ().main_part_) + { + if (percent_) + typeset_perc (); + percent_event_ = 0; + repeat_sign_type_ = UNKNOWN; + } } IMPLEMENT_TRANSLATOR_LISTENER (Percent_repeat_engraver, percent); @@ -94,7 +129,10 @@ Percent_repeat_engraver::listen_percent (Stream_event *ev) } else { - ev->origin ()->warning (_ ("Junking percent repeat event: Duration must be exactly one or two measures")); + /* + don't warn about percent repeats: slash repeats are not + exactly 1 or 2 measures long. + */ return; } percent_event_ = ev; @@ -114,13 +152,15 @@ Percent_repeat_engraver::process_music () { if (percent_) typeset_perc (); + percent_ = make_spanner ("PercentRepeat", percent_event_->self_scm ()); - Grob *col = unsmob_grob (get_property ("currentCommandColumn")); + Grob *col = first_command_column_; percent_->set_bound (LEFT, col); SCM count = percent_event_->get_property ("repeat-count"); - if (count != SCM_EOL && to_boolean (get_property ("countPercentRepeats"))) + if (count != SCM_EOL && to_boolean (get_property ("countPercentRepeats")) + && check_count_visibility (count)) { percent_counter_ = make_spanner ("PercentRepeatCounter", percent_event_->self_scm ()); @@ -140,11 +180,11 @@ Percent_repeat_engraver::process_music () Item *double_percent = make_item ("DoublePercentRepeat", percent_event_->self_scm ()); SCM count = percent_event_->get_property ("repeat-count"); - if (count != SCM_EOL - && to_boolean (get_property ("countPercentRepeats"))) + if (count != SCM_EOL && to_boolean (get_property ("countPercentRepeats")) + && check_count_visibility (count)) { Item *double_percent_counter = make_item ("DoublePercentRepeatCounter", - percent_event_->self_scm()); + percent_event_->self_scm ()); SCM text = scm_number_to_string (count, scm_from_int (10)); @@ -172,7 +212,7 @@ Percent_repeat_engraver::finalize () { percent_event_->origin ()->warning (_ ("unterminated percent repeat")); percent_->suicide (); - percent_counter_->suicide(); + percent_counter_->suicide (); } } @@ -181,7 +221,7 @@ Percent_repeat_engraver::typeset_perc () { if (percent_) { - Grob *col = unsmob_grob (get_property ("currentCommandColumn")); + Grob *col = first_command_column_; percent_->set_bound (RIGHT, col); percent_ = 0; @@ -192,18 +232,16 @@ Percent_repeat_engraver::typeset_perc () } } -void -Percent_repeat_engraver::start_translation_timestep () +bool +Percent_repeat_engraver::check_count_visibility (SCM count) { - if (stop_mom_.main_part_ == now_mom ().main_part_) - { - if (percent_) - typeset_perc (); - percent_event_ = 0; - repeat_sign_type_ = UNKNOWN; - } + SCM proc = get_property ("repeatCountVisibility"); + return (ly_is_procedure (proc) && to_boolean (scm_call_2 (proc, + count, + context ()->self_scm ()))); } + void Percent_repeat_engraver::stop_translation_timestep () { @@ -218,14 +256,12 @@ ADD_TRANSLATOR (Percent_repeat_engraver, "DoublePercentRepeatCounter " "PercentRepeat " "PercentRepeatCounter ", - - /* accept */ - "percent-event ", /* read */ "countPercentRepeats " "currentCommandColumn " - "measureLength ", + "measureLength " + "repeatCountVisibility ", /* write */ "forbidBreak "