Merge pull request #3316 from dylanmtaylor/filmcraft/float-grip-names

ui-panels: a floating window's resize grips carry the accessible name Resize panel window
This commit is contained in:
Dylan M. Taylor
2026-11-24 12:52:47 -05:00
committed by GitHub
6 changed files with 57 additions and 1 deletions
@@ -839,6 +839,7 @@ impl BodyHooks<'_> {
let top = top_band(props, &ctx, pcx.id, pcx.tokens);
let pinned = overlay_of(props).map_or(Pinned::NONE, |overlay| Pinned::of(overlay, &ctx, pcx.id, pcx.env.direction().is_rtl()));
let caller_sizes = overlay_of(props).is_some_and(|overlay| overlay.resize.by_caller);
let grip_name = props.resize_name.as_ref().map(|name| pcx.env.resolve(name).as_str().to_owned());
for (index, (dx, dy, cursor)) in GRIPS.into_iter().enumerate() {
if held != Some(index) && !grip_stands(edges, pinned, dx, dy) {
continue;
@@ -862,6 +863,10 @@ impl BodyHooks<'_> {
.pointer_only(reason)
.exact_hit()
.over();
let part = match &grip_name {
Some(name) => part.node(crate::runtime::access::Role::SPLITTER, name.as_str()),
None => part,
};
// The grips of a window its caller sizes are the app's (`window_resize`), never the platform's.
if let Some(hit) = exclusive(WindowHit::Resize(edge_of(dx, dy))).filter(|_| !caller_sizes) {
part.exclusive(hit);
@@ -812,6 +812,8 @@ pub struct ContainerProps {
/// The help line the footer shows under the control column of a label-scoped container; its text joins the
/// control's description.
pub help: Option<Label>,
/// The accessible name of each resize grip of a window or layer mount; its grips report no node without one.
pub resize_name: Option<Label>,
/// The container's place in its set, reported on its node.
pub position: Option<SetPosition>,
/// The focus scope of an `Inline`, `Pane` or `FullWindow` mount.
@@ -937,6 +939,7 @@ impl ContainerProps {
footer: None,
end: None,
help: None,
resize_name: None,
position: None,
focus: FocusPolicy::NONE,
collapse: None,
@@ -1056,6 +1059,12 @@ impl ContainerProps {
self
}
/// The accessible name of every resize grip of the container's window or layer.
pub fn resize_name(mut self, name: impl Into<Label>) -> Self {
self.resize_name = Some(name.into());
self
}
/// The container's place in its set (`n of m`), reported on its node.
pub const fn position(mut self, position: SetPosition) -> Self {
self.position = Some(position);
@@ -89,6 +89,8 @@ pub(crate) struct PartExtras {
pub toggles: Option<crate::contract::overlay::ToggleDecl>,
/// A header part at the end edge: its stop registers after the header's children.
pub after_header: bool,
/// The part reports an access node of this role and name though no face is painted for it.
pub node: Option<(crate::runtime::access::Role, String)>,
}
impl PartBuilder<'_> {
@@ -245,6 +247,12 @@ impl PartBuilder<'_> {
self
}
/// The part reports an access node of `role`, named `name`, for a part the component paints no face for.
pub fn node(self, role: crate::runtime::access::Role, name: impl Into<String>) -> Self {
self.declared.node = Some((role, name.into()));
self
}
/// A part with no focus stop names its keyboard path: the intent or command that does the same.
pub fn pointer_only(self, reason: &'static str) -> Self {
self.declared.pointer_only = Some(reason);
@@ -11,7 +11,7 @@ use crate::runtime::env::{Label, Message};
use crate::runtime::focus::{self};
use crate::runtime::{inspect, keys, pass_state};
use crate::style::Flags;
use craft_behavior::Sense;
use craft_behavior::{PartRef, Sense};
use egui::Id;
/// What step 16 reads that the pass computed before: the part declarations, the sense and the container facts.
@@ -276,6 +276,16 @@ pub(crate) fn report_parts(core: &CxCore<'_>, decls: &Decls, nodes: &[SubNode],
for face in faces.iter().filter(|face| !seen.contains(&face.part)) {
report_sub(core, decls, &SubNode::new(face.part, face.role), Some(face), parent);
}
for (decl, extras) in decls {
let part = PartRef { key: decl.key, index: decl.index };
let Some((role, name)) = &extras.node else { continue };
if seen.contains(&part) || faces.iter().any(|face| face.part == part) {
continue;
}
let mut node = SubNode::new(part, *role);
node.name = access::Name::Text(name.clone());
report_sub(core, decls, &node, None, parent);
}
}
fn report_sub(core: &CxCore<'_>, decls: &Decls, node: &SubNode, face: Option<&FaceRecord>, parent: Id) {
+4
View File
@@ -326,6 +326,10 @@ impl<'a> FloatingGroup<'a> {
.pad(Pad::None)
.sizing(Sizing::Content)
.header(HeaderRegion::new().band(DragBand::Move).rule(true));
let props = match <DockWords as craft_i18n::WordSet>::word("floatingGroup.resize") {
Some(word) => props.resize_name(Label::from(word)),
None => props,
};
FloatingGroup {
common: Common::new(),
props,
+20
View File
@@ -160,6 +160,26 @@ fn a_grip_window_keeps_no_band_for_a_title_rule() {
assert!(ruled - grip >= 0.5, "the grip window's body ({grip}) starts above the ruled window's ({ruled})");
}
// A floating window's resize grips are named, so assistive technology and automation address them: each edge and
// corner the window declares is one node.
#[trial]
fn a_floating_window_names_each_resize_grip() {
use craft_ui::contract::Role;
use craft_ui::docking::FloatingGroup;
let mut fixture = Fixture::new(move |ui| {
let group = FloatingGroup::new("Quick tools", Rect::from_min_size(Pos2::new(10.0, 10.0), Vec2::new(120.0, 200.0)));
let _ = group.show_group(ui, |ui, _| {
Button::new("Select").show(ui);
});
});
fixture.settle();
let grips = fixture.by_role(Role::SPLITTER);
assert!(grips.len() >= 4, "a resizable window declares a grip on each edge");
for grip in &grips {
assert_eq!(craft_ui::testing::access::name(fixture.tree(), grip.node), Some("Resize panel window"), "every grip is named");
}
}
// A toolbar's marked grip is a handle (photocraft#16467): the grab cursor over it and grabbing while it is held, as
// the grips of a collapsed column show. An unmarked band and a grip that does not move keep the plain arrow.
#[trial]