>From 25c247794ae655557de8b476e6f51951fac4e45a Mon Sep 17 00:00:00 2001 From: Mark Knoop Date: Wed, 27 Jul 2016 17:16:29 +0100 Subject: [PATCH] Keep a staff alive if a staff with the same id is alive This adds a `VerticalAxisGroup.keep-alive-with-id' property of type integer which allows to keep a staff or other horizontal context alive if any other staff with matching id is alive. In this way, any one of a set of staves can keep another alive. Other staves in the set will still be removed if `VerticalAxisGroup.remove-layer' is false. --- input/regression/keep-alive-with-id.ly | 52 ++++++++++++++++++++++++++++++++++ lily/hara-kiri-group-spanner.cc | 1 + lily/keep-alive-together-engraver.cc | 12 ++++++++ scm/define-grob-properties.scm | 2 ++ 4 files changed, 67 insertions(+) create mode 100644 input/regression/keep-alive-with-id.ly diff --git a/input/regression/keep-alive-with-id.ly b/input/regression/keep-alive-with-id.ly new file mode 100644 index 0000000..1365d79 --- /dev/null +++ b/input/regression/keep-alive-with-id.ly @@ -0,0 +1,52 @@ +\version "2.19.46" + +\header { + texidoc = "The @code{VerticalAxisGroup.keep-alive-with-id} property +can be used together with @code{VerticalAxisGroup.remove-layer = ##f} +to identify groups of contexts, any of which should keep the group alive." +} + +bars = \repeat unfold 12 { \mark \default R1*2 } +winds = \repeat unfold 96 { c''4 } +brass = \repeat unfold 192 { c''8 } +violinone = \repeat unfold 24 { R1 } +violintwo = { \repeat unfold 12 c'1 \repeat unfold 12 { R1 } } + +\layout { + \context { \Dynamics \consists Mark_engraver } + \context { \Score \remove Mark_engraver } +} + +\score { + << + \new Dynamics { \bars } + \new Staff \with { instrumentName = "Winds" + shortInstrumentName = "W" + } \winds + \new Staff \with { instrumentName = "Brass" + shortInstrumentName = "Br" + } \brass + \new StaffGroup \with { + \consists Keep_alive_together_engraver + instrumentName = "Strings" + shortInstrumentName = "St" + } << + \new Dynamics \with { + keepAliveInterfaces = #'() + \override RehearsalMark.color = #red + \override VerticalAxisGroup.remove-empty = ##t + \override VerticalAxisGroup.keep-alive-with-id = 1 + } \bars + \new Staff \with { + \override VerticalAxisGroup.remove-empty = ##t + \override VerticalAxisGroup.remove-layer = ##f + \override VerticalAxisGroup.keep-alive-with-id = 1 + } \violinone + \new Staff \with { + \override VerticalAxisGroup.remove-empty = ##t + \override VerticalAxisGroup.remove-layer = ##f + \override VerticalAxisGroup.keep-alive-with-id = 1 + } \violintwo + >> + >> +} diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index 0641078..84872e8 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -198,6 +198,7 @@ ADD_INTERFACE (Hara_kiri_group_spanner, "items-worth-living " "important-column-ranks " "keep-alive-with " + "keep-alive-with-id " "make-dead-when " "remove-empty " "remove-first " diff --git a/lily/keep-alive-together-engraver.cc b/lily/keep-alive-together-engraver.cc index 9b1cbe4..d78327c 100644 --- a/lily/keep-alive-together-engraver.cc +++ b/lily/keep-alive-together-engraver.cc @@ -55,6 +55,8 @@ Keep_alive_together_engraver::finalize () if (scm_is_false (this_layer)) continue; + SCM this_id = group_spanners_[i]->get_property ("keep-alive-with-id"); + SCM live_scm = Grob_array::make_array (); Grob_array *live = unsmob (live_scm); SCM dead_scm = Grob_array::make_array (); @@ -64,6 +66,16 @@ Keep_alive_together_engraver::finalize () { if (i == j) continue; + + SCM that_id = group_spanners_[j]->get_property ("keep-alive-with-id"); + if (scm_is_integer (this_id) and scm_is_integer (that_id) and + scm_is_true (scm_num_eq_p (that_id, this_id))) + { + // this layer is kept alive by any other layer with equal id + live->add (group_spanners_[j]); + continue; + } + SCM that_layer = group_spanners_[j]->get_property ("remove-layer"); if (scm_is_false (that_layer)) continue; diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index cb9103a..e52d70a 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -547,6 +547,8 @@ slur quants to this position, and print the respective scores.") ;;; (keep-inside-line ,boolean? "If set, this column cannot have objects sticking into the margin.") + (keep-alive-with-id ,integer? "An identifying integer for a set of address@hidden If any of them are alive, then we will stay alive.") (kern ,ly:dimension? "The space between individual elements in any compound bar line, expressed as a multiple of the default staff-line thickness (i.e. the visual output is @emph{not} -- 2.7.4