From a885cd5f384f835b672bd8248508af9cfbc325af Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 27 Nov 2026 12:14:56 +0100 Subject: [PATCH 1/2] ui-contract: the pointer-move gate compares each root's hover and press winners Overlapping shapes of one root can hit both points of a move while the nearest centre picks another winner; the move now runs a pass then. Co-Authored-By: Claude Opus 5.5 --- crates/ui-contract/src/runtime/pointer.rs | 34 ++++++++++++------- .../ui-contract/tests/it/runtime/pointer.rs | 19 +++++++++++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/crates/ui-contract/src/runtime/pointer.rs b/crates/ui-contract/src/runtime/pointer.rs index 5ab0a02679..37f2f59501 100644 --- a/crates/ui-contract/src/runtime/pointer.rs +++ b/crates/ui-contract/src/runtime/pointer.rs @@ -695,32 +695,40 @@ pub fn move_needs_pass(ctx: &Context, viewport: ViewportId, from: Option, follows || ctx.widgets_at(viewport, from) != ctx.widgets_at(viewport, to) || shapes_under(ctx, viewport, from) != shapes_under(ctx, viewport, to) } -/// The layer under `at` and the component shapes there that hit it, as the last finished pass of `viewport` recorded -/// them: each as its root and its index in the root's record. -fn shapes_under(ctx: &Context, viewport: ViewportId, at: Pos2) -> (Option, Vec<(Id, usize)>) { +/// The layer under `at` and, for each root with component shapes there that hit it as the last finished pass of +/// `viewport` recorded them, the root, the indices of those shapes in the root's record and the ones that win its hover +/// and its press: overlapping shapes can hit both points while the nearest centre picks another winner. +fn shapes_under(ctx: &Context, viewport: ViewportId, at: Pos2) -> (Option, Vec) { let Some(layer) = areas::layer_at(ctx, at) else { return (None, Vec::new()) }; let point = areas::layer_map(ctx, layer).map_or(at, |map| map.to_layer(at)); let hit = PerViewport::::with(ctx, viewport, |record| { record.this.get(&layer).map_or_else(Vec::new, |roots| { - let mut hit: Vec<(Id, usize)> = roots + let mut hit: Vec = roots .iter() - .flat_map(|(root, entry)| { - entry - .shapes - .iter() - .zip(&entry.placed) - .enumerate() - .filter(|(_, (shape, placed))| placed.clip.contains(point) && shape.hits(point)) - .map(move |(index, _)| (*root, index)) + .filter_map(|(root, entry)| { + let indices: Vec = (0..entry.shapes.len().min(entry.placed.len())) + .filter(|&index| entry.placed[index].clip.contains(point) && entry.shapes[index].hits(point)) + .collect(); + if indices.is_empty() { + return None; + } + let shapes: Vec> = indices.iter().map(|&index| entry.shapes[index].clone()).collect(); + let winner = |kind| resolve(&shapes, point, kind).and_then(|winner| indices.get(winner.index).copied()); + let (hover, press) = (winner(ResolveFor::Hover), winner(ResolveFor::Press)); + Some((*root, indices, hover, press)) }) .collect(); - hit.sort_unstable_by_key(|(root, index)| (root.value(), *index)); + hit.sort_unstable_by_key(|(root, ..)| root.value()); hit }) }); (Some(layer), hit) } +/// A root with shapes under a point ([`shapes_under`]): the root, the indices of its shapes that hit the point, and +/// the indices of the ones that win its hover and its press there. +type UnderRoot = (Id, Vec, Option, Option); + /// Records that `layer` shows the transformed body of the root `root`, which is itself shown on `parent`: a press on /// the body layer reaches the root's own shapes beneath the body's. pub(crate) fn record_body_layer(ctx: &Context, layer: Layer, parent: Layer, root: Id) { diff --git a/crates/ui-contract/tests/it/runtime/pointer.rs b/crates/ui-contract/tests/it/runtime/pointer.rs index 282b8e153c..ac0c06eef2 100644 --- a/crates/ui-contract/tests/it/runtime/pointer.rs +++ b/crates/ui-contract/tests/it/runtime/pointer.rs @@ -889,3 +889,22 @@ fn a_move_that_changes_nothing_under_the_pointer_needs_no_pass() { assert!(needs(Some(follow.center()), follow.center() + Vec2::new(5.0, 0.0)), "a move in a rect that follows the pointer runs a pass"); assert!(needs(None, inside), "the pointer coming in runs a pass"); } + +/// Two overlapping parts of one root that hit both points of a move, where the nearest centre picks another part at +/// the end: the hover changes, so the move runs a pass. +#[trial] +fn a_move_that_changes_the_nearest_part_needs_a_pass() { + use craft_ui::runtime::pointer::move_needs_pass; + use egui::ViewportId; + const LEFT: PartKey = PartKey::new("left"); + const RIGHT: PartKey = PartKey::new("right"); + let root = ProbeRoot::new("parts", rect(0.0, 0.0, 140.0, 100.0), Sense::empty()) + .part(ProbePart::new(LEFT, rect(0.0, 0.0, 100.0, 100.0), Sense::CLICK)) + .part(ProbePart::new(RIGHT, rect(40.0, 0.0, 100.0, 100.0), Sense::CLICK)); + let (mut show, _) = scene(vec![root]); + let mut frames = Frames::new(); + frames.idle(2, &mut show); + let needs = |from: Pos2, to: Pos2| move_needs_pass(&frames.ctx, ViewportId::ROOT, Some(from), to); + assert!(!needs(Pos2::new(60.0, 50.0), Pos2::new(65.0, 50.0)), "both points nearer the left part's centre"); + assert!(needs(Pos2::new(60.0, 50.0), Pos2::new(80.0, 50.0)), "the right part's centre is nearer at the end"); +} From b8bda06c2c12ccf247ceb770a1fa5efd99ee6510 Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 27 Nov 2026 14:58:00 +0100 Subject: [PATCH 2/2] Pin egui at storytold/egui#65's merge commit 932a73b2 (photocraft#17148) Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 28 ++++++++++++++-------------- crates/craft/src/egui_fork.rs | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd6ffc831e..c99367b053 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5656,7 +5656,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "bytemuck", "emath", @@ -5712,7 +5712,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "ahash", "bytemuck", @@ -5747,7 +5747,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "accesskit", "ahash", @@ -5766,7 +5766,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "ahash", "bytemuck", @@ -5785,7 +5785,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "block2 0.6.2", "bytemuck", @@ -5805,7 +5805,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "bytemuck", "egui", @@ -5818,7 +5818,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "eframe", "egui", @@ -5895,7 +5895,7 @@ dependencies = [ [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "bytemuck", ] @@ -5968,7 +5968,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" dependencies = [ "ahash", "bytemuck", @@ -5994,7 +5994,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" [[package]] name = "equator" @@ -15317,19 +15317,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" [[patch.unused]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=9952df2fb315a5c07d200ce09e19cf176c417206#9952df2fb315a5c07d200ce09e19cf176c417206" +source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" diff --git a/Cargo.toml b/Cargo.toml index 3aebf53d07..3af86eaf40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -321,20 +321,20 @@ hayro-postscript = { path = "vendor/hayro-postscript" } linesweeper = { path = "vendor/linesweeper" } vello_common = { path = "vendor/vello_common" } vello_cpu = { path = "vendor/vello_cpu" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -emath = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "9952df2fb315a5c07d200ce09e19cf176c417206" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid diff --git a/crates/craft/src/egui_fork.rs b/crates/craft/src/egui_fork.rs index 1ec410e0ff..e10d75f9e0 100644 --- a/crates/craft/src/egui_fork.rs +++ b/crates/craft/src/egui_fork.rs @@ -3,7 +3,7 @@ /// The egui fork the library is built and tested with. Apps patch egui to exactly this. pub const GIT: &str = "https://github.com/storytold/egui.git"; /// The commit of [`GIT`]. -pub const REV: &str = "9952df2fb315a5c07d200ce09e19cf176c417206"; +pub const REV: &str = "932a73b28560acb1a695533307b2cd0d66a42081"; /// The packages the workspace patches to the fork (the `[patch.crates-io]` entries that name [`GIT`]). pub const PACKAGES: &[&str] = &[