mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Remove accesskit feature and always depend on accesskit (#7701)
* Closes #3137 With this, `egui` will always depend on `accesskit`, removing a lot of `#[cfg(feature = "accesskit")]` throughout the code.
This commit is contained in:
@@ -40,7 +40,7 @@ default = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/).
|
## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/).
|
||||||
accesskit = ["egui/accesskit", "egui-winit/accesskit"]
|
accesskit = ["egui-winit/accesskit"]
|
||||||
|
|
||||||
# Allow crates to choose an android-activity backend via Winit
|
# Allow crates to choose an android-activity backend via Winit
|
||||||
# - It's important that most applications should not have to depend on android-activity directly, and can
|
# - It's important that most applications should not have to depend on android-activity directly, and can
|
||||||
|
|||||||
@@ -324,8 +324,7 @@ impl AppRunner {
|
|||||||
events: _, // already handled
|
events: _, // already handled
|
||||||
mutable_text_under_cursor: _, // TODO(#4569): https://github.com/emilk/egui/issues/4569
|
mutable_text_under_cursor: _, // TODO(#4569): https://github.com/emilk/egui/issues/4569
|
||||||
ime,
|
ime,
|
||||||
#[cfg(feature = "accesskit")]
|
accesskit_update: _, // not currently implemented
|
||||||
accesskit_update: _, // not currently implemented
|
|
||||||
num_completed_passes: _, // handled by `Context::run`
|
num_completed_passes: _, // handled by `Context::run`
|
||||||
request_discard_reasons: _, // handled by `Context::run`
|
request_discard_reasons: _, // handled by `Context::run`
|
||||||
} = platform_output;
|
} = platform_output;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ rustdoc-args = ["--generate-link-to-definition"]
|
|||||||
default = ["clipboard", "links", "wayland", "winit/default", "x11"]
|
default = ["clipboard", "links", "wayland", "winit/default", "x11"]
|
||||||
|
|
||||||
## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/).
|
## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/).
|
||||||
accesskit = ["dep:accesskit_winit", "egui/accesskit"]
|
accesskit = ["dep:accesskit_winit"]
|
||||||
|
|
||||||
# Allow crates to choose an android-activity backend via Winit
|
# Allow crates to choose an android-activity backend via Winit
|
||||||
# - It's important that most applications should not have to depend on android-activity directly, and can
|
# - It's important that most applications should not have to depend on android-activity directly, and can
|
||||||
|
|||||||
@@ -888,7 +888,6 @@ impl State {
|
|||||||
events: _, // handled elsewhere
|
events: _, // handled elsewhere
|
||||||
mutable_text_under_cursor: _, // only used in eframe web
|
mutable_text_under_cursor: _, // only used in eframe web
|
||||||
ime,
|
ime,
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
accesskit_update,
|
accesskit_update,
|
||||||
num_completed_passes: _, // `egui::Context::run` handles this
|
num_completed_passes: _, // `egui::Context::run` handles this
|
||||||
request_discard_reasons: _, // `egui::Context::run` handles this
|
request_discard_reasons: _, // `egui::Context::run` handles this
|
||||||
@@ -947,6 +946,9 @@ impl State {
|
|||||||
profiling::scope!("accesskit");
|
profiling::scope!("accesskit");
|
||||||
accesskit.update_if_active(|| update);
|
accesskit.update_if_active(|| update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "accesskit"))]
|
||||||
|
let _ = accesskit_update;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_cursor_icon(&mut self, window: &Window, cursor_icon: egui::CursorIcon) {
|
fn set_cursor_icon(&mut self, window: &Window, cursor_icon: egui::CursorIcon) {
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ rustdoc-args = ["--generate-link-to-definition"]
|
|||||||
[features]
|
[features]
|
||||||
default = ["default_fonts"]
|
default = ["default_fonts"]
|
||||||
|
|
||||||
## Exposes detailed accessibility implementation required by platform
|
|
||||||
## accessibility APIs. Also requires support in the egui integration.
|
|
||||||
accesskit = ["dep:accesskit"]
|
|
||||||
|
|
||||||
## [`bytemuck`](https://docs.rs/bytemuck) enables you to cast [`epaint::Vertex`], [`emath::Vec2`] etc to `&[u8]`.
|
## [`bytemuck`](https://docs.rs/bytemuck) enables you to cast [`epaint::Vertex`], [`emath::Vec2`] etc to `&[u8]`.
|
||||||
bytemuck = ["epaint/bytemuck"]
|
bytemuck = ["epaint/bytemuck"]
|
||||||
|
|
||||||
@@ -61,7 +57,7 @@ persistence = ["serde", "epaint/serde", "ron"]
|
|||||||
rayon = ["epaint/rayon"]
|
rayon = ["epaint/rayon"]
|
||||||
|
|
||||||
## Allow serialization using [`serde`](https://docs.rs/serde).
|
## Allow serialization using [`serde`](https://docs.rs/serde).
|
||||||
serde = ["dep:serde", "epaint/serde", "accesskit?/serde"]
|
serde = ["dep:serde", "epaint/serde", "accesskit/serde"]
|
||||||
|
|
||||||
## Change Vertex layout to be compatible with unity
|
## Change Vertex layout to be compatible with unity
|
||||||
unity = ["epaint/unity"]
|
unity = ["epaint/unity"]
|
||||||
@@ -75,6 +71,7 @@ _override_unity = ["epaint/_override_unity"]
|
|||||||
emath = { workspace = true, default-features = false }
|
emath = { workspace = true, default-features = false }
|
||||||
epaint = { workspace = true, default-features = false }
|
epaint = { workspace = true, default-features = false }
|
||||||
|
|
||||||
|
accesskit.workspace = true
|
||||||
ahash.workspace = true
|
ahash.workspace = true
|
||||||
bitflags.workspace = true
|
bitflags.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
@@ -84,7 +81,6 @@ smallvec.workspace = true
|
|||||||
unicode-segmentation.workspace = true
|
unicode-segmentation.workspace = true
|
||||||
|
|
||||||
#! ### Optional dependencies
|
#! ### Optional dependencies
|
||||||
accesskit = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
backtrace = { workspace = true, optional = true }
|
backtrace = { workspace = true, optional = true }
|
||||||
|
|
||||||
|
|||||||
@@ -899,7 +899,6 @@ fn resize_interaction(
|
|||||||
let rect = outer_rect.shrink(window_frame.stroke.width / 2.0);
|
let rect = outer_rect.shrink(window_frame.stroke.width / 2.0);
|
||||||
|
|
||||||
let side_response = |rect, id| {
|
let side_response = |rect, id| {
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
ctx.register_accesskit_parent(id, _accessibility_parent);
|
ctx.register_accesskit_parent(id, _accessibility_parent);
|
||||||
let response = ctx.create_widget(
|
let response = ctx.create_widget(
|
||||||
WidgetRect {
|
WidgetRect {
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ use crate::{
|
|||||||
viewport::ViewportClass,
|
viewport::ViewportClass,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
use crate::IdMap;
|
use crate::IdMap;
|
||||||
|
|
||||||
/// Information given to the backend about when it is time to repaint the ui.
|
/// Information given to the backend about when it is time to repaint the ui.
|
||||||
@@ -404,7 +403,6 @@ struct ContextImpl {
|
|||||||
|
|
||||||
embed_viewports: bool,
|
embed_viewports: bool,
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
is_accesskit_enabled: bool,
|
is_accesskit_enabled: bool,
|
||||||
|
|
||||||
loaders: Arc<Loaders>,
|
loaders: Arc<Loaders>,
|
||||||
@@ -507,7 +505,6 @@ impl ContextImpl {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
if self.is_accesskit_enabled {
|
if self.is_accesskit_enabled {
|
||||||
profiling::scope!("accesskit");
|
profiling::scope!("accesskit");
|
||||||
use crate::pass_state::AccessKitPassState;
|
use crate::pass_state::AccessKitPassState;
|
||||||
@@ -589,10 +586,10 @@ impl ContextImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
fn accesskit_node_builder(&mut self, id: Id) -> &mut accesskit::Node {
|
fn accesskit_node_builder(&mut self, id: Id) -> &mut accesskit::Node {
|
||||||
let state = self.viewport().this_pass.accesskit_state.as_mut().unwrap();
|
let state = self.viewport().this_pass.accesskit_state.as_mut().unwrap();
|
||||||
let builders = &mut state.nodes;
|
let builders = &mut state.nodes;
|
||||||
|
|
||||||
if let std::collections::hash_map::Entry::Vacant(entry) = builders.entry(id) {
|
if let std::collections::hash_map::Entry::Vacant(entry) = builders.entry(id) {
|
||||||
entry.insert(Default::default());
|
entry.insert(Default::default());
|
||||||
|
|
||||||
@@ -619,6 +616,7 @@ impl ContextImpl {
|
|||||||
let parent_builder = builders.get_mut(&parent_id).unwrap();
|
let parent_builder = builders.get_mut(&parent_id).unwrap();
|
||||||
parent_builder.push_child(id.accesskit_id());
|
parent_builder.push_child(id.accesskit_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
builders.get_mut(&id).unwrap()
|
builders.get_mut(&id).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1204,7 +1202,6 @@ impl Context {
|
|||||||
plugins.on_widget_under_pointer(self, &w);
|
plugins.on_widget_under_pointer(self, &w);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
if allow_focus && w.sense.is_focusable() {
|
if allow_focus && w.sense.is_focusable() {
|
||||||
// Make sure anything that can receive focus has an AccessKit node.
|
// Make sure anything that can receive focus has an AccessKit node.
|
||||||
// TODO(mwcampbell): For nodes that are filled from widget info,
|
// TODO(mwcampbell): For nodes that are filled from widget info,
|
||||||
@@ -1212,7 +1209,6 @@ impl Context {
|
|||||||
self.accesskit_node_builder(w.id, |builder| res.fill_accesskit_node_common(builder));
|
self.accesskit_node_builder(w.id, |builder| res.fill_accesskit_node_common(builder));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
self.write(|ctx| {
|
self.write(|ctx| {
|
||||||
use crate::{Align, pass_state::ScrollTarget, style::ScrollAnimation};
|
use crate::{Align, pass_state::ScrollTarget, style::ScrollAnimation};
|
||||||
let viewport = ctx.viewport_for(ctx.viewport_id());
|
let viewport = ctx.viewport_for(ctx.viewport_id());
|
||||||
@@ -1220,12 +1216,14 @@ impl Context {
|
|||||||
viewport
|
viewport
|
||||||
.input
|
.input
|
||||||
.consume_accesskit_action_requests(res.id, |request| {
|
.consume_accesskit_action_requests(res.id, |request| {
|
||||||
|
use accesskit::Action;
|
||||||
|
|
||||||
// TODO(lucasmerlin): Correctly handle the scroll unit:
|
// TODO(lucasmerlin): Correctly handle the scroll unit:
|
||||||
// https://github.com/AccessKit/accesskit/blob/e639c0e0d8ccbfd9dff302d972fa06f9766d608e/common/src/lib.rs#L2621
|
// https://github.com/AccessKit/accesskit/blob/e639c0e0d8ccbfd9dff302d972fa06f9766d608e/common/src/lib.rs#L2621
|
||||||
const DISTANCE: f32 = 100.0;
|
const DISTANCE: f32 = 100.0;
|
||||||
|
|
||||||
match &request.action {
|
match &request.action {
|
||||||
accesskit::Action::ScrollIntoView => {
|
Action::ScrollIntoView => {
|
||||||
viewport.this_pass.scroll_target = [
|
viewport.this_pass.scroll_target = [
|
||||||
Some(ScrollTarget::new(
|
Some(ScrollTarget::new(
|
||||||
res.rect.x_range(),
|
res.rect.x_range(),
|
||||||
@@ -1239,16 +1237,16 @@ impl Context {
|
|||||||
)),
|
)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
accesskit::Action::ScrollDown => {
|
Action::ScrollDown => {
|
||||||
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::UP;
|
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::UP;
|
||||||
}
|
}
|
||||||
accesskit::Action::ScrollUp => {
|
Action::ScrollUp => {
|
||||||
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::DOWN;
|
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::DOWN;
|
||||||
}
|
}
|
||||||
accesskit::Action::ScrollLeft => {
|
Action::ScrollLeft => {
|
||||||
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::LEFT;
|
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::LEFT;
|
||||||
}
|
}
|
||||||
accesskit::Action::ScrollRight => {
|
Action::ScrollRight => {
|
||||||
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::RIGHT;
|
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::RIGHT;
|
||||||
}
|
}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
@@ -1341,7 +1339,6 @@ impl Context {
|
|||||||
res.flags.set(Flags::FAKE_PRIMARY_CLICKED, true);
|
res.flags.set(Flags::FAKE_PRIMARY_CLICKED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
if enabled
|
if enabled
|
||||||
&& sense.senses_click()
|
&& sense.senses_click()
|
||||||
&& input.has_accesskit_action_request(id, accesskit::Action::Click)
|
&& input.has_accesskit_action_request(id, accesskit::Action::Click)
|
||||||
@@ -2498,7 +2495,6 @@ impl ContextImpl {
|
|||||||
|
|
||||||
let mut platform_output: PlatformOutput = std::mem::take(&mut viewport.output);
|
let mut platform_output: PlatformOutput = std::mem::take(&mut viewport.output);
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
{
|
{
|
||||||
profiling::scope!("accesskit");
|
profiling::scope!("accesskit");
|
||||||
let state = viewport.this_pass.accesskit_state.take();
|
let state = viewport.this_pass.accesskit_state.take();
|
||||||
@@ -3497,9 +3493,8 @@ impl Context {
|
|||||||
///
|
///
|
||||||
/// The `Context` lock is held while the given closure is called!
|
/// The `Context` lock is held while the given closure is called!
|
||||||
///
|
///
|
||||||
/// Returns `None` if acesskit is off.
|
/// Returns `None` if accesskit is off.
|
||||||
// TODO(emilk): consider making both read-only and read-write versions
|
// TODO(emilk): consider making both read-only and read-write versions
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn accesskit_node_builder<R>(
|
pub fn accesskit_node_builder<R>(
|
||||||
&self,
|
&self,
|
||||||
id: Id,
|
id: Id,
|
||||||
@@ -3515,7 +3510,6 @@ impl Context {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub(crate) fn register_accesskit_parent(&self, id: Id, parent_id: Id) {
|
pub(crate) fn register_accesskit_parent(&self, id: Id, parent_id: Id) {
|
||||||
self.write(|ctx| {
|
self.write(|ctx| {
|
||||||
if let Some(state) = ctx.viewport().this_pass.accesskit_state.as_mut() {
|
if let Some(state) = ctx.viewport().this_pass.accesskit_state.as_mut() {
|
||||||
@@ -3525,13 +3519,11 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Enable generation of AccessKit tree updates in all future frames.
|
/// Enable generation of AccessKit tree updates in all future frames.
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn enable_accesskit(&self) {
|
pub fn enable_accesskit(&self) {
|
||||||
self.write(|ctx| ctx.is_accesskit_enabled = true);
|
self.write(|ctx| ctx.is_accesskit_enabled = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disable generation of AccessKit tree updates in all future frames.
|
/// Disable generation of AccessKit tree updates in all future frames.
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn disable_accesskit(&self) {
|
pub fn disable_accesskit(&self) {
|
||||||
self.write(|ctx| ctx.is_accesskit_enabled = false);
|
self.write(|ctx| ctx.is_accesskit_enabled = false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -548,7 +548,6 @@ pub enum Event {
|
|||||||
WindowFocused(bool),
|
WindowFocused(bool),
|
||||||
|
|
||||||
/// An assistive technology (e.g. screen reader) requested an action.
|
/// An assistive technology (e.g. screen reader) requested an action.
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
AccessKitActionRequest(accesskit::ActionRequest),
|
AccessKitActionRequest(accesskit::ActionRequest),
|
||||||
|
|
||||||
/// The reply of a screenshot requested with [`crate::ViewportCommand::Screenshot`].
|
/// The reply of a screenshot requested with [`crate::ViewportCommand::Screenshot`].
|
||||||
|
|||||||
@@ -128,7 +128,6 @@ pub struct PlatformOutput {
|
|||||||
/// The difference in the widget tree since last frame.
|
/// The difference in the widget tree since last frame.
|
||||||
///
|
///
|
||||||
/// NOTE: this needs to be per-viewport.
|
/// NOTE: this needs to be per-viewport.
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub accesskit_update: Option<accesskit::TreeUpdate>,
|
pub accesskit_update: Option<accesskit::TreeUpdate>,
|
||||||
|
|
||||||
/// How many ui passes is this the sum of?
|
/// How many ui passes is this the sum of?
|
||||||
@@ -175,7 +174,6 @@ impl PlatformOutput {
|
|||||||
mut events,
|
mut events,
|
||||||
mutable_text_under_cursor,
|
mutable_text_under_cursor,
|
||||||
ime,
|
ime,
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
accesskit_update,
|
accesskit_update,
|
||||||
num_completed_passes,
|
num_completed_passes,
|
||||||
mut request_discard_reasons,
|
mut request_discard_reasons,
|
||||||
@@ -190,12 +188,8 @@ impl PlatformOutput {
|
|||||||
self.request_discard_reasons
|
self.request_discard_reasons
|
||||||
.append(&mut request_discard_reasons);
|
.append(&mut request_discard_reasons);
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
// egui produces a complete AccessKit tree for each frame, so overwrite rather than append:
|
||||||
{
|
self.accesskit_update = accesskit_update;
|
||||||
// egui produces a complete AccessKit tree for each frame,
|
|
||||||
// so overwrite rather than appending.
|
|
||||||
self.accesskit_update = accesskit_update;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Take everything ephemeral (everything except `cursor_icon` currently)
|
/// Take everything ephemeral (everything except `cursor_icon` currently)
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ impl Id {
|
|||||||
self.0.get()
|
self.0.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub(crate) fn accesskit_id(&self) -> accesskit::NodeId {
|
pub(crate) fn accesskit_id(&self) -> accesskit::NodeId {
|
||||||
self.value().into()
|
self.value().into()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -855,7 +855,6 @@ impl InputState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn accesskit_action_requests(
|
pub fn accesskit_action_requests(
|
||||||
&self,
|
&self,
|
||||||
id: crate::Id,
|
id: crate::Id,
|
||||||
@@ -873,7 +872,6 @@ impl InputState {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn consume_accesskit_action_requests(
|
pub fn consume_accesskit_action_requests(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: crate::Id,
|
id: crate::Id,
|
||||||
@@ -890,12 +888,10 @@ impl InputState {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn has_accesskit_action_request(&self, id: crate::Id, action: accesskit::Action) -> bool {
|
pub fn has_accesskit_action_request(&self, id: crate::Id, action: accesskit::Action) -> bool {
|
||||||
self.accesskit_action_requests(id, action).next().is_some()
|
self.accesskit_action_requests(id, action).next().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn num_accesskit_action_requests(&self, id: crate::Id, action: accesskit::Action) -> usize {
|
pub fn num_accesskit_action_requests(&self, id: crate::Id, action: accesskit::Action) -> usize {
|
||||||
self.accesskit_action_requests(id, action).count()
|
self.accesskit_action_requests(id, action).count()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,7 +448,6 @@ pub mod widgets;
|
|||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
mod callstack;
|
mod callstack;
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub use accesskit;
|
pub use accesskit;
|
||||||
|
|
||||||
#[deprecated = "Use the ahash crate directly."]
|
#[deprecated = "Use the ahash crate directly."]
|
||||||
@@ -708,7 +707,6 @@ pub fn __run_test_ui(add_contents: impl Fn(&mut Ui)) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn accesskit_root_id() -> Id {
|
pub fn accesskit_root_id() -> Id {
|
||||||
Id::new("accesskit_root")
|
Id::new("accesskit_root")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -470,7 +470,6 @@ pub(crate) struct Focus {
|
|||||||
/// The ID of a widget to give the focus to in the next frame.
|
/// The ID of a widget to give the focus to in the next frame.
|
||||||
id_next_frame: Option<Id>,
|
id_next_frame: Option<Id>,
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
id_requested_by_accesskit: Option<accesskit::NodeId>,
|
id_requested_by_accesskit: Option<accesskit::NodeId>,
|
||||||
|
|
||||||
/// If set, the next widget that is interested in focus will automatically get it.
|
/// If set, the next widget that is interested in focus will automatically get it.
|
||||||
@@ -529,10 +528,7 @@ impl Focus {
|
|||||||
}
|
}
|
||||||
let event_filter = self.focused_widget.map(|w| w.filter).unwrap_or_default();
|
let event_filter = self.focused_widget.map(|w| w.filter).unwrap_or_default();
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
self.id_requested_by_accesskit = None;
|
||||||
{
|
|
||||||
self.id_requested_by_accesskit = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.focus_direction = FocusDirection::None;
|
self.focus_direction = FocusDirection::None;
|
||||||
|
|
||||||
@@ -567,16 +563,13 @@ impl Focus {
|
|||||||
self.focus_direction = cardinality;
|
self.focus_direction = cardinality;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
if let crate::Event::AccessKitActionRequest(accesskit::ActionRequest {
|
||||||
|
action: accesskit::Action::Focus,
|
||||||
|
target,
|
||||||
|
data: None,
|
||||||
|
}) = event
|
||||||
{
|
{
|
||||||
if let crate::Event::AccessKitActionRequest(accesskit::ActionRequest {
|
self.id_requested_by_accesskit = Some(*target);
|
||||||
action: accesskit::Action::Focus,
|
|
||||||
target,
|
|
||||||
data: None,
|
|
||||||
}) = event
|
|
||||||
{
|
|
||||||
self.id_requested_by_accesskit = Some(*target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -606,14 +599,11 @@ impl Focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn interested_in_focus(&mut self, id: Id) {
|
fn interested_in_focus(&mut self, id: Id) {
|
||||||
#[cfg(feature = "accesskit")]
|
if self.id_requested_by_accesskit == Some(id.accesskit_id()) {
|
||||||
{
|
self.focused_widget = Some(FocusWidget::new(id));
|
||||||
if self.id_requested_by_accesskit == Some(id.accesskit_id()) {
|
self.id_requested_by_accesskit = None;
|
||||||
self.focused_widget = Some(FocusWidget::new(id));
|
self.give_to_next = false;
|
||||||
self.id_requested_by_accesskit = None;
|
self.reset_focus();
|
||||||
self.give_to_next = false;
|
|
||||||
self.reset_focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The rect is updated at the end of the frame.
|
// The rect is updated at the end of the frame.
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ impl ScrollTarget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AccessKitPassState {
|
pub struct AccessKitPassState {
|
||||||
pub nodes: IdMap<accesskit::Node>,
|
pub nodes: IdMap<accesskit::Node>,
|
||||||
@@ -225,7 +224,6 @@ pub struct PassState {
|
|||||||
/// as when swiping down on a touch-screen or track-pad with natural scrolling.
|
/// as when swiping down on a touch-screen or track-pad with natural scrolling.
|
||||||
pub scroll_delta: (Vec2, style::ScrollAnimation),
|
pub scroll_delta: (Vec2, style::ScrollAnimation),
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub accesskit_state: Option<AccessKitPassState>,
|
pub accesskit_state: Option<AccessKitPassState>,
|
||||||
|
|
||||||
/// Highlight these widgets the next pass.
|
/// Highlight these widgets the next pass.
|
||||||
@@ -247,7 +245,6 @@ impl Default for PassState {
|
|||||||
used_by_panels: Rect::NAN,
|
used_by_panels: Rect::NAN,
|
||||||
scroll_target: [None, None],
|
scroll_target: [None, None],
|
||||||
scroll_delta: (Vec2::default(), style::ScrollAnimation::none()),
|
scroll_delta: (Vec2::default(), style::ScrollAnimation::none()),
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
accesskit_state: None,
|
accesskit_state: None,
|
||||||
highlight_next_pass: Default::default(),
|
highlight_next_pass: Default::default(),
|
||||||
|
|
||||||
@@ -270,7 +267,6 @@ impl PassState {
|
|||||||
used_by_panels,
|
used_by_panels,
|
||||||
scroll_target,
|
scroll_target,
|
||||||
scroll_delta,
|
scroll_delta,
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
accesskit_state,
|
accesskit_state,
|
||||||
highlight_next_pass,
|
highlight_next_pass,
|
||||||
|
|
||||||
@@ -293,10 +289,7 @@ impl PassState {
|
|||||||
*debug_rect = None;
|
*debug_rect = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
*accesskit_state = None;
|
||||||
{
|
|
||||||
*accesskit_state = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
highlight_next_pass.clear();
|
highlight_next_pass.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -793,7 +793,6 @@ impl Response {
|
|||||||
if let Some(event) = event {
|
if let Some(event) = event {
|
||||||
self.output_event(event);
|
self.output_event(event);
|
||||||
} else {
|
} else {
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
self.ctx.accesskit_node_builder(self.id, |builder| {
|
self.ctx.accesskit_node_builder(self.id, |builder| {
|
||||||
self.fill_accesskit_node_from_widget_info(builder, make_info());
|
self.fill_accesskit_node_from_widget_info(builder, make_info());
|
||||||
});
|
});
|
||||||
@@ -803,7 +802,6 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn output_event(&self, event: crate::output::OutputEvent) {
|
pub fn output_event(&self, event: crate::output::OutputEvent) {
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
self.ctx.accesskit_node_builder(self.id, |builder| {
|
self.ctx.accesskit_node_builder(self.id, |builder| {
|
||||||
self.fill_accesskit_node_from_widget_info(builder, event.widget_info().clone());
|
self.fill_accesskit_node_from_widget_info(builder, event.widget_info().clone());
|
||||||
});
|
});
|
||||||
@@ -814,7 +812,6 @@ impl Response {
|
|||||||
self.ctx.output_mut(|o| o.events.push(event));
|
self.ctx.output_mut(|o| o.events.push(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub(crate) fn fill_accesskit_node_common(&self, builder: &mut accesskit::Node) {
|
pub(crate) fn fill_accesskit_node_common(&self, builder: &mut accesskit::Node) {
|
||||||
if !self.enabled() {
|
if !self.enabled() {
|
||||||
builder.set_disabled();
|
builder.set_disabled();
|
||||||
@@ -833,7 +830,6 @@ impl Response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
fn fill_accesskit_node_from_widget_info(
|
fn fill_accesskit_node_from_widget_info(
|
||||||
&self,
|
&self,
|
||||||
builder: &mut accesskit::Node,
|
builder: &mut accesskit::Node,
|
||||||
@@ -908,14 +904,9 @@ impl Response {
|
|||||||
/// # });
|
/// # });
|
||||||
/// ```
|
/// ```
|
||||||
pub fn labelled_by(self, id: Id) -> Self {
|
pub fn labelled_by(self, id: Id) -> Self {
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
self.ctx.accesskit_node_builder(self.id, |builder| {
|
self.ctx.accesskit_node_builder(self.id, |builder| {
|
||||||
builder.push_labelled_by(id.accesskit_id());
|
builder.push_labelled_by(id.accesskit_id());
|
||||||
});
|
});
|
||||||
#[cfg(not(feature = "accesskit"))]
|
|
||||||
{
|
|
||||||
let _ = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ pub fn update_accesskit_for_text_widget(
|
|||||||
|
|
||||||
for (row_index, row) in galley.rows.iter().enumerate() {
|
for (row_index, row) in galley.rows.iter().enumerate() {
|
||||||
let row_id = parent_id.with(row_index);
|
let row_id = parent_id.with(row_index);
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
ctx.register_accesskit_parent(row_id, parent_id);
|
ctx.register_accesskit_parent(row_id, parent_id);
|
||||||
|
|
||||||
ctx.accesskit_node_builder(row_id, |builder| {
|
ctx.accesskit_node_builder(row_id, |builder| {
|
||||||
builder.set_role(accesskit::Role::TextRun);
|
builder.set_role(accesskit::Role::TextRun);
|
||||||
let rect = global_from_galley * row.rect_without_leading_space();
|
let rect = global_from_galley * row.rect_without_leading_space();
|
||||||
|
|||||||
@@ -190,7 +190,6 @@ impl CCursorRange {
|
|||||||
..
|
..
|
||||||
} => self.on_key_press(os, galley, modifiers, *key),
|
} => self.on_key_press(os, galley, modifiers, *key),
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
Event::AccessKitActionRequest(accesskit::ActionRequest {
|
Event::AccessKitActionRequest(accesskit::ActionRequest {
|
||||||
action: accesskit::Action::SetTextSelection,
|
action: accesskit::Action::SetTextSelection,
|
||||||
target,
|
target,
|
||||||
@@ -220,7 +219,6 @@ impl CCursorRange {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
fn ccursor_from_accesskit_text_position(
|
fn ccursor_from_accesskit_text_position(
|
||||||
id: Id,
|
id: Id,
|
||||||
galley: &Galley,
|
galley: &Galley,
|
||||||
|
|||||||
@@ -624,7 +624,6 @@ impl LabelSelectionState {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
super::accesskit_text::update_accesskit_for_text_widget(
|
super::accesskit_text::update_accesskit_for_text_widget(
|
||||||
ui.ctx(),
|
ui.ctx(),
|
||||||
response.id,
|
response.id,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
//! Helpers regarding text selection for labels and text edit.
|
//! Helpers regarding text selection for labels and text edit.
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub mod accesskit_text;
|
pub mod accesskit_text;
|
||||||
|
|
||||||
mod cursor_range;
|
mod cursor_range;
|
||||||
|
|||||||
@@ -133,7 +133,6 @@ impl Ui {
|
|||||||
sizing_pass,
|
sizing_pass,
|
||||||
style,
|
style,
|
||||||
sense,
|
sense,
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
accessibility_parent,
|
accessibility_parent,
|
||||||
} = ui_builder;
|
} = ui_builder;
|
||||||
|
|
||||||
@@ -175,7 +174,6 @@ impl Ui {
|
|||||||
min_rect_already_remembered: false,
|
min_rect_already_remembered: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
if let Some(accessibility_parent) = accessibility_parent {
|
if let Some(accessibility_parent) = accessibility_parent {
|
||||||
ui.ctx()
|
ui.ctx()
|
||||||
.register_accesskit_parent(ui.unique_id, accessibility_parent);
|
.register_accesskit_parent(ui.unique_id, accessibility_parent);
|
||||||
@@ -202,7 +200,6 @@ impl Ui {
|
|||||||
ui.set_invisible();
|
ui.set_invisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
ui.ctx().accesskit_node_builder(ui.unique_id, |node| {
|
ui.ctx().accesskit_node_builder(ui.unique_id, |node| {
|
||||||
node.set_role(accesskit::Role::GenericContainer);
|
node.set_role(accesskit::Role::GenericContainer);
|
||||||
});
|
});
|
||||||
@@ -273,7 +270,6 @@ impl Ui {
|
|||||||
sizing_pass,
|
sizing_pass,
|
||||||
style,
|
style,
|
||||||
sense,
|
sense,
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
accessibility_parent,
|
accessibility_parent,
|
||||||
} = ui_builder;
|
} = ui_builder;
|
||||||
|
|
||||||
@@ -343,7 +339,6 @@ impl Ui {
|
|||||||
child_ui.disable();
|
child_ui.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
child_ui.ctx().register_accesskit_parent(
|
child_ui.ctx().register_accesskit_parent(
|
||||||
child_ui.unique_id,
|
child_ui.unique_id,
|
||||||
accessibility_parent.unwrap_or(self.unique_id),
|
accessibility_parent.unwrap_or(self.unique_id),
|
||||||
@@ -363,7 +358,6 @@ impl Ui {
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
child_ui
|
child_ui
|
||||||
.ctx()
|
.ctx()
|
||||||
.accesskit_node_builder(child_ui.unique_id, |node| {
|
.accesskit_node_builder(child_ui.unique_id, |node| {
|
||||||
@@ -1129,7 +1123,6 @@ impl Ui {
|
|||||||
impl Ui {
|
impl Ui {
|
||||||
/// Check for clicks, drags and/or hover on a specific region of this [`Ui`].
|
/// Check for clicks, drags and/or hover on a specific region of this [`Ui`].
|
||||||
pub fn interact(&self, rect: Rect, id: Id, sense: Sense) -> Response {
|
pub fn interact(&self, rect: Rect, id: Id, sense: Sense) -> Response {
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
self.ctx().register_accesskit_parent(id, self.unique_id);
|
self.ctx().register_accesskit_parent(id, self.unique_id);
|
||||||
|
|
||||||
self.ctx().create_widget(
|
self.ctx().create_widget(
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ pub struct UiBuilder {
|
|||||||
pub sizing_pass: bool,
|
pub sizing_pass: bool,
|
||||||
pub style: Option<Arc<Style>>,
|
pub style: Option<Arc<Style>>,
|
||||||
pub sense: Option<Sense>,
|
pub sense: Option<Sense>,
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub accessibility_parent: Option<Id>,
|
pub accessibility_parent: Option<Id>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,15 +186,9 @@ impl UiBuilder {
|
|||||||
///
|
///
|
||||||
/// This will override the automatic parent assignment for accessibility purposes.
|
/// This will override the automatic parent assignment for accessibility purposes.
|
||||||
/// If not set, the parent [`Ui`]'s ID will be used as the accessibility parent.
|
/// If not set, the parent [`Ui`]'s ID will be used as the accessibility parent.
|
||||||
///
|
|
||||||
/// This does nothing if the `accesskit` feature is not enabled.
|
|
||||||
#[cfg_attr(not(feature = "accesskit"), expect(unused_mut, unused_variables))]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn accessibility_parent(mut self, parent_id: Id) -> Self {
|
pub fn accessibility_parent(mut self, parent_id: Id) -> Self {
|
||||||
#[cfg(feature = "accesskit")]
|
self.accessibility_parent = Some(parent_id);
|
||||||
{
|
|
||||||
self.accessibility_parent = Some(parent_id);
|
|
||||||
}
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -489,27 +489,21 @@ impl Widget for DragValue<'_> {
|
|||||||
- input.count_and_consume_key(Modifiers::NONE, Key::ArrowDown) as f64;
|
- input.count_and_consume_key(Modifiers::NONE, Key::ArrowDown) as f64;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
use accesskit::Action;
|
||||||
{
|
change += input.num_accesskit_action_requests(id, Action::Increment) as f64
|
||||||
use accesskit::Action;
|
- input.num_accesskit_action_requests(id, Action::Decrement) as f64;
|
||||||
change += input.num_accesskit_action_requests(id, Action::Increment) as f64
|
|
||||||
- input.num_accesskit_action_requests(id, Action::Decrement) as f64;
|
|
||||||
}
|
|
||||||
|
|
||||||
change
|
change
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
ui.input(|input| {
|
||||||
{
|
|
||||||
use accesskit::{Action, ActionData};
|
use accesskit::{Action, ActionData};
|
||||||
ui.input(|input| {
|
for request in input.accesskit_action_requests(id, Action::SetValue) {
|
||||||
for request in input.accesskit_action_requests(id, Action::SetValue) {
|
if let Some(ActionData::NumericValue(new_value)) = request.data {
|
||||||
if let Some(ActionData::NumericValue(new_value)) = request.data {
|
value = new_value;
|
||||||
value = new_value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if clamp_existing_to_range {
|
if clamp_existing_to_range {
|
||||||
value = clamp_value_to_range(value, range.clone());
|
value = clamp_value_to_range(value, range.clone());
|
||||||
@@ -669,7 +663,6 @@ impl Widget for DragValue<'_> {
|
|||||||
|
|
||||||
response.widget_info(|| WidgetInfo::drag_value(ui.is_enabled(), value));
|
response.widget_info(|| WidgetInfo::drag_value(ui.is_enabled(), value));
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
ui.ctx().accesskit_node_builder(response.id, |builder| {
|
ui.ctx().accesskit_node_builder(response.id, |builder| {
|
||||||
use accesskit::Action;
|
use accesskit::Action;
|
||||||
// If either end of the range is unbounded, it's better
|
// If either end of the range is unbounded, it's better
|
||||||
|
|||||||
@@ -716,14 +716,11 @@ impl Slider<'_> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
ui.input(|input| {
|
||||||
{
|
|
||||||
use accesskit::Action;
|
use accesskit::Action;
|
||||||
ui.input(|input| {
|
decrement += input.num_accesskit_action_requests(response.id, Action::Decrement);
|
||||||
decrement += input.num_accesskit_action_requests(response.id, Action::Decrement);
|
increment += input.num_accesskit_action_requests(response.id, Action::Increment);
|
||||||
increment += input.num_accesskit_action_requests(response.id, Action::Increment);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let kb_step = increment as f32 - decrement as f32;
|
let kb_step = increment as f32 - decrement as f32;
|
||||||
|
|
||||||
@@ -759,17 +756,14 @@ impl Slider<'_> {
|
|||||||
self.set_value(new_value);
|
self.set_value(new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
ui.input(|input| {
|
||||||
{
|
|
||||||
use accesskit::{Action, ActionData};
|
use accesskit::{Action, ActionData};
|
||||||
ui.input(|input| {
|
for request in input.accesskit_action_requests(response.id, Action::SetValue) {
|
||||||
for request in input.accesskit_action_requests(response.id, Action::SetValue) {
|
if let Some(ActionData::NumericValue(new_value)) = request.data {
|
||||||
if let Some(ActionData::NumericValue(new_value)) = request.data {
|
self.set_value(new_value);
|
||||||
self.set_value(new_value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Paint it:
|
// Paint it:
|
||||||
if ui.is_rect_visible(response.rect) {
|
if ui.is_rect_visible(response.rect) {
|
||||||
@@ -978,7 +972,6 @@ impl Slider<'_> {
|
|||||||
}
|
}
|
||||||
response.widget_info(|| WidgetInfo::slider(ui.is_enabled(), value, self.text.text()));
|
response.widget_info(|| WidgetInfo::slider(ui.is_enabled(), value, self.text.text()));
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
ui.ctx().accesskit_node_builder(response.id, |builder| {
|
ui.ctx().accesskit_node_builder(response.id, |builder| {
|
||||||
use accesskit::Action;
|
use accesskit::Action;
|
||||||
builder.set_min_numeric_value(*self.range.start());
|
builder.set_min_numeric_value(*self.range.start());
|
||||||
|
|||||||
@@ -844,7 +844,6 @@ impl TextEdit<'_> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
{
|
{
|
||||||
let role = if password {
|
let role = if password {
|
||||||
accesskit::Role::PasswordInput
|
accesskit::Role::PasswordInput
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ x11 = ["eframe?/x11"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kittest.workspace = true
|
kittest.workspace = true
|
||||||
egui = { workspace = true, features = ["accesskit"] }
|
egui.workspace = true
|
||||||
eframe = { workspace = true, optional = true }
|
eframe = { workspace = true, optional = true }
|
||||||
|
|
||||||
# wgpu dependencies
|
# wgpu dependencies
|
||||||
|
|||||||
Reference in New Issue
Block a user