Bump accesskit and accesskit_winit. (#16234)

# Objective

- Bumps accesskit and accesskit_winit dependencies

## Solution

- Fixes several breaking API changes introduced in accesskit 0.23.

## Testing

- Tested with the ui example and seems to work comparably
This commit is contained in:
Nolan Darilek 2024-11-04 14:07:38 -06:00 committed by GitHub
parent b0058dc54b
commit 817f160d35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 44 additions and 46 deletions

View file

@ -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

View file

@ -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<NodeBuilder> for AccessibilityNode {
fn from(node: NodeBuilder) -> Self {
impl From<Node> for AccessibilityNode {
fn from(node: Node) -> Self {
Self(node)
}
}

View file

@ -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<Item = Entity>,
) -> Option<Box<str>> {
@ -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::<Vec<String>>();
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)

View file

@ -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 }

View file

@ -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<Entity, With<AccessibilityNode>>,
node: &mut NodeBuilder,
node: &mut Node,
) {
let Some(children) = children else {
return;

View file

@ -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<AssetServer>) {
..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<AssetServer>) {
..default()
},
Label,
AccessibilityNode(NodeBuilder::new(
AccessibilityNode(Accessible::new(
Role::ListItem,
)),
))
@ -234,7 +234,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
..default()
},
Label,
AccessibilityNode(NodeBuilder::new(
AccessibilityNode(Accessible::new(
Role::ListItem,
)),
))
@ -310,7 +310,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
..default()
},
Label,
AccessibilityNode(NodeBuilder::new(
AccessibilityNode(Accessible::new(
Role::ListItem,
)),
))

View file

@ -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<AssetServer>) {
..default()
},
Label,
AccessibilityNode(NodeBuilder::new(Role::ListItem)),
AccessibilityNode(Accessible::new(Role::ListItem)),
))
.insert(PickingBehavior {
should_block_lower: false,