Merge craft-libs#3801's head (b8bda06c2c) into fw365-int

Brings the pointer-move gate's per-root hover and press winners
(a885cd5f38) and the egui pin at storytold/egui#65's merge commit
932a73b2. The pointer trials keep both sides' additions.
This commit is contained in:
aiongg committed 2026-11-27 15:00:51 +00:00
commit 47ba4dfd38
5 files changed
+69 -42

No files matched your search

Generated
+14 -14
View File
@@ -5659,7 +5659,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",
@@ -5715,7 +5715,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",
@@ -5750,7 +5750,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",
@@ -5769,7 +5769,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",
@@ -5788,7 +5788,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",
@@ -5808,7 +5808,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",
@@ -5821,7 +5821,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",
@@ -5898,7 +5898,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",
]
@@ -5971,7 +5971,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",
@@ -5997,7 +5997,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"
@@ -15320,19 +15320,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"
+14 -14
View File
@@ -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
+1 -1
View File
@@ -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] = &[
+21 -13
View File
@@ -751,32 +751,40 @@ pub fn move_needs_pass(ctx: &Context, viewport: ViewportId, from: Option<Pos2>,
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<Layer>, 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<Layer>, Vec<UnderRoot>) {
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::<Shapes>::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<UnderRoot> = 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<usize> = (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<Shape<Id>> = 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<usize>, Option<usize>, Option<usize>);
/// 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) {
@@ -1005,3 +1005,22 @@ fn a_hover_position_read_follows_the_pointer() {
"a move over the rest of the component, which read no position, runs none"
);
}
/// 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");
}