X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpercent-repeat-engraver.cc;h=398fbe9aa0f19f7652792b8d6ff392b40cfca75a;hb=d02dcdc4042a592a52bc977ad4fb28a5d841e733;hp=dc6ba4213fc8e983b21ce2c9f6069046bbe8450c;hpb=5f0e15c0862e3e9f024bfe1c763180e554f2e045;p=lilypond.git diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index dc6ba4213f..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 . */ @@ -30,6 +41,7 @@ class Percent_repeat_engraver : public Engraver { void typeset_perc (); + bool check_count_visibility (SCM count); public: TRANSLATOR_DECLARATIONS (Percent_repeat_engraver); @@ -117,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; @@ -144,7 +159,8 @@ Percent_repeat_engraver::process_music () 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 ()); @@ -164,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)); @@ -196,7 +212,7 @@ Percent_repeat_engraver::finalize () { percent_event_->origin ()->warning (_ ("unterminated percent repeat")); percent_->suicide (); - percent_counter_->suicide(); + percent_counter_->suicide (); } } @@ -216,6 +232,14 @@ Percent_repeat_engraver::typeset_perc () } } +bool +Percent_repeat_engraver::check_count_visibility (SCM count) +{ + SCM proc = get_property ("repeatCountVisibility"); + return (ly_is_procedure (proc) && to_boolean (scm_call_2 (proc, + count, + context ()->self_scm ()))); +} void @@ -232,14 +256,12 @@ ADD_TRANSLATOR (Percent_repeat_engraver, "DoublePercentRepeatCounter " "PercentRepeat " "PercentRepeatCounter ", - - /* accept */ - "percent-event ", /* read */ "countPercentRepeats " "currentCommandColumn " - "measureLength ", + "measureLength " + "repeatCountVisibility ", /* write */ "forbidBreak "