Hi Jan-Peter,

On Fri, Dec 23, 2016 at 5:52 AM, Jan-Peter Voigt <jp.vo...@gmx.de> wrote:
> Hello list,
>
> in my current scores I have to deal with a lot of MultiMeasureRests. I am
> facing the following layout-problem:
>
> If there is one line filled with (for example) a three measure long mm-rest
> (and maybe one bar with a few cue-notes) the measure-symbol consisting of
> two or the rectangles is spreading quite widely:
>
> %%%%%
> \paper {
>   ragged-last = ##f
> }
> { \compressFullBarRests R1*3 }
> %%%%%
>
> (mmrest1.png)
>
> But I would like to space it like in mmrest2.png, the default spacing.
>
> I looked for an override, but didn't find one suitable.
> Anybody knows how to deal with it?
>

The default is actually to allow the components of the church rest to
expand to fill the available space within the measure.  The symbols
making up the rest are assigned a padding value proportional to the
visual size of the measure.

I think what you're after is some means to limit this expansion.  I've
attached a patch which creates a property ("no-stretch") which keeps
internal padding at its minimum value -- 1 staff space.  Note also the
test file.  I haven't tested it beyond what you see there.

It might be nice to allow a maximum padding.  (I find 1.0 for padding
a little close.)  That would be easily done.

Sorry that this is a patch you need to apply.  Putting this in Scheme
would require extensive recoding.

HTH,
David
From 2db13e3ab86920886574585bf9130a0bebdfd096 Mon Sep 17 00:00:00 2001
From: David Nalesnik <david.nales...@gmail.com>
Date: Fri, 23 Dec 2016 10:39:12 -0600
Subject: [PATCH] Implement no-stretch for MultiMeasureRest

Ordinarily, church rests expand to fill the measure.  This patch
implements the property "no-stretch," a boolean which when #t prevents
the default behavior.
---
 lily/multi-measure-rest.cc     | 15 +++++++++++++--
 scm/define-grob-interfaces.scm |  2 +-
 scm/define-grob-properties.scm |  2 ++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc
index 7f2a720..478192a 100644
--- a/lily/multi-measure-rest.cc
+++ b/lily/multi-measure-rest.cc
@@ -321,7 +321,8 @@ Multi_measure_rest::church_rest (Grob *me, Font_metric *musfont, int measure_cou
   Real outer_padding_factor = 1.5;
   Real inner_padding = (space - symbols_width)
                        / (2 * outer_padding_factor + (symbol_count - 1));
-  if (inner_padding < 0)
+  bool no_stretch = to_boolean (me->get_property("no-stretch"));
+  if (inner_padding < 0 || no_stretch)
     inner_padding = 1.0;
 
   Stencil mol;
@@ -329,7 +330,17 @@ Multi_measure_rest::church_rest (Grob *me, Font_metric *musfont, int measure_cou
     mol.add_at_edge (X_AXIS, LEFT, *unsmob<Stencil> (scm_car (s)),
                      inner_padding);
   mol.align_to (X_AXIS, LEFT);
-  mol.translate_axis (outer_padding_factor * inner_padding, X_AXIS);
+
+  if (no_stretch)
+    {
+      mol.translate_axis (max (outer_padding_factor * inner_padding,
+        (space - symbols_width - (inner_padding * (symbol_count - 1))) / 2),
+        X_AXIS);
+    }
+  else
+    {
+      mol.translate_axis (outer_padding_factor * inner_padding, X_AXIS);
+    }
 
   return mol;
 }
diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm
index d5f2311..5ee78a3 100644
--- a/scm/define-grob-interfaces.scm
+++ b/scm/define-grob-interfaces.scm
@@ -209,7 +209,7 @@ accidentals)."
 (ly:add-interface
  'multi-measure-interface
  "Multi measure rest, and the text or number that is printed over it."
- '(bound-padding))
+ '(bound-padding no-stretch))
 
 (ly:add-interface
  'note-name-interface
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index 0635898..48da9da 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -667,6 +667,8 @@ syllable following an extender).")
 object.")
      (no-stem-extend ,boolean? "If set, notes with ledger lines do not
 get stems extending to the middle staff line.")
+     (no-stretch ,boolean? "If set, church rests will not spread to fill
+available space.")
      (non-break-align-symbols ,list? "A list of symbols that determine
 which NON-break-aligned interfaces to align this to.")
      (non-default ,boolean? "Set for manually specified clefs and keys.")
-- 
2.1.4

\version "2.19.54"

\paper {
  ragged-last = ##f
}

\markup \bold \huge "DEFAULT"

{
  \compressFullBarRests R1*3
  \break
  R1*9
  \break
  R1*12
  \break
  R1*3
  R1*9
  R1*12
  \break
  \repeat unfold 8 { R1*3 }
}

\markup \bold \huge "NO STRETCH"
\markup \concat { "Church rests do not expand with increased measure size, " \italic "but rests drawn as lines are" }

{
  \override Staff.MultiMeasureRest.no-stretch = ##t
  \compressFullBarRests R1*3
  \break
  R1*9
  \break
  R1*12
  \break
  R1*3
  R1*9
  R1*12
  \break
  \repeat unfold 8 { R1*3 }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to