Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(863)

Unified Diff: lily/staff-grouper-interface.cc

Issue 331650043: Issue 2199: align outside-staff grobs vertically in staff groups (Closed)
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lily/side-position-interface.cc ('k') | lily/system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lily/staff-grouper-interface.cc
diff --git a/lily/staff-grouper-interface.cc b/lily/staff-grouper-interface.cc
index 55162c2bc7cc0cc13a7000351c2f46e879452b0a..fe0c7aaf4d162524e35d600337238ce6341adcfe 100644
--- a/lily/staff-grouper-interface.cc
+++ b/lily/staff-grouper-interface.cc
@@ -23,6 +23,35 @@
#include "page-layout-problem.hh"
#include "pointer-group-interface.hh"
+// Find the furthest staff in the given direction whose x-extent overlaps with
+// the given interval.
+Grob *
+Staff_grouper_interface::get_extremal_staff (Grob *me, Grob *refpoint, Direction dir, Interval const &iv)
+{
+ // N.B. This is intended to work for a VerticalAlignment grob even though
+ // VerticalAlignment does not have the staff-grouper interface. StaffGrouper
+ // and VerticalAlignment grobs are both created by the
+ // Vertical_align_engraver and contain elements meeting a common set of
+ // criteria, yet they are not described as having a common interface. Should
+ // we treat staff grouping as a subset of vertical alignment? Should we
+ // factor out the shared subset of features into a new interface?
+
+ extract_grob_set (me, "elements", elts);
+ vsize start = (dir == UP) ? 0 : elts.size () - 1;
+ vsize end = (dir == UP) ? elts.size () : VPOS;
+ for (vsize i = start; i != end; i += dir)
+ {
+ if (has_interface<Hara_kiri_group_spanner> (elts[i]))
+ Hara_kiri_group_spanner::consider_suicide (elts[i]);
+
+ Interval intersection = elts[i]->extent (refpoint, X_AXIS);
+ intersection.intersect (iv);
+ if (elts[i]->is_live () && !intersection.is_empty ())
+ return elts[i];
+ }
+ return 0;
+}
+
/* Checks whether the child grob is in the "interior" of this staff-grouper.
This is the case if the next spaceable, living child after the given one
belongs to the group.
« no previous file with comments | « lily/side-position-interface.cc ('k') | lily/system.cc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b