From ab3532b502191fbafb1a6fca5857af01dbbc027c Mon Sep 17 00:00:00 2001 From: hanwen Date: Tue, 16 Aug 2005 15:47:43 +0000 Subject: [PATCH] * Documentation/topdocs/NEWS.tely (Top): add entry for percent counters. * Documentation/user/basic-notation.itely (Measure repeats): add links to Counter grobs. * scm/define-grobs.scm (all-grob-descriptions): add DoublePercentRepeatCounter (all-grob-descriptions): add PercentRepeatCounter * lily/percent-repeat-engraver.cc (class Percent_repeat_engraver): also create counter grobs. * lily/separation-item.cc (extremal_break_aligned_grob): don't return grob without space-alist. * input/proportional.ly: tune staff-padding. * input/regression/repeat-percent-count.ly: new file. --- ChangeLog | 22 ++++ Documentation/topdocs/NEWS.tely | 11 ++ Documentation/user/basic-notation.itely | 6 +- THANKS | 1 + input/proportional.ly | 155 +++++++++++------------ input/regression/repeat-percent-count.ly | 20 +++ lily/break-align-engraver.cc | 2 +- lily/include/paper-system.hh | 3 +- lily/percent-repeat-engraver.cc | 135 ++++++++++++++------ lily/separation-item.cc | 3 + scm/define-grobs.scm | 34 +++++ scm/framework-ps.scm | 1 + 12 files changed, 272 insertions(+), 121 deletions(-) create mode 100644 input/regression/repeat-percent-count.ly diff --git a/ChangeLog b/ChangeLog index 4a1c8472c1..8799e980a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2005-08-16 Han-Wen Nienhuys + + * Documentation/topdocs/NEWS.tely (Top): add entry for percent + counters. + + * Documentation/user/basic-notation.itely (Measure repeats): add + links to Counter grobs. + + * scm/define-grobs.scm (all-grob-descriptions): add + DoublePercentRepeatCounter + (all-grob-descriptions): add PercentRepeatCounter + + * lily/percent-repeat-engraver.cc (class Percent_repeat_engraver): + also create counter grobs. + + * lily/separation-item.cc (extremal_break_aligned_grob): don't + return grob without space-alist. + + * input/proportional.ly: tune staff-padding. + + * input/regression/repeat-percent-count.ly: new file. + 2005-08-16 Nicolas Sceaux * input/no-notation/display-lily-tests.ly: moved from diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index 0e7c07adcb..30865e919d 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -37,6 +37,17 @@ This document is also available in @uref{source/Documentation/topdocs/out-www/NE @itemize @bullet +@item +Percent repeats now get numbers to how many repeats there are. + +@lilypond[relative=2,fragment,raggedright] +\repeat percent 4 { c1 } +\time 2/4 +\repeat percent 4 { c2 c2 } +@end lilypond + +This feature was sponsored by Yoshinobu Ishizaki + @item Text scripts such as fingering instructions and dynamics avoid collisions with Slurs diff --git a/Documentation/user/basic-notation.itely b/Documentation/user/basic-notation.itely index 5133b865df..607054fc3d 100644 --- a/Documentation/user/basic-notation.itely +++ b/Documentation/user/basic-notation.itely @@ -2937,7 +2937,9 @@ Percent repeats must be declared within a @code{Voice} context. @seealso -Program reference: @internalsref{RepeatSlash}, @internalsref{PercentRepeat}, +Program reference: @internalsref{RepeatSlash}, +@internalsref{PercentRepeat}, @internalsref{DoublePercentRepeat}, +@internalsref{DoublePercentRepeatCounter}, +@internalsref{PercentRepeatCounter}, @internalsref{PercentRepeatedMusic}, and -@internalsref{DoublePercentRepeat}. diff --git a/THANKS b/THANKS index d7399bd2c5..f080579f75 100644 --- a/THANKS +++ b/THANKS @@ -26,6 +26,7 @@ D. Josiah Boothby Nancho Alvarez Sven Axelsson Trevor Baca +Yoshinobu Ishizaki BUG HUNTERS/SUGGESTIONS diff --git a/input/proportional.ly b/input/proportional.ly index 65eb3f211b..db3aecdaf9 100644 --- a/input/proportional.ly +++ b/input/proportional.ly @@ -27,7 +27,7 @@ \override TimeSignature #'break-visibility = #end-of-line-invisible \override Beam #'break-overshoot = #'(-0.5 . 1.0) \override TupletBracket #'break-overshoot = #'(-0.5 . 1.0) - \override TupletBracket #'staff-padding = #4 + \override TupletBracket #'staff-padding = #3.5 \override PaperColumn #'used = ##t } \context { @@ -43,87 +43,86 @@ staffKind = "RhythmicStaff" \relative c'' \new StaffGroup << - \new \staffKind << - { - \skip 2 - \skip 2 - \break \time 4/8 - \skip 1 \break \time 4/8 - \skip 1 \break \time 4/8 - } + \new \staffKind << + { + \skip 2 + \skip 2 + \break \time 4/8 + \skip 1 \break \time 4/8 + \skip 1 \break \time 4/8 + } - { - \time 4/8 + { + \time 4/8 - \times 7/9 { - \times 4/6 { - r8 c32[ c c c c c c c] r4 - c32[ c32 c16 } - \times 5/4 { - c16 c c] c32[ c32 c16 c] r8 } - } + \times 7/9 { + \times 4/6 { + r8 c32[ c c c c c c c] r4 + c32[ c32 c16 } + \times 5/4 { + c16 c c] c32[ c32 c16 c] r8 } + } -\times 10/12 { - \times 7/6 { - c32[ c32 c8 c16] r4 - c16[ c16 c16. c32 - } - \times 5/8 { - c16 c16 c16. c32] r8 c8[ c8] r4. - } -} + \times 10/12 { + \times 7/6 { + c32[ c32 c8 c16] r4 + c16[ c16 c16. c32 + } + \times 5/8 { + c16 c16 c16. c32] r8 c8[ c8] r4. + } + } - \times 4/7 { - r8 - c16[ c16 - \times 5/4 { - c16 r16 c8 c c - } - } + \times 4/7 { + r8 + c16[ c16 + \times 5/4 { + c16 r16 c8 c c + } + } - \times 3/4 { - c8] - c16[ c - \times 2/3 { - c16 c16] - r4 } - } - } - >> - \new \staffKind - << - { - \times 9/5 { - r8. c16[ c c - \grace { - \stemDown - c32[ c32] - \stemNeutral - } - c16 c c - c - } - \times 4/7 { - c16 c c c ] - \times 5/4 { - c16[ c32 c32] - r4 - c32[ c c16 - } - } - \times 10/12 { - \times 7/10 { - c16 c16 c8] r4 c4 - c16[ c8 c16 c16 r8 c16 - } - c16 c32 c32] - r4. - c16.[ - c32 - } - c16 c16] + \times 3/4 { + c8] + c16[ c + \times 2/3 { + c16 c16] + r4 } + } + } + >> + \new \staffKind + << + { + \times 9/5 { + r8. c16[ c c + \grace { + \stemDown + c32[ c32] + \stemNeutral + } + c16 c c + c + } + \times 4/7 { + c16 c c c ] + \times 5/4 { + c16[ c32 c32] + r4 + c32[ c c16 + } + } + \times 10/12 { + \times 7/10 { + c16 c16 c8] r4 c4 + c16[ c8 c16 c16 r8 c16 + } + c16 c32 c32] + r4. + c16.[ + c32 + } + c16 c16] - } - { \skip 2 * 6 } % filler space. - >> + } + >> >> diff --git a/input/regression/repeat-percent-count.ly b/input/regression/repeat-percent-count.ly new file mode 100644 index 0000000000..45666ee6b8 --- /dev/null +++ b/input/regression/repeat-percent-count.ly @@ -0,0 +1,20 @@ + +\header { + + + texidoc = "Percent repeats get numbers to indicate the repeat +counts, but only if there are more than two repeats." + + +} + +\version "2.7.6" + +\relative c'' \new Voice { + \time 4/4 + \repeat "percent" 4 { c1 } + \time 2/4 + \repeat "percent" 4 { c2 c2 } + \repeat "percent" 2 { c2 } +} + diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index 3359b9b72a..9fde23e6b7 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -71,7 +71,7 @@ Break_align_engraver::acknowledge_break_aligned (Grob_info inf) SCM align_name = item->get_property ("break-align-symbol"); if (!scm_is_symbol (align_name)) return; - + if (!align_) { align_ = make_item ("BreakAlignment", SCM_EOL); diff --git a/lily/include/paper-system.hh b/lily/include/paper-system.hh index 2c4930b363..3c9168993e 100644 --- a/lily/include/paper-system.hh +++ b/lily/include/paper-system.hh @@ -22,6 +22,7 @@ class Paper_system DECLARE_SMOBS (Paper_system,); Stencil stencil_; bool is_title_; + public: Interval staff_refpoints_; Real break_before_penalty_; @@ -34,7 +35,7 @@ public: bool is_title () const; Real break_before_penalty () const; }; -// + DECLARE_UNSMOB (Paper_system, paper_system); #endif /* PAPER_SYSTEM_HH */ diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index ba9a627537..bb40c0e45f 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -6,6 +6,9 @@ (c) 2000--2005 Han-Wen Nienhuys */ + +#include "score-engraver.hh" + #include "repeated-music.hh" #include "global-context.hh" #include "warn.hh" @@ -14,23 +17,16 @@ #include "item.hh" #include "percent-repeat-iterator.hh" #include "bar-line.hh" -#include "score-engraver.hh" - -/** - This acknowledges repeated music with "percent" style. It typesets - a % sign. - - TODO: +#include "side-position-interface.hh" - - BEAT case: Create items for single beat repeats, i.e. c4 / / / +#include "translator.icc" - - DOUBLE_MEASURE case: attach a % to an appropriate barline. -*/ class Percent_repeat_engraver : public Engraver { void typeset_perc (); public: TRANSLATOR_DECLARATIONS (Percent_repeat_engraver); + protected: Music *repeat_; @@ -38,22 +34,28 @@ protected: Moment start_mom_; Moment stop_mom_; - /// location within measure where beam started. + /// location within measure where beam started. Moment beam_start_location_; Moment next_moment_; Moment body_length_; - enum + enum Repeat_sign_type { UNKNOWN, MEASURE, DOUBLE_MEASURE, - } - repeat_sign_type_; + }; + Repeat_sign_type repeat_sign_type_; Item *double_percent_; - Spanner *perc_; - Spanner *finished_perc_; + Item *double_percent_counter_; + Spanner *percent_; + Spanner *percent_counter_; + Spanner *finished_percent_; + Spanner *finished_percent_counter_; + + int count_; + int total_count_; protected: virtual void finalize (); virtual bool try_music (Music *); @@ -65,11 +67,18 @@ protected: Percent_repeat_engraver::Percent_repeat_engraver () { - perc_ = 0; - finished_perc_ = 0; - repeat_ = 0; + percent_ = 0; + percent_counter_ = 0; + + finished_percent_ = 0; + finished_percent_counter_ = 0; double_percent_ = 0; + double_percent_counter_ = 0; + + repeat_ = 0; + count_ = 0; + total_count_ = 0; } bool @@ -81,11 +90,11 @@ Percent_repeat_engraver::try_music (Music *m) && !repeat_) { body_length_ = Repeated_music::body_get_length (m); - int count = Repeated_music::repeat_count (m); - + total_count_ = Repeated_music::repeat_count (m); + Moment now = now_mom (); start_mom_ = now; - stop_mom_ = start_mom_ + Moment (count) * body_length_; + stop_mom_ = start_mom_ + Moment (total_count_) * body_length_; next_moment_ = start_mom_ + body_length_; Moment meas_len (robust_scm2moment (get_property ("measureLength"), Moment (1))); @@ -103,7 +112,7 @@ Percent_repeat_engraver::try_music (Music *m) repeat_ = m; Global_context *global = get_global_context (); - for (int i = 1; i < count; i++) + for (int i = 1; i < total_count_; i++) { Moment m = next_moment_ + Moment (i) * body_length_; global->add_moment_to_process (m); @@ -116,6 +125,7 @@ Percent_repeat_engraver::try_music (Music *m) if (repeat_sign_type_ == DOUBLE_MEASURE) next_moment_ += meas_len; + count_ = 1; return true; } @@ -127,18 +137,53 @@ Percent_repeat_engraver::process_music () { if (repeat_ && now_mom () == next_moment_) { + count_ ++; if (repeat_sign_type_ == MEASURE) { - finished_perc_ = perc_; + finished_percent_ = percent_; + finished_percent_counter_ = percent_counter_; + typeset_perc (); - perc_ = make_spanner ("PercentRepeat", repeat_->self_scm ()); - SCM col = get_property ("currentCommandColumn"); - perc_->set_bound (LEFT, unsmob_grob (col)); + percent_ = make_spanner ("PercentRepeat", repeat_->self_scm ()); + + Grob *col = unsmob_grob (get_property ("currentCommandColumn")); + percent_->set_bound (LEFT, col); + + if (total_count_ > 2) + { + percent_counter_ + = make_spanner ("PercentRepeatCounter", repeat_->self_scm ()); + + + SCM text = scm_number_to_string (scm_from_int (count_), + scm_from_int (10)); + percent_counter_->set_property ("text", text); + percent_counter_->set_bound (LEFT, col); + Side_position_interface::add_support (percent_counter_, + percent_); + percent_counter_->set_parent (percent_, Y_AXIS); + } } else if (repeat_sign_type_ == DOUBLE_MEASURE) { double_percent_ = make_item ("DoublePercentRepeat", repeat_->self_scm ()); + if (total_count_ > 2) + { + double_percent_counter_ + = make_item ("DoublePercentRepeatCounter", + repeat_->self_scm()); + + SCM text = scm_number_to_string (scm_from_int (count_), + scm_from_int (10)); + double_percent_counter_->set_property ("text", text); + + Side_position_interface::add_support (double_percent_counter_, + double_percent_); + double_percent_counter_->set_parent (double_percent_, Y_AXIS); + double_percent_counter_->set_parent (double_percent_, X_AXIS); + } + /* forbid breaks on a % line. Should forbid all breaks, really. @@ -155,24 +200,32 @@ void Percent_repeat_engraver::finalize () { typeset_perc (); - if (perc_) + if (percent_) { repeat_->origin ()->warning (_ ("unterminated percent repeat")); - perc_->suicide (); + percent_->suicide (); + percent_counter_->suicide(); } } void Percent_repeat_engraver::typeset_perc () { - if (finished_perc_) + if (finished_percent_) { - SCM col = get_property ("currentCommandColumn"); - finished_perc_->set_bound (RIGHT, unsmob_grob (col)); - finished_perc_ = 0; + Grob *col = unsmob_grob (get_property ("currentCommandColumn")); + + finished_percent_->set_bound (RIGHT, col); + finished_percent_ = 0; + + if (finished_percent_counter_) + finished_percent_counter_->set_bound (RIGHT, col); + + finished_percent_counter_ = 0; } double_percent_ = 0; + double_percent_counter_ = 0; } void @@ -180,13 +233,17 @@ Percent_repeat_engraver::start_translation_timestep () { if (stop_mom_ == now_mom ()) { - if (perc_) + if (percent_) { - finished_perc_ = perc_; + finished_percent_ = percent_; + finished_percent_counter_ = percent_counter_; + typeset_perc (); } repeat_ = 0; - perc_ = 0; + percent_ = 0; + + percent_counter_ = 0; repeat_sign_type_ = UNKNOWN; } } @@ -197,11 +254,11 @@ Percent_repeat_engraver::stop_translation_timestep () typeset_perc (); } -#include "translator.icc" - ADD_TRANSLATOR (Percent_repeat_engraver, /* doc */ "Make whole bar and double bar repeats.", - /* create */ "PercentRepeat DoublePercentRepeat", + /* create */ + "PercentRepeat DoublePercentRepeat " + "PercentRepeatCounter DoublePercentRepeatCounter", /* accept */ "repeated-music", /* read */ "measureLength currentCommandColumn", /* write */ ""); diff --git a/lily/separation-item.cc b/lily/separation-item.cc index 4b80e14793..ba63f91d0e 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -129,6 +129,9 @@ Separation_item::extremal_break_aligned_grob (Grob *me, if (!scm_is_symbol (break_item->get_property ("break-align-symbol"))) continue; + if (!scm_is_pair (break_item->get_property ("space-alist"))) + continue; + Interval ext = break_item->extent (col, X_AXIS); if (ext.is_empty ()) diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 9f58f66256..af88579662 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -454,6 +454,23 @@ break-aligned-interface percent-repeat-interface)))))) + (DoublePercentRepeatCounter + . ((print-function . ,Text_interface::print) + (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self + ,Self_alignment_interface::centered_on_other_axis_parent)) + (Y-offset-callbacks . (,Side_position_interface::aligned_side)) + (font-encoding . fetaNumber) + (self-alignment-X . 0) + (font-size . -2) + (direction . 1) + (padding . 0.2) + (staff-padding . 0.25) + (meta . ((class . Item) + (interfaces . (side-position-interface + self-alignment-interface + percent-repeat-interface + font-interface + text-interface)))))) (DynamicLineSpanner . ( (axes . (1)) @@ -977,6 +994,23 @@ (interfaces . (multi-measure-rest-interface font-interface percent-repeat-interface)))))) + (PercentRepeatCounter + . ((print-function . ,Text_interface::print) + (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self + ,Self_alignment_interface::centered_on_other_axis_parent)) + (Y-offset-callbacks . (,Side_position_interface::aligned_side)) + (self-alignment-X . 0) + (direction . 1) + (padding . 0.2) + (staff-padding . 0.25) + (font-size . -2) + (font-encoding . fetaNumber) + (meta . ((class . Spanner) + (interfaces . (side-position-interface + self-alignment-interface + percent-repeat-interface + font-interface + text-interface)))))) ;; an example of a text spanner (PianoPedalBracket diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index b2d8f7c558..67ceda359e 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -495,6 +495,7 @@ (scale (ly:output-def-lookup paper 'outputscale)) (to-dump-systems '())) + (display systems) ;; skip booktitles. (if (and (not -- 2.39.5