1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 21:00:03 -04:00

Remove native screen reader support (#2669)

* Remove native screen reader support

Use the "accesskit" feature flag to `eframe` instead.
[AccessKit](https://github.com/AccessKit/accesskit) is the future.

`tts` was a mess to compile on many platforms, so I no longer want
the native `tts` dependency.

* Update tts to 0.25

* Update changelogs

* Turn on all feature flags for package.metadata.docs.rs

* remove tts from deny.toml skip-tree

* Update web build scripts

* Update deny.toml
This commit is contained in:
Emil Ernerfeldt
2023-02-04 11:47:36 +01:00
committed by GitHub
parent 1353a5733f
commit e4eaf99072
17 changed files with 64 additions and 204 deletions

View File

@@ -5,7 +5,8 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C
## Unreleased
* ⚠️ BREAKING: `App::clear_color` now expects you to return a raw float array ([#2666](https://github.com/emilk/egui/pull/2666)):
* ⚠️ BREAKING: `App::clear_color` now expects you to return a raw float array ([#2666](https://github.com/emilk/egui/pull/2666)).
* The `screen_reader` feature has now been renamed `web_screen_reader` and only work on web. On other platforms, use the `accesskit` feature flag instead ([#2669](https://github.com/emilk/egui/pull/2669)).
#### Desktop/Native:
* `eframe::run_native` now returns a `Result` ([#2433](https://github.com/emilk/egui/pull/2433)).

View File

@@ -14,9 +14,7 @@ keywords = ["egui", "gui", "gamedev"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[package.metadata.docs.rs]
# Avoid speech-dispatcher dependencies - see https://docs.rs/crate/eframe/0.20.0/builds/695200
no-default-features = true
features = ["document-features", "glow", "wgpu", "persistence", "wgpu"]
all-features = true
targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
[lib]
@@ -55,8 +53,10 @@ persistence = [
## `eframe` will call `puffin::GlobalProfiler::lock().new_frame()` for you
puffin = ["dep:puffin", "egui_glow?/puffin", "egui-wgpu?/puffin"]
## Enable screen reader support (requires `ctx.options_mut(|o| o.screen_reader = true);`)
screen_reader = ["egui-winit/screen_reader", "tts"]
## Enable screen reader support (requires `ctx.options_mut(|o| o.screen_reader = true);`) on web.
##
## For other platforms, use the "accesskit" feature instead.
web_screen_reader = ["tts"]
## If set, eframe will look for the env-var `EFRAME_SCREENSHOT_TO` and write a screenshot to that location, and then quit.
## This is used to generate images for the examples.
@@ -171,5 +171,5 @@ web-sys = { version = "0.3.58", features = [
# optional web:
egui-wgpu = { version = "0.20.0", path = "../egui-wgpu", optional = true } # if wgpu is used, use it without (!) winit
tts = { version = "0.24", optional = true }
tts = { version = "0.25", optional = true, default-features = false }
wgpu = { version = "0.15.0", optional = true, features = ["webgl"] }

View File

@@ -3,6 +3,7 @@ All notable changes to the `egui-winit` integration will be noted in this file.
## Unreleased
* Remove the `screen_reader` feature. Use the `accesskit` feature flag instead ([#2669](https://github.com/emilk/egui/pull/2669)).
## 0.20.1 - 2022-12-11

View File

@@ -14,8 +14,7 @@ keywords = ["winit", "egui", "gui", "gamedev"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[package.metadata.docs.rs]
# Avoid speech-dispatcher dependencies - see https://docs.rs/crate/egui-winit/0.20.0/builds/695196
features = ["document-features"]
all-features = true
[features]
@@ -37,9 +36,6 @@ links = ["webbrowser"]
## Enable profiling with the [`puffin`](https://docs.rs/puffin) crate.
puffin = ["dep:puffin"]
## Experimental support for a screen reader.
screen_reader = ["tts"]
## Allow serialization of [`WindowSettings`] using [`serde`](https://docs.rs/serde).
serde = ["egui/serde", "dep:serde"]
@@ -67,9 +63,6 @@ accesskit_winit = { version = "0.8.1", optional = true }
puffin = { version = "0.14", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
# feature screen_reader
tts = { version = "0.24", optional = true }
webbrowser = { version = "0.8.3", optional = true }
[target.'cfg(any(target_os="linux", target_os="dragonfly", target_os="freebsd", target_os="netbsd", target_os="openbsd"))'.dependencies]

View File

@@ -19,7 +19,6 @@ use egui::accesskit;
pub use winit;
pub mod clipboard;
pub mod screen_reader;
mod window_settings;
pub use window_settings::WindowSettings;
@@ -75,7 +74,6 @@ pub struct State {
current_pixels_per_point: f32,
clipboard: clipboard::Clipboard,
screen_reader: screen_reader::ScreenReader,
/// If `true`, mouse inputs will be treated as touches.
/// Useful for debugging touch support in egui.
@@ -115,7 +113,6 @@ impl State {
current_pixels_per_point: 1.0,
clipboard: clipboard::Clipboard::new(wayland_display),
screen_reader: screen_reader::ScreenReader::default(),
simulate_touch_screen: false,
pointer_touch_id: None,
@@ -615,11 +612,6 @@ impl State {
egui_ctx: &egui::Context,
platform_output: egui::PlatformOutput,
) {
if egui_ctx.options(|o| o.screen_reader) {
self.screen_reader
.speak(&platform_output.events_description());
}
let egui::PlatformOutput {
cursor_icon,
open_url,

View File

@@ -1,49 +0,0 @@
pub struct ScreenReader {
#[cfg(feature = "tts")]
tts: Option<tts::Tts>,
}
#[cfg(not(feature = "tts"))]
#[allow(clippy::derivable_impls)] // False positive
impl Default for ScreenReader {
fn default() -> Self {
Self {}
}
}
#[cfg(feature = "tts")]
impl Default for ScreenReader {
fn default() -> Self {
let tts = match tts::Tts::default() {
Ok(screen_reader) => {
tracing::debug!("Initialized screen reader.");
Some(screen_reader)
}
Err(err) => {
tracing::warn!("Failed to load screen reader: {}", err);
None
}
};
Self { tts }
}
}
impl ScreenReader {
#[cfg(not(feature = "tts"))]
#[allow(clippy::unused_self)]
pub fn speak(&mut self, _text: &str) {}
#[cfg(feature = "tts")]
pub fn speak(&mut self, text: &str) {
if text.is_empty() {
return;
}
if let Some(tts) = &mut self.tts {
tracing::debug!("Speaking: {:?}", text);
let interrupt = true;
if let Err(err) = tts.speak(text, interrupt) {
tracing::warn!("Failed to read: {}", err);
}
}
}
}

View File

@@ -103,9 +103,15 @@ pub struct Options {
/// Controls the tessellator.
pub tessellation_options: epaint::TessellationOptions,
/// This does not at all change the behavior of egui,
/// but is a signal to any backend that we want the [`crate::PlatformOutput::events`] read out loud.
/// This is a signal to any backend that we want the [`crate::PlatformOutput::events`] read out loud.
///
/// The only change to egui is that labels can be focused by pressing tab.
///
/// Screen readers is an experimental feature of egui, and not supported on all platforms.
///
/// `eframe` supports it only on web, using the `web_screen_reader` feature flag,
/// but you should consider using [AccessKit](https://github.com/AccessKit/accesskit) instead,
/// which `eframe` supports.
pub screen_reader: bool,
/// If true, the most common glyphs (ASCII) are pre-rendered to the texture atlas.

View File

@@ -20,7 +20,7 @@ default = ["glow", "persistence"]
http = ["ehttp", "image", "poll-promise", "egui_extras/image"]
persistence = ["eframe/persistence", "egui/persistence", "serde"]
screen_reader = ["eframe/screen_reader"] # experimental
web_screen_reader = ["eframe/web_screen_reader"] # experimental
serde = ["dep:serde", "egui_demo_lib/serde", "egui/serde"]
syntax_highlighting = ["egui_demo_lib/syntax_highlighting"]

View File

@@ -130,6 +130,8 @@ impl BackendPanel {
ui.separator();
#[cfg(target_arch = "wasm32")]
#[cfg(feature = "web_screen-reader")]
{
let mut screen_reader = ui.ctx().options(|o| o.screen_reader);
ui.checkbox(&mut screen_reader, "🔈 Screen reader").on_hover_text("Experimental feature: checking this will turn on the screen reader on supported platforms");

View File

@@ -3,6 +3,7 @@ All notable changes to the `egui_glium` integration will be noted in this file.
## Unreleased
* Remove the `screen_reader` feature ([#2669](https://github.com/emilk/egui/pull/2669)).
## 0.20.1 - 2022-12-11

View File

@@ -20,8 +20,7 @@ include = [
]
[package.metadata.docs.rs]
# Avoid speech-dispatcher dependencies - see https://docs.rs/crate/egui_glium/0.20.0/builds/695197
features = ["document-features"]
all-features = true
[features]
@@ -35,9 +34,6 @@ clipboard = ["egui-winit/clipboard"]
## Enable opening links in a browser when an egui hyperlink is clicked.
links = ["egui-winit/links"]
## Experimental support for a screen reader.
screen_reader = ["egui-winit/screen_reader"]
[dependencies]
egui = { version = "0.20.0", path = "../egui", default-features = false, features = [

View File

@@ -3,6 +3,7 @@ All notable changes to the `egui_glow` integration will be noted in this file.
## Unreleased
* Remove the `screen_reader` feature ([#2669](https://github.com/emilk/egui/pull/2669)).
## 0.20.1 - 2022-12-11

View File

@@ -20,8 +20,7 @@ include = [
]
[package.metadata.docs.rs]
# Avoid speech-dispatcher dependencies - see https://docs.rs/crate/egui_glow/0.20.0/builds/695194
features = ["document-features"]
all-features = true
[features]
@@ -37,9 +36,6 @@ clipboard = ["egui-winit?/clipboard"]
## enable opening links in a browser when an egui hyperlink is clicked.
links = ["egui-winit?/links"]
## Experimental support for a screen reader.
screen_reader = ["egui-winit?/screen_reader"]
## Enable profiling with the [`puffin`](https://docs.rs/puffin) crate.
puffin = ["dep:puffin", "egui-winit?/puffin"]