>From bc32fc46df59c9e1cd5bf0f3182985e23f8db8a8 Mon Sep 17 00:00:00 2001 From: Mark Knoop Date: Sun, 31 Jul 2016 14:43:14 +0100 Subject: [PATCH] Keep a staff alive until it is alone in the group This adds a `VerticalAxisGroup.remove-orphan' property which when set to true will allow removal of the staff when it is the only surviving member of the Keep_alive_together_engraver group. --- lily/hara-kiri-group-spanner.cc | 1 + lily/keep-alive-together-engraver.cc | 10 +++++++++- scm/define-grob-properties.scm | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index 0641078..22092a1 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -202,4 +202,5 @@ ADD_INTERFACE (Hara_kiri_group_spanner, "remove-empty " "remove-first " "remove-layer " + "remove-orphan " ); diff --git a/lily/keep-alive-together-engraver.cc b/lily/keep-alive-together-engraver.cc index 9b1cbe4..4f7b0f0 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_orphan = group_spanners_[i]->get_property ("remove-orphan"); + SCM live_scm = Grob_array::make_array (); Grob_array *live = unsmob (live_scm); SCM dead_scm = Grob_array::make_array (); @@ -65,11 +67,17 @@ Keep_alive_together_engraver::finalize () if (i == j) continue; SCM that_layer = group_spanners_[j]->get_property ("remove-layer"); + if (to_boolean (this_orphan) and !scm_is_integer (that_layer)) + { + // orphan layers are kept alive by ignored and unset layers + 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..b75a4d7 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -815,6 +815,8 @@ larger than the smallest retained @code{remove-layer}. Set to @code{#f} to make a layer invisible to the @code{Keep_alive_together_engraver}, set to @code{'()} to have it not participate in the layering decisions.") + (remove-orphan ,boolean? "Remove the staff if it is the last in +the group?") (replacement-alist ,list? "Alist of strings. The key is a string of the pattern to be replaced. The value is a string of what should be displayed. Useful for ligatures.") -- 2.7.4