[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Group contexts in the Keep_alive_together_engraver (issue 310230043 by a
From: |
mark . opus11 |
Subject: |
Group contexts in the Keep_alive_together_engraver (issue 310230043 by address@hidden) |
Date: |
Fri, 16 Sep 2016 11:23:13 -0700 |
Reviewers: ,
Message:
This patch allows independent sub-groups to operate in the
Keep_alive_together_engraver. For example, it may be desired to display
four instruments in either one tutti staff, two duo staves (I+II,
III+IV), or four solo staves. By labelling the pairs in this situation,
it is possible for the duo-to-solo behaviour of the pairs to operate
independently of each other.
Description:
Group contexts in the Keep_alive_together_engraver
This introduces a `VerticalAxisGroup.keep-alive-group' property
which can be set to a symbol to associate a subset of contexts
under the control of the same Keep_alive_together_engraver. This
group operates only up to the highest `remove-layer` level of its
members.
Please review this at https://codereview.appspot.com/310230043/
Affected files (+38, -0 lines):
M lily/hara-kiri-group-spanner.cc
M lily/keep-alive-together-engraver.cc
M scm/define-grob-properties.scm
Index: lily/hara-kiri-group-spanner.cc
diff --git a/lily/hara-kiri-group-spanner.cc
b/lily/hara-kiri-group-spanner.cc
index
76207a5c928abb5dfae0bdb788c063931de21cf2..d721a9642ed72ca953f5733fa4bb5f3e55d855ef
100644
--- a/lily/hara-kiri-group-spanner.cc
+++ b/lily/hara-kiri-group-spanner.cc
@@ -199,6 +199,7 @@ ADD_INTERFACE (Hara_kiri_group_spanner,
/* properties */
"items-worth-living "
"important-column-ranks "
+ "keep-alive-group "
"keep-alive-with "
"make-dead-when "
"remove-empty "
Index: lily/keep-alive-together-engraver.cc
diff --git a/lily/keep-alive-together-engraver.cc
b/lily/keep-alive-together-engraver.cc
index
8931a819c6ff45150ccb229fdec3d06b8c457426..cad55ba1bfe494f74d9bcbd86122985a22011d82
100644
--- a/lily/keep-alive-together-engraver.cc
+++ b/lily/keep-alive-together-engraver.cc
@@ -26,6 +26,8 @@
#include "translator.icc"
+#include <map>
+
class Keep_alive_together_engraver: public Engraver
{
vector<Grob *> group_spanners_;
@@ -50,12 +52,30 @@
Keep_alive_together_engraver::acknowledge_hara_kiri_group_spanner
(Grob_info i)
void
Keep_alive_together_engraver::finalize ()
{
+ // construct map of maximum remove-layer values in each named
keep-alive-group
+ map<SCM, int> group_max_map_;
+
+ for (vsize i = 0; i < group_spanners_.size (); ++i)
+ {
+ SCM this_group = group_spanners_[i]->get_property
("keep-alive-group");
+ SCM this_layer = group_spanners_[i]->get_property ("remove-layer");
+ if (!scm_is_integer (this_layer))
+ continue;
+
+ if (group_max_map_.find (this_group) == group_max_map_.end ())
+ group_max_map_[this_group] = scm_to_int (this_layer);
+ else
+ group_max_map_[this_group] = max (scm_to_int (this_layer),
+ group_max_map_[this_group]);
+ }
+
for (vsize i = 0; i < group_spanners_.size (); ++i)
{
SCM this_layer = group_spanners_[i]->get_property ("remove-layer");
if (scm_is_false (this_layer))
continue;
+ SCM this_group = group_spanners_[i]->get_property
("keep-alive-group");
SCM live_scm = Grob_array::make_array ();
Grob_array *live = unsmob<Grob_array> (live_scm);
SCM dead_scm = Grob_array::make_array ();
@@ -96,6 +116,21 @@ Keep_alive_together_engraver::finalize ()
}
}
+ SCM that_group = group_spanners_[j]->get_property
("keep-alive-group");
+ if (!scm_is_eq (that_group, this_group))
+ {
+ if (scm_is_integer (this_layer) and
+ group_max_map_[that_group] < scm_to_int (this_layer))
+ {
+ // layer is killed by a lower level group
+ dead->add (group_spanners_[j]);
+ continue;
+ }
+ else
+ // layer ignores a group at undefined, equal or higher
level
+ continue;
+ }
+
SCM that_layer = group_spanners_[j]->get_property
("remove-layer");
if (scm_is_false (that_layer))
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index
d55ab4c8c788449af838d45b2afd55b9b1e8247c..ee6d6e042335c26791f873acd3d24975a918580c
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-group ,symbol? "A symbol defining the group to
+which this @code{VerticalAxisGroup} grob belongs.")
(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}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Group contexts in the Keep_alive_together_engraver (issue 310230043 by address@hidden),
mark . opus11 <=