From 373771efcc39c028d5940c0bf670aec32065bb1d Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 28 Nov 2024 13:44:09 +0100 Subject: [PATCH 1/6] Fix `Node::simulate_click` not centering cursor over widget --- src/node.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node.rs b/src/node.rs index 9236ac0..c83de78 100644 --- a/src/node.rs +++ b/src/node.rs @@ -96,6 +96,7 @@ impl<'tree> Node<'tree> { /// Simulate a click event at the node center pub fn simulate_click(&self) { + self.hover(); ElementState::click().for_each(|state| { self.event(Event::Simulated(SimulatedEvent::MouseInput { button: MouseButton::Left, From 1dd378661e8ca7365c37db4cb401a54fa32924ad Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 28 Nov 2024 14:05:22 +0100 Subject: [PATCH 2/6] Fix center calculation --- src/node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.rs b/src/node.rs index c83de78..4ee73a4 100644 --- a/src/node.rs +++ b/src/node.rs @@ -88,7 +88,7 @@ impl<'tree> Node<'tree> { /// Hover the cursor at the node center pub fn hover(&self) { let rect = self.node.raw_bounds().expect("Node has no bounds"); - let center = Vec2::new(rect.x0 + rect.x1 / 2.0, rect.y0 + rect.y1 / 2.0); + let center = Vec2::new((rect.x0 + rect.x1) / 2.0, (rect.y0 + rect.y1) / 2.0); self.event(Event::Simulated(SimulatedEvent::CursorMoved { position: center, })); From 301742639dd18fc14d01b0576d2ae560fe1d0ec1 Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 28 Nov 2024 14:20:16 +0100 Subject: [PATCH 3/6] Update egui --- Cargo.lock | 36 +++++++++++++++--------------------- Cargo.toml | 4 ++-- rust-toolchain | 2 +- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 277785e..217e15b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,15 +20,9 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" -version = "0.16.1" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef7442f1f520649b8e11ee3af6caeec24123fed4b63bc36a85b67308d8514fdf" - -[[package]] -name = "accesskit" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c97bb3cc1dacbdc6d1147040fc61309590d3e1ab5efd92a8a09c7a2e07284c" +checksum = "d3d3b8f9bae46a948369bc4a03e815d4ed6d616bd00de4051133a5019dc31c5a" [[package]] name = "accesskit_consumer" @@ -36,7 +30,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa3a17950ce0d911f132387777b9b3d05eddafb59b773ccaa53fceefaeb0228e" dependencies = [ - "accesskit 0.17.0", + "accesskit", "immutable-chunkmap", ] @@ -78,18 +72,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "ecolor" -version = "0.28.1" -source = "git+https://github.com/emilk/egui?rev=dae1979dd334ace310b6e3ef02e98281ed7dfb8e#dae1979dd334ace310b6e3ef02e98281ed7dfb8e" +version = "0.29.1" +source = "git+https://github.com/emilk/egui?rev=84cc1572b175d49a64f1b323a6d7e56b1f1fba66#84cc1572b175d49a64f1b323a6d7e56b1f1fba66" dependencies = [ "emath", ] [[package]] name = "egui" -version = "0.28.1" -source = "git+https://github.com/emilk/egui?rev=dae1979dd334ace310b6e3ef02e98281ed7dfb8e#dae1979dd334ace310b6e3ef02e98281ed7dfb8e" +version = "0.29.1" +source = "git+https://github.com/emilk/egui?rev=84cc1572b175d49a64f1b323a6d7e56b1f1fba66#84cc1572b175d49a64f1b323a6d7e56b1f1fba66" dependencies = [ - "accesskit 0.16.1", + "accesskit", "ahash", "emath", "epaint", @@ -98,13 +92,13 @@ dependencies = [ [[package]] name = "emath" -version = "0.28.1" -source = "git+https://github.com/emilk/egui?rev=dae1979dd334ace310b6e3ef02e98281ed7dfb8e#dae1979dd334ace310b6e3ef02e98281ed7dfb8e" +version = "0.29.1" +source = "git+https://github.com/emilk/egui?rev=84cc1572b175d49a64f1b323a6d7e56b1f1fba66#84cc1572b175d49a64f1b323a6d7e56b1f1fba66" [[package]] name = "epaint" -version = "0.28.1" -source = "git+https://github.com/emilk/egui?rev=dae1979dd334ace310b6e3ef02e98281ed7dfb8e#dae1979dd334ace310b6e3ef02e98281ed7dfb8e" +version = "0.29.1" +source = "git+https://github.com/emilk/egui?rev=84cc1572b175d49a64f1b323a6d7e56b1f1fba66#84cc1572b175d49a64f1b323a6d7e56b1f1fba66" dependencies = [ "ab_glyph", "ahash", @@ -117,8 +111,8 @@ dependencies = [ [[package]] name = "epaint_default_fonts" -version = "0.28.1" -source = "git+https://github.com/emilk/egui?rev=dae1979dd334ace310b6e3ef02e98281ed7dfb8e#dae1979dd334ace310b6e3ef02e98281ed7dfb8e" +version = "0.29.1" +source = "git+https://github.com/emilk/egui?rev=84cc1572b175d49a64f1b323a6d7e56b1f1fba66#84cc1572b175d49a64f1b323a6d7e56b1f1fba66" [[package]] name = "immutable-chunkmap" @@ -133,7 +127,7 @@ dependencies = [ name = "kittest" version = "0.1.0" dependencies = [ - "accesskit 0.17.0", + "accesskit", "accesskit_consumer", "egui", "parking_lot", diff --git a/Cargo.toml b/Cargo.toml index 162cbbf..8c974b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,10 +29,10 @@ accesskit = "0.17.0" parking_lot = "0.12" [dev-dependencies] -egui = { version = "0.28.1", features = ["accesskit"] } +egui = { version = "0.29.1", features = ["accesskit"] } [patch.crates-io] -egui = { git = "https://github.com/emilk/egui", rev = "dae1979dd334ace310b6e3ef02e98281ed7dfb8e" } +egui = { git = "https://github.com/emilk/egui", rev = "84cc1572b175d49a64f1b323a6d7e56b1f1fba66" } [lints] workspace = true diff --git a/rust-toolchain b/rust-toolchain index ae5c85c..4da9309 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -5,6 +5,6 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "1.76" # Avoid specifying a patch version here; see https://github.com/emilk/eframe_template/issues/145 +channel = "1.77" # Avoid specifying a patch version here; see https://github.com/emilk/eframe_template/issues/145 components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] From fb3646da2be5e8b4a8c228bed3b419d904be650e Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 28 Nov 2024 14:24:12 +0100 Subject: [PATCH 4/6] Update toolchain to 1.77 --- .github/workflows/rust.yml | 6 +++--- Cargo.toml | 2 +- clippy.toml | 2 +- scripts/clippy_wasm/clippy.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f26c38c..4688a8e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,7 +22,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: default - toolchain: 1.76.0 + toolchain: 1.77.0 override: true - name: Install packages (Linux) @@ -119,7 +119,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.76.0 + toolchain: 1.77.0 target: wasm32-unknown-unknown override: true components: clippy @@ -147,6 +147,6 @@ jobs: - uses: actions/checkout@v3 - uses: EmbarkStudios/cargo-deny-action@v1 with: - rust-version: "1.76.0" + rust-version: "1.77.0" log-level: warn command: check diff --git a/Cargo.toml b/Cargo.toml index 8c974b2..b57c51a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ name = "kittest" publish = true readme = "README.md" repository = "https://github.com/rerun-io/kittest" -rust-version = "1.76" +rust-version = "1.77" version = "0.1.0" [package.metadata.docs.rs] diff --git a/clippy.toml b/clippy.toml index 9673121..6b6f92b 100644 --- a/clippy.toml +++ b/clippy.toml @@ -5,7 +5,7 @@ # ----------------------------------------------------------------------------- # Section identical to scripts/clippy_wasm/clippy.toml: -msrv = "1.76" +msrv = "1.77" allow-unwrap-in-tests = true diff --git a/scripts/clippy_wasm/clippy.toml b/scripts/clippy_wasm/clippy.toml index 5b7bf9d..2916ea9 100644 --- a/scripts/clippy_wasm/clippy.toml +++ b/scripts/clippy_wasm/clippy.toml @@ -8,7 +8,7 @@ # ----------------------------------------------------------------------------- # Section identical to the main clippy.toml: -msrv = "1.76" +msrv = "1.77" allow-unwrap-in-tests = true From 7ed0af14d99ffbcdd023a78269f91517a18da8eb Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 28 Nov 2024 14:26:29 +0100 Subject: [PATCH 5/6] Fix doc --- src/node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.rs b/src/node.rs index 4ee73a4..8e50276 100644 --- a/src/node.rs +++ b/src/node.rs @@ -76,7 +76,7 @@ impl<'tree> Node<'tree> { })); } - /// Click the node via accesskit. This will trigger a [`accesskit::Action::Default`] action + /// Click the node via accesskit. This will trigger a [`accesskit::Action::Click`] action pub fn click(&self) { self.event(Event::ActionRequest(ActionRequest { data: None, From 5fbade46eabb934ee07e0d5a0cb2a04272a6297f Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 28 Nov 2024 14:40:35 +0100 Subject: [PATCH 6/6] Fix querying labels via value --- src/filter.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/filter.rs b/src/filter.rs index 03bbe23..a2c7006 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -83,12 +83,20 @@ impl<'a> By<'a> { } /// Filter by the label of the node with an exact match. + /// + /// Note that [in AccessKit](https://docs.rs/accesskit/latest/accesskit/struct.Node.html#method.label), + /// a widget with `Role::Label`, stores it's label in `Node::value`. + /// We check for this and use the value if the role is `Role::Label`. pub fn label(mut self, label: &'a str) -> Self { self.label = Some(label); self } /// Filter by the label of the node with a substring match. + /// + /// Note that [in AccessKit](https://docs.rs/accesskit/latest/accesskit/struct.Node.html#method.label), + /// a widget with `Role::Label`, stores it's label in `Node::value`. + /// We check for this and use the value if the role is `Role::Label`. pub fn label_contains(mut self, label: &'a str) -> Self { self.label = Some(label); self.label_contains = true; @@ -156,7 +164,14 @@ impl<'a> By<'a> { /// Note: Remember to check for recursive filtering pub(crate) fn matches(&self, node: &Node<'_>) -> bool { if let Some(label) = self.label { - if let Some(node_label) = node.label() { + // In AccessKit, a widget with `Role::Label`, stores it's label in `Node::value`. + let node_label = if node.role() == Role::Label { + node.value() + } else { + node.label() + }; + + if let Some(node_label) = node_label { if self.label_contains { if !node_label.contains(label) { return false;