2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2011--2012 Neil Puttock <n.puttock@gmail.com>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
21 #include "global-context.hh"
22 #include "international.hh"
24 #include "side-position-interface.hh"
25 #include "stream-event.hh"
28 #include "translator.icc"
30 class Double_percent_repeat_engraver : public Engraver
33 TRANSLATOR_DECLARATIONS (Double_percent_repeat_engraver);
36 Stream_event *percent_event_;
38 // moment (global time) where percent started
41 DECLARE_TRANSLATOR_LISTENER (double_percent);
43 void process_music ();
46 Double_percent_repeat_engraver::Double_percent_repeat_engraver ()
51 IMPLEMENT_TRANSLATOR_LISTENER (Double_percent_repeat_engraver, double_percent);
53 Double_percent_repeat_engraver::listen_double_percent (Stream_event *ev)
57 Moment meas_len (robust_scm2moment (get_property ("measureLength"),
59 start_mom_ = now_mom () + meas_len;
60 get_global_context ()->add_moment_to_process (start_mom_);
64 ASSIGN_EVENT_ONCE (percent_event_, ev);
68 Double_percent_repeat_engraver::process_music ()
70 if (percent_event_ && now_mom ().main_part_ == start_mom_.main_part_)
72 Item *double_percent = make_item ("DoublePercentRepeat",
73 percent_event_->self_scm ());
75 SCM count = percent_event_->get_property ("repeat-count");
76 if (count != SCM_EOL && to_boolean (get_property ("countPercentRepeats"))
77 && check_repeat_count_visibility (context (), count))
79 Item *double_percent_counter
80 = make_item ("DoublePercentRepeatCounter",
81 percent_event_->self_scm ());
83 SCM text = scm_number_to_string (count, scm_from_int (10));
84 double_percent_counter->set_property ("text", text);
86 Side_position_interface::add_support (double_percent_counter,
88 double_percent_counter->set_parent (double_percent, Y_AXIS);
89 double_percent_counter->set_parent (double_percent, X_AXIS);
91 // forbid breaks on a % line
92 context ()->get_score_context ()->set_property ("forbidBreak",
98 ADD_TRANSLATOR (Double_percent_repeat_engraver,
100 "Make double measure repeats.",
103 "DoublePercentRepeat "
104 "DoublePercentRepeatCounter ",
107 "countPercentRepeats "
109 "repeatCountVisibility ",