Suite: a row is pressed where no control lies over it, its own or one its collection draws over it (a grid's filter buttons in its header cells)

This commit is contained in:
aiongg
2026-11-12 14:32:50 +00:00
parent 860c088aa4
commit 685572eaba
@@ -1,20 +1,23 @@
//! The point at which the suite presses a collection row to give it the lead or pick it: a point of the row's own
//! area (17.5). A row that holds child components (a switch, a select) is pressed where none of them is, so the
//! press reaches the row and not a child.
//! area (17.5). A row that holds child components (a switch, a select), or that the collection draws controls over (a
//! grid's filter buttons in its header cells), is pressed where none of them is, so the press reaches the row.
use super::nodes::subtree;
use crate::runtime::egui::access::Declared;
use crate::testing::fixture::{Fixture, Target};
use egui::{Pos2, Rect};
/// The point of `row` to press: its centre when no focusable or clickable descendant covers it, else the middle of the widest
/// stretch of the row's centre line that none covers, and the centre when the descendants cover the whole line.
/// The point of `row` to press: its centre when no focusable or clickable node of its collection (the row's parent:
/// the row's own children and the controls the collection shows beside or over its rows) covers it, else the middle of
/// the widest stretch of the row's centre line that none covers, and the centre when they cover the whole line. Nodes
/// outside the collection, such as the field a popup list opens over, lie under it and are not counted.
pub(super) fn point(fixture: &Fixture, row: &Target) -> Pos2 {
let tree = fixture.tree();
let centre = row.rect.center();
let mut covered: Vec<Rect> = subtree(tree, row.node)
let collection = tree.parent_of_key(row.node).unwrap_or(row.node);
let mut covered: Vec<Rect> = subtree(tree, collection)
.into_iter()
.skip(1)
.filter(|node| *node != collection && *node != row.node)
.filter(|node| tree.declares_key(*node, Declared::Focus) || tree.declares_key(*node, Declared::Click))
.filter_map(|node| tree.bounds_of(node))
.filter(|bounds| bounds.min.y <= centre.y && centre.y <= bounds.max.y)