diff --git a/crates/bevy_a11y/Cargo.toml b/crates/bevy_a11y/Cargo.toml index 62cf5ef240..82a3da1f29 100644 --- a/crates/bevy_a11y/Cargo.toml +++ b/crates/bevy_a11y/Cargo.toml @@ -15,7 +15,7 @@ bevy_derive = { path = "../bevy_derive", version = "0.15.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev" } -accesskit = "0.16" +accesskit = "0.17" [lints] workspace = true diff --git a/crates/bevy_a11y/src/lib.rs b/crates/bevy_a11y/src/lib.rs index f73a529f33..49943bd719 100644 --- a/crates/bevy_a11y/src/lib.rs +++ b/crates/bevy_a11y/src/lib.rs @@ -13,7 +13,7 @@ use alloc::sync::Arc; use core::sync::atomic::{AtomicBool, Ordering}; pub use accesskit; -use accesskit::NodeBuilder; +use accesskit::Node; use bevy_app::Plugin; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ @@ -84,10 +84,10 @@ impl ManageAccessibilityUpdates { /// If the entity doesn't have a parent, or if the immediate parent doesn't have /// an `AccessibilityNode`, its node will be an immediate child of the primary window. #[derive(Component, Clone, Deref, DerefMut)] -pub struct AccessibilityNode(pub NodeBuilder); +pub struct AccessibilityNode(pub Node); -impl From for AccessibilityNode { - fn from(node: NodeBuilder) -> Self { +impl From for AccessibilityNode { + fn from(node: Node) -> Self { Self(node) } } diff --git a/crates/bevy_ui/src/accessibility.rs b/crates/bevy_ui/src/accessibility.rs index 941282eac4..f4d331b9ca 100644 --- a/crates/bevy_ui/src/accessibility.rs +++ b/crates/bevy_ui/src/accessibility.rs @@ -5,7 +5,7 @@ use crate::{ ComputedNode, }; use bevy_a11y::{ - accesskit::{NodeBuilder, Rect, Role}, + accesskit::{Node, Rect, Role}, AccessibilityNode, }; use bevy_app::{App, Plugin, PostUpdate}; @@ -19,7 +19,7 @@ use bevy_ecs::{ use bevy_render::{camera::CameraUpdateSystem, prelude::Camera}; use bevy_transform::prelude::GlobalTransform; -fn calc_name( +fn calc_label( text_reader: &mut TextUiReader, children: impl Iterator, ) -> Option> { @@ -70,18 +70,18 @@ fn button_changed( mut text_reader: TextUiReader, ) { for (entity, accessible) in &mut query { - let name = calc_name(&mut text_reader, ui_children.iter_ui_children(entity)); + let label = calc_label(&mut text_reader, ui_children.iter_ui_children(entity)); if let Some(mut accessible) = accessible { accessible.set_role(Role::Button); - if let Some(name) = name { - accessible.set_name(name); + if let Some(name) = label { + accessible.set_label(name); } else { - accessible.clear_name(); + accessible.clear_label(); } } else { - let mut node = NodeBuilder::new(Role::Button); - if let Some(name) = name { - node.set_name(name); + let mut node = Node::new(Role::Button); + if let Some(label) = label { + node.set_label(label); } commands .entity(entity) @@ -97,18 +97,18 @@ fn image_changed( mut text_reader: TextUiReader, ) { for (entity, accessible) in &mut query { - let name = calc_name(&mut text_reader, ui_children.iter_ui_children(entity)); + let label = calc_label(&mut text_reader, ui_children.iter_ui_children(entity)); if let Some(mut accessible) = accessible { accessible.set_role(Role::Image); - if let Some(name) = name { - accessible.set_name(name); + if let Some(label) = label { + accessible.set_label(label); } else { - accessible.clear_name(); + accessible.clear_label(); } } else { - let mut node = NodeBuilder::new(Role::Image); - if let Some(name) = name { - node.set_name(name); + let mut node = Node::new(Role::Image); + if let Some(label) = label { + node.set_label(label); } commands .entity(entity) @@ -127,18 +127,18 @@ fn label_changed( .iter(entity) .map(|(_, _, text, _, _)| text.into()) .collect::>(); - let name = Some(values.join(" ").into_boxed_str()); + let label = Some(values.join(" ").into_boxed_str()); if let Some(mut accessible) = accessible { accessible.set_role(Role::Label); - if let Some(name) = name { - accessible.set_name(name); + if let Some(label) = label { + accessible.set_label(label); } else { - accessible.clear_name(); + accessible.clear_label(); } } else { - let mut node = NodeBuilder::new(Role::Label); - if let Some(name) = name { - node.set_name(name); + let mut node = Node::new(Role::Label); + if let Some(label) = label { + node.set_label(label); } commands .entity(entity) diff --git a/crates/bevy_winit/Cargo.toml b/crates/bevy_winit/Cargo.toml index 427dc84838..3e9e2ea5f0 100644 --- a/crates/bevy_winit/Cargo.toml +++ b/crates/bevy_winit/Cargo.toml @@ -43,7 +43,7 @@ bevy_image = { path = "../bevy_image", version = "0.15.0-dev", optional = true } # other # feature rwh_06 refers to window_raw_handle@v0.6 winit = { version = "0.30", default-features = false, features = ["rwh_06"] } -accesskit_winit = { version = "0.22", default-features = false, features = [ +accesskit_winit = { version = "0.23", default-features = false, features = [ "rwh_06", ] } approx = { version = "0.5", default-features = false } diff --git a/crates/bevy_winit/src/accessibility.rs b/crates/bevy_winit/src/accessibility.rs index b0b88ff220..d2b57fbd04 100644 --- a/crates/bevy_winit/src/accessibility.rs +++ b/crates/bevy_winit/src/accessibility.rs @@ -6,8 +6,8 @@ use std::sync::Mutex; use accesskit_winit::Adapter; use bevy_a11y::{ accesskit::{ - ActionHandler, ActionRequest, ActivationHandler, DeactivationHandler, Node, NodeBuilder, - NodeId, Role, Tree, TreeUpdate, + ActionHandler, ActionRequest, ActivationHandler, DeactivationHandler, Node, NodeId, Role, + Tree, TreeUpdate, }, AccessibilityNode, AccessibilityRequested, AccessibilitySystem, ActionRequest as ActionRequestWrapper, Focus, ManageAccessibilityUpdates, @@ -64,9 +64,9 @@ impl AccessKitState { } fn build_root(&mut self) -> Node { - let mut builder = NodeBuilder::new(Role::Window); - builder.set_name(self.name.clone()); - builder.build() + let mut node = Node::new(Role::Window); + node.set_label(self.name.clone()); + node } fn build_initial_tree(&mut self) -> TreeUpdate { @@ -227,16 +227,14 @@ fn update_adapter( queue_node_for_update(entity, parent, &node_entities, &mut window_children); add_children_nodes(children, &node_entities, &mut node); let node_id = NodeId(entity.to_bits()); - let node = node.build(); to_update.push((node_id, node)); } - let mut window_node = NodeBuilder::new(Role::Window); + let mut window_node = Node::new(Role::Window); if primary_window.focused { let title = primary_window.title.clone(); - window_node.set_name(title.into_boxed_str()); + window_node.set_label(title.into_boxed_str()); } window_node.set_children(window_children); - let window_node = window_node.build(); let node_id = NodeId(primary_window_id.to_bits()); let window_update = (node_id, window_node); to_update.insert(0, window_update); @@ -268,7 +266,7 @@ fn queue_node_for_update( fn add_children_nodes( children: Option<&Children>, node_entities: &Query>, - node: &mut NodeBuilder, + node: &mut Node, ) { let Some(children) = children else { return; diff --git a/examples/ui/scroll.rs b/examples/ui/scroll.rs index 152ea7189f..9fc2f14f0f 100644 --- a/examples/ui/scroll.rs +++ b/examples/ui/scroll.rs @@ -2,7 +2,7 @@ use bevy::{ a11y::{ - accesskit::{NodeBuilder, Role}, + accesskit::{Node as Accessible, Role}, AccessibilityNode, }, input::mouse::{MouseScrollUnit, MouseWheel}, @@ -79,7 +79,7 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }, Label, - AccessibilityNode(NodeBuilder::new(Role::ListItem)), + AccessibilityNode(Accessible::new(Role::ListItem)), )) .insert(Node { min_width: Val::Px(200.), @@ -167,7 +167,7 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }, Label, - AccessibilityNode(NodeBuilder::new( + AccessibilityNode(Accessible::new( Role::ListItem, )), )) @@ -234,7 +234,7 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }, Label, - AccessibilityNode(NodeBuilder::new( + AccessibilityNode(Accessible::new( Role::ListItem, )), )) @@ -310,7 +310,7 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }, Label, - AccessibilityNode(NodeBuilder::new( + AccessibilityNode(Accessible::new( Role::ListItem, )), )) diff --git a/examples/ui/ui.rs b/examples/ui/ui.rs index 24647b469a..62367e20fd 100644 --- a/examples/ui/ui.rs +++ b/examples/ui/ui.rs @@ -4,7 +4,7 @@ use std::f32::consts::PI; use bevy::{ a11y::{ - accesskit::{NodeBuilder, Role}, + accesskit::{Node as Accessible, Role}, AccessibilityNode, }, color::palettes::{basic::LIME, css::DARK_GRAY}, @@ -149,7 +149,7 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }, Label, - AccessibilityNode(NodeBuilder::new(Role::ListItem)), + AccessibilityNode(Accessible::new(Role::ListItem)), )) .insert(PickingBehavior { should_block_lower: false,