>From 2cf7db9ee6d7bfdfa9358a889b6210f2b71cb6dd Mon Sep 17 00:00:00 2001 From: Mark Knoop Date: Thu, 28 Jul 2016 15:47:46 +0100 Subject: [PATCH] Keep a staff alive if any other staff in the group is alive This uses the `VerticalAxisGroup.remove-layer' property, when set to -1, to keep the context alive within a `Keep_alive_together_engraver' only while any other context is alive, even if those contexts have `VerticalAxisGroup.remove-layer' set to false. --- input/regression/keep-alive-with-any-other.ly | 56 +++++++++++++++++++++++++++ lily/keep-alive-together-engraver.cc | 8 +++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 input/regression/keep-alive-with-any-other.ly diff --git a/input/regression/keep-alive-with-any-other.ly b/input/regression/keep-alive-with-any-other.ly new file mode 100644 index 0000000..ecc4868 --- /dev/null +++ b/input/regression/keep-alive-with-any-other.ly @@ -0,0 +1,56 @@ +\version "2.19.47" + +\header { + texidoc = "The @code{VerticalAxisGroup.remove-layer} property can be set to + @code{-1} to keep it alive only while any other VerticalAxisGroup layer + controlled by the same Keep_alive_together_engraver is alive." +} + +\score { + << + \new StaffGroup \with { + \consists Keep_alive_together_engraver + } << + \new Staff \with { + keepAliveInterfaces = #'() + instrumentName = "With 2 or 3" + shortInstrumentName = "w" + \override VerticalAxisGroup.remove-empty = ##t + \override VerticalAxisGroup.remove-first = ##t + \override VerticalAxisGroup.remove-layer = -1 + } { + \repeat unfold 200 c''4 + } + \new Staff \with { + instrumentName = "2" + shortInstrumentName = "2" + \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 = "3" + shortInstrumentName = "3" + \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 = "Continuous" + shortInstrumentName = "c" + } { + \repeat unfold 200 g'4 + } + >> +} diff --git a/lily/keep-alive-together-engraver.cc b/lily/keep-alive-together-engraver.cc index 9b1cbe4..5125854 100644 --- a/lily/keep-alive-together-engraver.cc +++ b/lily/keep-alive-together-engraver.cc @@ -64,12 +64,18 @@ Keep_alive_together_engraver::finalize () { if (i == j) continue; + if (scm_is_integer (this_layer) and (scm_to_int (this_layer) == -1)) + { + // if remove-layer == -1, layer is kept alive by any other layer + live->add (group_spanners_[j]); + continue; + } SCM that_layer = group_spanners_[j]->get_property ("remove-layer"); if (scm_is_false (that_layer)) continue; if (!scm_is_integer (this_layer)) { - // Unspecified layers are kept alive by anything else + // unspecified layers are kept alive by all but ignored layers live->add (group_spanners_[j]); continue; } -- 2.7.4