Skip to content

Commit

Permalink
Update accesskit and accesskit_winit. (#3475)
Browse files Browse the repository at this point in the history
* Update accesskit and accesskit_winit.

* Remove duplicated `libgtk-3-dev`

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
ndarilek and emilk authored Nov 10, 2023
1 parent 7169f28 commit d0ff09a
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
toolchain: 1.70.0
targets: wasm32-unknown-unknown

- run: sudo apt-get update && sudo apt-get install libgtk-3-dev
- run: sudo apt-get update && sudo apt-get install libgtk-3-dev libatk1.0-dev

- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
Expand Down
79 changes: 54 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/egui-winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ winit = { version = "0.28", default-features = false }
#! ### Optional dependencies

# feature accesskit
accesskit_winit = { version = "0.14.0", optional = true }
accesskit_winit = { version = "0.15.0", optional = true }

## Enable this when generating docs.
document-features = { version = "0.2", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ahash = { version = "0.8.1", default-features = false, features = [
nohash-hasher = "0.2"

#! ### Optional dependencies
accesskit = { version = "0.11", optional = true }
accesskit = { version = "0.12", optional = true }

backtrace = { version = "0.3", optional = true }

Expand Down
11 changes: 5 additions & 6 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,6 @@ impl Context {
crate::profile_scope!("accesskit");
let state = self.frame_state_mut(|fs| fs.accesskit_state.take());
if let Some(state) = state {
let has_focus = self.input(|i| i.raw.focused);
let root_id = crate::accesskit_root_id().accesskit_id();
let nodes = self.write(|ctx| {
state
Expand All @@ -1305,13 +1304,13 @@ impl Context {
})
.collect()
});
let focus_id = self
.memory(|mem| mem.focus())
.map_or(root_id, |id| id.accesskit_id());
platform_output.accesskit_update = Some(accesskit::TreeUpdate {
nodes,
tree: Some(accesskit::Tree::new(root_id)),
focus: has_focus.then(|| {
let focus_id = self.memory(|mem| mem.focus());
focus_id.map_or(root_id, |id| id.accesskit_id())
}),
focus: focus_id,
});
}
}
Expand Down Expand Up @@ -1941,7 +1940,7 @@ impl Context {
NodeBuilder::new(Role::Window).build(&mut ctx.accesskit_node_classes),
)],
tree: Some(Tree::new(root_id)),
focus: None,
focus: root_id,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Id {

#[cfg(feature = "accesskit")]
pub(crate) fn accesskit_id(&self) -> accesskit::NodeId {
std::num::NonZeroU64::new(self.0).unwrap().into()
self.0.into()
}
}

Expand Down
12 changes: 6 additions & 6 deletions crates/egui/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,20 +620,20 @@ impl Response {
info: crate::WidgetInfo,
) {
use crate::WidgetType;
use accesskit::{CheckedState, Role};
use accesskit::{Checked, Role};

self.fill_accesskit_node_common(builder);
builder.set_role(match info.typ {
WidgetType::Label => Role::StaticText,
WidgetType::Link => Role::Link,
WidgetType::TextEdit => Role::TextField,
WidgetType::TextEdit => Role::TextInput,
WidgetType::Button | WidgetType::ImageButton | WidgetType::CollapsingHeader => {
Role::Button
}
WidgetType::Checkbox => Role::CheckBox,
WidgetType::RadioButton => Role::RadioButton,
WidgetType::SelectableLabel => Role::ToggleButton,
WidgetType::ComboBox => Role::PopupButton,
WidgetType::ComboBox => Role::ComboBox,
WidgetType::Slider => Role::Slider,
WidgetType::DragValue => Role::SpinButton,
WidgetType::ColorButton => Role::ColorWell,
Expand All @@ -649,10 +649,10 @@ impl Response {
builder.set_numeric_value(value);
}
if let Some(selected) = info.selected {
builder.set_checked_state(if selected {
CheckedState::True
builder.set_checked(if selected {
Checked::True
} else {
CheckedState::False
Checked::False
});
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::sync::Arc;

#[cfg(feature = "accesskit")]
use accesskit::Role;
use epaint::text::{cursor::*, Galley, LayoutJob};

use crate::{output::OutputEvent, *};
Expand Down Expand Up @@ -751,15 +753,15 @@ impl<'t> TextEdit<'t> {

builder.set_default_action_verb(accesskit::DefaultActionVerb::Focus);
if self.multiline {
builder.set_multiline();
builder.set_role(Role::MultilineTextInput);
}

parent_id
});

if let Some(parent_id) = parent_id {
// drop ctx lock before further processing
use accesskit::{Role, TextDirection};
use accesskit::TextDirection;

ui.ctx().with_accessibility_parent(parent_id, || {
for (i, row) in galley.rows.iter().enumerate() {
Expand Down

0 comments on commit d0ff09a

Please sign in to comment.