mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 21:53:07 +00:00
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:
parent
b0058dc54b
commit
817f160d35
7 changed files with 44 additions and 46 deletions
|
@ -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_ecs = { path = "../bevy_ecs", version = "0.15.0-dev" }
|
||||||
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev" }
|
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev" }
|
||||||
|
|
||||||
accesskit = "0.16"
|
accesskit = "0.17"
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
|
@ -13,7 +13,7 @@ use alloc::sync::Arc;
|
||||||
use core::sync::atomic::{AtomicBool, Ordering};
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
pub use accesskit;
|
pub use accesskit;
|
||||||
use accesskit::NodeBuilder;
|
use accesskit::Node;
|
||||||
use bevy_app::Plugin;
|
use bevy_app::Plugin;
|
||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_ecs::{
|
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
|
/// 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.
|
/// an `AccessibilityNode`, its node will be an immediate child of the primary window.
|
||||||
#[derive(Component, Clone, Deref, DerefMut)]
|
#[derive(Component, Clone, Deref, DerefMut)]
|
||||||
pub struct AccessibilityNode(pub NodeBuilder);
|
pub struct AccessibilityNode(pub Node);
|
||||||
|
|
||||||
impl From<NodeBuilder> for AccessibilityNode {
|
impl From<Node> for AccessibilityNode {
|
||||||
fn from(node: NodeBuilder) -> Self {
|
fn from(node: Node) -> Self {
|
||||||
Self(node)
|
Self(node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
ComputedNode,
|
ComputedNode,
|
||||||
};
|
};
|
||||||
use bevy_a11y::{
|
use bevy_a11y::{
|
||||||
accesskit::{NodeBuilder, Rect, Role},
|
accesskit::{Node, Rect, Role},
|
||||||
AccessibilityNode,
|
AccessibilityNode,
|
||||||
};
|
};
|
||||||
use bevy_app::{App, Plugin, PostUpdate};
|
use bevy_app::{App, Plugin, PostUpdate};
|
||||||
|
@ -19,7 +19,7 @@ use bevy_ecs::{
|
||||||
use bevy_render::{camera::CameraUpdateSystem, prelude::Camera};
|
use bevy_render::{camera::CameraUpdateSystem, prelude::Camera};
|
||||||
use bevy_transform::prelude::GlobalTransform;
|
use bevy_transform::prelude::GlobalTransform;
|
||||||
|
|
||||||
fn calc_name(
|
fn calc_label(
|
||||||
text_reader: &mut TextUiReader,
|
text_reader: &mut TextUiReader,
|
||||||
children: impl Iterator<Item = Entity>,
|
children: impl Iterator<Item = Entity>,
|
||||||
) -> Option<Box<str>> {
|
) -> Option<Box<str>> {
|
||||||
|
@ -70,18 +70,18 @@ fn button_changed(
|
||||||
mut text_reader: TextUiReader,
|
mut text_reader: TextUiReader,
|
||||||
) {
|
) {
|
||||||
for (entity, accessible) in &mut query {
|
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 {
|
if let Some(mut accessible) = accessible {
|
||||||
accessible.set_role(Role::Button);
|
accessible.set_role(Role::Button);
|
||||||
if let Some(name) = name {
|
if let Some(name) = label {
|
||||||
accessible.set_name(name);
|
accessible.set_label(name);
|
||||||
} else {
|
} else {
|
||||||
accessible.clear_name();
|
accessible.clear_label();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut node = NodeBuilder::new(Role::Button);
|
let mut node = Node::new(Role::Button);
|
||||||
if let Some(name) = name {
|
if let Some(label) = label {
|
||||||
node.set_name(name);
|
node.set_label(label);
|
||||||
}
|
}
|
||||||
commands
|
commands
|
||||||
.entity(entity)
|
.entity(entity)
|
||||||
|
@ -97,18 +97,18 @@ fn image_changed(
|
||||||
mut text_reader: TextUiReader,
|
mut text_reader: TextUiReader,
|
||||||
) {
|
) {
|
||||||
for (entity, accessible) in &mut query {
|
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 {
|
if let Some(mut accessible) = accessible {
|
||||||
accessible.set_role(Role::Image);
|
accessible.set_role(Role::Image);
|
||||||
if let Some(name) = name {
|
if let Some(label) = label {
|
||||||
accessible.set_name(name);
|
accessible.set_label(label);
|
||||||
} else {
|
} else {
|
||||||
accessible.clear_name();
|
accessible.clear_label();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut node = NodeBuilder::new(Role::Image);
|
let mut node = Node::new(Role::Image);
|
||||||
if let Some(name) = name {
|
if let Some(label) = label {
|
||||||
node.set_name(name);
|
node.set_label(label);
|
||||||
}
|
}
|
||||||
commands
|
commands
|
||||||
.entity(entity)
|
.entity(entity)
|
||||||
|
@ -127,18 +127,18 @@ fn label_changed(
|
||||||
.iter(entity)
|
.iter(entity)
|
||||||
.map(|(_, _, text, _, _)| text.into())
|
.map(|(_, _, text, _, _)| text.into())
|
||||||
.collect::<Vec<String>>();
|
.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 {
|
if let Some(mut accessible) = accessible {
|
||||||
accessible.set_role(Role::Label);
|
accessible.set_role(Role::Label);
|
||||||
if let Some(name) = name {
|
if let Some(label) = label {
|
||||||
accessible.set_name(name);
|
accessible.set_label(label);
|
||||||
} else {
|
} else {
|
||||||
accessible.clear_name();
|
accessible.clear_label();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut node = NodeBuilder::new(Role::Label);
|
let mut node = Node::new(Role::Label);
|
||||||
if let Some(name) = name {
|
if let Some(label) = label {
|
||||||
node.set_name(name);
|
node.set_label(label);
|
||||||
}
|
}
|
||||||
commands
|
commands
|
||||||
.entity(entity)
|
.entity(entity)
|
||||||
|
|
|
@ -43,7 +43,7 @@ bevy_image = { path = "../bevy_image", version = "0.15.0-dev", optional = true }
|
||||||
# other
|
# other
|
||||||
# feature rwh_06 refers to window_raw_handle@v0.6
|
# feature rwh_06 refers to window_raw_handle@v0.6
|
||||||
winit = { version = "0.30", default-features = false, features = ["rwh_06"] }
|
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",
|
"rwh_06",
|
||||||
] }
|
] }
|
||||||
approx = { version = "0.5", default-features = false }
|
approx = { version = "0.5", default-features = false }
|
||||||
|
|
|
@ -6,8 +6,8 @@ use std::sync::Mutex;
|
||||||
use accesskit_winit::Adapter;
|
use accesskit_winit::Adapter;
|
||||||
use bevy_a11y::{
|
use bevy_a11y::{
|
||||||
accesskit::{
|
accesskit::{
|
||||||
ActionHandler, ActionRequest, ActivationHandler, DeactivationHandler, Node, NodeBuilder,
|
ActionHandler, ActionRequest, ActivationHandler, DeactivationHandler, Node, NodeId, Role,
|
||||||
NodeId, Role, Tree, TreeUpdate,
|
Tree, TreeUpdate,
|
||||||
},
|
},
|
||||||
AccessibilityNode, AccessibilityRequested, AccessibilitySystem,
|
AccessibilityNode, AccessibilityRequested, AccessibilitySystem,
|
||||||
ActionRequest as ActionRequestWrapper, Focus, ManageAccessibilityUpdates,
|
ActionRequest as ActionRequestWrapper, Focus, ManageAccessibilityUpdates,
|
||||||
|
@ -64,9 +64,9 @@ impl AccessKitState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_root(&mut self) -> Node {
|
fn build_root(&mut self) -> Node {
|
||||||
let mut builder = NodeBuilder::new(Role::Window);
|
let mut node = Node::new(Role::Window);
|
||||||
builder.set_name(self.name.clone());
|
node.set_label(self.name.clone());
|
||||||
builder.build()
|
node
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_initial_tree(&mut self) -> TreeUpdate {
|
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);
|
queue_node_for_update(entity, parent, &node_entities, &mut window_children);
|
||||||
add_children_nodes(children, &node_entities, &mut node);
|
add_children_nodes(children, &node_entities, &mut node);
|
||||||
let node_id = NodeId(entity.to_bits());
|
let node_id = NodeId(entity.to_bits());
|
||||||
let node = node.build();
|
|
||||||
to_update.push((node_id, node));
|
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 {
|
if primary_window.focused {
|
||||||
let title = primary_window.title.clone();
|
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);
|
window_node.set_children(window_children);
|
||||||
let window_node = window_node.build();
|
|
||||||
let node_id = NodeId(primary_window_id.to_bits());
|
let node_id = NodeId(primary_window_id.to_bits());
|
||||||
let window_update = (node_id, window_node);
|
let window_update = (node_id, window_node);
|
||||||
to_update.insert(0, window_update);
|
to_update.insert(0, window_update);
|
||||||
|
@ -268,7 +266,7 @@ fn queue_node_for_update(
|
||||||
fn add_children_nodes(
|
fn add_children_nodes(
|
||||||
children: Option<&Children>,
|
children: Option<&Children>,
|
||||||
node_entities: &Query<Entity, With<AccessibilityNode>>,
|
node_entities: &Query<Entity, With<AccessibilityNode>>,
|
||||||
node: &mut NodeBuilder,
|
node: &mut Node,
|
||||||
) {
|
) {
|
||||||
let Some(children) = children else {
|
let Some(children) = children else {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
a11y::{
|
a11y::{
|
||||||
accesskit::{NodeBuilder, Role},
|
accesskit::{Node as Accessible, Role},
|
||||||
AccessibilityNode,
|
AccessibilityNode,
|
||||||
},
|
},
|
||||||
input::mouse::{MouseScrollUnit, MouseWheel},
|
input::mouse::{MouseScrollUnit, MouseWheel},
|
||||||
|
@ -79,7 +79,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Label,
|
Label,
|
||||||
AccessibilityNode(NodeBuilder::new(Role::ListItem)),
|
AccessibilityNode(Accessible::new(Role::ListItem)),
|
||||||
))
|
))
|
||||||
.insert(Node {
|
.insert(Node {
|
||||||
min_width: Val::Px(200.),
|
min_width: Val::Px(200.),
|
||||||
|
@ -167,7 +167,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Label,
|
Label,
|
||||||
AccessibilityNode(NodeBuilder::new(
|
AccessibilityNode(Accessible::new(
|
||||||
Role::ListItem,
|
Role::ListItem,
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
|
@ -234,7 +234,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Label,
|
Label,
|
||||||
AccessibilityNode(NodeBuilder::new(
|
AccessibilityNode(Accessible::new(
|
||||||
Role::ListItem,
|
Role::ListItem,
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
|
@ -310,7 +310,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Label,
|
Label,
|
||||||
AccessibilityNode(NodeBuilder::new(
|
AccessibilityNode(Accessible::new(
|
||||||
Role::ListItem,
|
Role::ListItem,
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::f32::consts::PI;
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
a11y::{
|
a11y::{
|
||||||
accesskit::{NodeBuilder, Role},
|
accesskit::{Node as Accessible, Role},
|
||||||
AccessibilityNode,
|
AccessibilityNode,
|
||||||
},
|
},
|
||||||
color::palettes::{basic::LIME, css::DARK_GRAY},
|
color::palettes::{basic::LIME, css::DARK_GRAY},
|
||||||
|
@ -149,7 +149,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Label,
|
Label,
|
||||||
AccessibilityNode(NodeBuilder::new(Role::ListItem)),
|
AccessibilityNode(Accessible::new(Role::ListItem)),
|
||||||
))
|
))
|
||||||
.insert(PickingBehavior {
|
.insert(PickingBehavior {
|
||||||
should_block_lower: false,
|
should_block_lower: false,
|
||||||
|
|
Loading…
Reference in a new issue