summaryrefslogtreecommitdiff
path: root/lily
diff options
context:
space:
mode:
authorMark Knoop <mark@opus11.net>2016-09-08 18:56:16 +0100
committerJames Lowe <pkx166h@gmail.com>2016-09-08 18:56:40 +0100
commit5944d20489bb5b8e4c4907fa3b3bcae9ec275ccb (patch)
tree6ad0b84f5685085aab33faa42d43e4f26aff3d23 /lily
parent93f3d637efbc038b837cf64fae0872e873e4f039 (diff)
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. The principal reason for this patch was to allow the use of MarkLine contexts in a Frenched score, where the context should stay alive with any single staff in a StaffGroup. This implementation should also allow additional flexibility with ossia and divisi staves.
Diffstat (limited to 'lily')
-rw-r--r--lily/hara-kiri-group-spanner.cc8
-rw-r--r--lily/keep-alive-together-engraver.cc35
2 files changed, 39 insertions, 4 deletions
diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc
index 06410786a6..76207a5c92 100644
--- a/lily/hara-kiri-group-spanner.cc
+++ b/lily/hara-kiri-group-spanner.cc
@@ -190,9 +190,11 @@ Hara_kiri_group_spanner::add_interesting_item (Grob *me, Grob *n)
ADD_INTERFACE (Hara_kiri_group_spanner,
"A group spanner that keeps track of interesting items. If it"
" doesn't contain any after line breaking, it removes itself"
- " and all its children. Children may be prioritized in layers"
- " via @code{remove-layer}, in which case only the"
- " lowest-numbered non-empty layer is retained.",
+ " and all its children. Greater control can be exercised via"
+ " @code{remove-layer} which can prioritize layers so only the"
+ " lowest-numbered non-empty layer is retained; make the layer"
+ " independent of the group; or make it dependent on any other"
+ " member of the group",
/* properties */
"items-worth-living "
diff --git a/lily/keep-alive-together-engraver.cc b/lily/keep-alive-together-engraver.cc
index 9b1cbe4a23..8931a819c6 100644
--- a/lily/keep-alive-together-engraver.cc
+++ b/lily/keep-alive-together-engraver.cc
@@ -22,6 +22,7 @@
#include "engraver.hh"
#include "grob.hh"
#include "grob-array.hh"
+#include "international.hh"
#include "translator.icc"
@@ -64,12 +65,44 @@ Keep_alive_together_engraver::finalize ()
{
if (i == j)
continue;
+
+ if (scm_is_symbol (this_layer))
+ {
+ if (scm_is_eq (this_layer, ly_symbol2scm ("any")))
+ {
+ // layer is kept alive by any other layer
+ live->add (group_spanners_[j]);
+ continue;
+ }
+ else if (scm_is_eq (this_layer, ly_symbol2scm ("above")))
+ {
+ // layer is kept alive by the layer preceding it
+ if (i == j + 1)
+ live->add (group_spanners_[j]);
+ continue;
+ }
+ else if (scm_is_eq (this_layer, ly_symbol2scm ("below")))
+ {
+ // layer is kept alive by the layer following it
+ if (i == j - 1)
+ live->add (group_spanners_[j]);
+ continue;
+ }
+ else
+ {
+ group_spanners_[i]->warning (_f ("unknown remove-layer value `%s'",
+ ly_symbol2string (this_layer).c_str ()));
+ 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
+ // unset layers are kept alive by all but ignored layers
live->add (group_spanners_[j]);
continue;
}