At 21:21 on 31 Jul 2016, David Kastrup wrote:
>Mark Knoop <[email protected]> writes:
>> OK. Attached are two patches and a test case. The patches are two
>> alternate methods of approaching the problem.
>>
>> Keep a staff alive with multiple layers
>> ---------------------------------------
>>
>> This changes the remove-layer property to number-or-pair? such that a
>> list of values can be specified. The layer will remain alive with any
>> other layer whose remove-layer value is in the list.
>
>If one can specify more than one remove-layer, what layer does a staff
>belong to? If there is no longer numerical order, how are cycles
>avoided?
If remove-layer is a list, the staff is dependent only, and does not
participate in the layering decisions (as an empty list does
currently). It is only controlled by other layers.
>All in all, I am more sympathetic to the list approach (which looks
>more generic), it is just that I see a lot of potential for paradoxes
>or even hangs. I may be wrong.
Yes, I think the list approach is the better way to go. By making
list-set layers only dependent, I don't see that any cyclic problems
can occur.
remove-layer settings:
- '(): staff always alive (default)
- #f: staff alive or dead according to its own keepAliveInterfaces
- integer: staff alive only if all lower layer staves are dead
- list: staff alive with any stave with an included remove-layer value
James, could you test this patch for review please? I will work on
documentation.
--
Mark Knoop
\version "2.19.45"
boring = \set Staff.keepAliveInterfaces = #'()
tricky = \unset Staff.keepAliveInterfaces
staffC = {
\boring \repeat unfold 72 c''4
\tricky <c'' g''>1
\boring \repeat unfold 44 c''4
R1*10
}
staffD = {
\boring \repeat unfold 80 c'4
\tricky <c' g'>1
\boring \repeat unfold 36 c'4
R1*10
}
\score {
<<
\new Staff \with {
instrumentName = "Continuous"
shortInstrumentName = "c"
} { \repeat unfold 200 g'4 }
\new StaffGroup \with {
\consists Keep_alive_together_engraver
} <<
\new Staff \with {
keepAliveInterfaces = #'()
instrumentName = "With group"
shortInstrumentName = "w"
\override VerticalAxisGroup.remove-empty = ##t
\override VerticalAxisGroup.remove-first = ##t
%%% uncomment for 0001-Keep-a-staff-alive-with-multiple-layers.patch
%\override VerticalAxisGroup.remove-layer = #'(#f) % lives with A and/or B
%\override VerticalAxisGroup.remove-layer = #'(1) % lives with C and/or D
%\override VerticalAxisGroup.remove-layer = #'(2) % lives with C+D
\override VerticalAxisGroup.remove-layer = #'(#f 1) % lives with A, B, C or D
%\override VerticalAxisGroup.remove-layer = 1,2 % lives with C, D or C+D
} { \repeat unfold 200 c''4 }
\new Staff \with {
instrumentName = "A"
shortInstrumentName = "A"
\override VerticalAxisGroup.remove-empty = ##t
\override VerticalAxisGroup.remove-first = ##t
\override VerticalAxisGroup.remove-layer = ##f
} {
\repeat unfold 20 c'4
R1*20
\repeat unfold 20 c'4
R1*20
}
\new Staff \with {
instrumentName = "B"
shortInstrumentName = "B"
\override VerticalAxisGroup.remove-empty = ##t
\override VerticalAxisGroup.remove-first = ##t
\override VerticalAxisGroup.remove-layer = ##f
} {
R1*10
\repeat unfold 40 c'4
\repeat unfold 40 c'4
R1*20
}
\new Staff \with {
instrumentName = "C"
shortInstrumentName = "C"
\override VerticalAxisGroup.remove-empty = ##t
\override VerticalAxisGroup.remove-first = ##t
\override VerticalAxisGroup.remove-layer = 1
} { \staffC R1*5 \tricky \repeat unfold 10 g'2 }
\new Staff \with {
instrumentName = "D"
shortInstrumentName = "D"
\override VerticalAxisGroup.remove-empty = ##t
\override VerticalAxisGroup.remove-first = ##t
\override VerticalAxisGroup.remove-layer = 1
} \staffD
\new Staff \with {
instrumentName = "C plus D"
shortInstrumentName = "C+D"
%%% TODO: how to remove this staff when both C and D are rests
%\override VerticalAxisGroup.remove-empty = ##t
%\override VerticalAxisGroup.remove-first = ##t
\override VerticalAxisGroup.remove-layer = 2
} << \staffC \\ \staffD >>
>>
>>
}
>From 4f8846436a395f6fe7d7fecf0c54c8f4aa9f4e1a Mon Sep 17 00:00:00 2001
From: Mark Knoop <[email protected]>
Date: Sun, 31 Jul 2016 15:41:37 +0100
Subject: [PATCH] Keep a staff alive with multiple layers
This allows the `VerticalAxisGroup.remove-layer' property to
accept a list of values. The layer will stay alive with any
other member of the Keep_alive_together_engrave group with a
remove-layer value in that list.
---
lily/keep-alive-together-engraver.cc | 9 ++++++++-
scm/define-grob-properties.scm | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/lily/keep-alive-together-engraver.cc b/lily/keep-alive-together-engraver.cc
index 9b1cbe4..a1dcdea 100644
--- a/lily/keep-alive-together-engraver.cc
+++ b/lily/keep-alive-together-engraver.cc
@@ -65,11 +65,18 @@ Keep_alive_together_engraver::finalize ()
if (i == j)
continue;
SCM that_layer = group_spanners_[j]->get_property ("remove-layer");
+ if (scm_is_pair (this_layer))
+ {
+ // layer is kept alive if its list contains the other
+ if (scm_is_true (scm_memv (that_layer, this_layer)))
+ live->add (group_spanners_[j]);
+ continue;
+ }
if (scm_is_false (that_layer))
continue;
if (!scm_is_integer (this_layer))
{
- // Unspecified layers are kept alive by anything else
+ // unset layers are kept alive by all but ignored layers
live->add (group_spanners_[j]);
continue;
}
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index cb9103a..1b6a169 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -809,7 +809,7 @@ number, the quicker the slur attains its @code{height-limit}.")
interesting items.")
(remove-first ,boolean? "Remove the first staff of an orchestral
score?")
- (remove-layer ,integer? "The @code{Keep_alive_together_engraver}
+ (remove-layer ,number-or-pair? "The @code{Keep_alive_together_engraver}
removes all @code{VerticalAxisGroup} grobs with a @code{remove-layer}
larger than the smallest retained @code{remove-layer}. Set to
@code{#f} to make a layer invisible to the
--
2.7.4
_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel