A replay compares what pointer sensing gives the view's own components (FW-365 integration item 2)

Facts.roots held arena roots, so every view of an arena saw the pointer
over any member of it and ran. A run now notes the owners of the shapes
it registers (Facts.sensors); Under lists every owner under the point,
and Sensed keeps the hover winners, owners and root parts of the view's
own components. Egui widgets stay in Record.widgets.
This commit is contained in:
aiongg committed 2026-11-27 04:25:49 +00:00
1 parent 6e13c41e8c
commit 0ff22c9503
3 files changed
+29 -26

No files matched your search

+3 -3
View File
@@ -513,7 +513,7 @@ pub(crate) fn replay(ctx: &Context, id: Id) {
/// - nothing in it moves: no animation off its end value, no repaint asked from inside it, no texture it shows still
/// loading, no wake time reached;
/// - what pointer sensing gives it is what its run saw (`pointer::Sensed`: the hover, part and pointer-over facts of
/// its roots and egui widgets, and the parts of its roots under the pointer), so a move within one part of it, a
/// the components whose shapes it registered and of its egui widgets), so a move within one part of it, a
/// collection's row among them, leaves it alone, and a move onto another part, in or out runs it; while it is under
/// the pointer, the modifiers are the ones its run saw; the pointer did not move in a rect its run follows the
/// pointer in (`pointer::follows_pointer`, which a hover position read marks), now or then; no wheel share or owed
@@ -667,7 +667,7 @@ fn pressed(ctx: &Context, layer: Layer, rect: Rect, overlays: &[replay::ShownLay
/// `offset`: the pointer rules of `settled`.
fn pointer_reaches(ctx: &Context, settled: &Settled, rect: Rect, offset: Vec2) -> bool {
let facts = &settled.record.facts;
let sensed = crate::runtime::pointer::sensed(ctx, &facts.roots, &settled.record.widgets);
let sensed = crate::runtime::pointer::sensed(ctx, &facts.sensors, &settled.record.widgets);
let changed = |input: Input| inputs::generation(ctx, input) != settled.seen[input as usize];
let hover = crate::runtime::pointer::hover_point(ctx);
let follows = changed(Input::Pointer)
@@ -754,7 +754,7 @@ pub(crate) fn ran(ctx: &Context, id: Id, record: Record, place: Place, rect: Rec
let revealed = focus::targets(ctx)[1];
let engaged_now = record.focus.stop_ids().any(|stop| revealed == Some(stop));
let lives = crate::runtime::memory::ended_generation(ctx);
let sensed = crate::runtime::pointer::sensed(ctx, &record.facts.roots, &record.widgets);
let sensed = crate::runtime::pointer::sensed(ctx, &record.facts.sensors, &record.widgets);
let pointer = crate::runtime::pointer::hover_point(ctx);
let mut settled =
Settled { record, frame: 0, place, rect, engaged: engaged_now, sensed, pointer, key, pass: 0, edits, output, lives, seen, view };
+19 -14
View File
@@ -667,7 +667,7 @@ pub(crate) fn record_shapes_in(ctx: &Context, viewport: ViewportId, layer: Layer
/// `record_shapes_in` with no note in the run records, for a caller whose own note makes the shapes again: shapes at
/// stack positions a replay takes from the arena it joins (`sensing`), not from the recorded run.
pub(crate) fn add_shapes_in(ctx: &Context, viewport: ViewportId, layer: Layer, root: Id, clip: Rect, shapes: Vec<Shape<Id>>) {
crate::runtime::replay::note_root(ctx, root);
crate::runtime::replay::note_sensors(ctx, shapes.iter().map(|shape| shape.owner));
PerViewport::<Shapes>::with(ctx, viewport, |record| {
let order = record.next;
record.next += 1;
@@ -799,7 +799,6 @@ pub(crate) fn record_widgets_in(ctx: &Context, viewport: ViewportId, layer: Laye
|| (layer, root, widgets.to_vec(), click),
|ctx, (layer, root, widgets, click)| record_widgets(ctx, *layer, *root, widgets, *click),
);
crate::runtime::replay::note_root(ctx, root);
PerViewport::<Shapes>::with(ctx, viewport, |record| {
record.this_made.insert(root);
record.this_made.extend(widgets.iter().copied());
@@ -1047,6 +1046,8 @@ pub(crate) struct Under {
pub hover_top: Option<(Winner<Id>, Id)>,
/// Every root with a shape under the point, on top or not: the roots that contain the pointer.
pub over: SmallVec<[Id; 4]>,
/// Every component (root or member) that owns a shape under the point, on top or not.
pub owners: SmallVec<[Id; 4]>,
/// The roots' own parts with a shape under the point, on top or not, each with its root: a collection's row that
/// contains the pointer under the row's own shapes.
pub parts: SmallVec<[(Id, PartRef); 4]>,
@@ -1103,16 +1104,17 @@ pub(crate) fn with_hover<R>(ctx: &Context, viewport: ViewportId, f: impl FnOnce(
PerViewport::<Shapes>::with(ctx, viewport, |record| f(record.hover.as_ref().map(|(_, _, under)| under), record.captured))
}
/// What pointer sensing gives a memoized view's run in the running pass (`runtime::lazy`): of the arena roots and egui
/// widgets the run registered, the ones under the pass's hover point and what they win there. Equal answers in two
/// passes mean every hover, part and pointer-over fact the run's components read is the same; a hover position is
/// not part of it, as the code that reads one marks itself ([`follows_pointer`]).
/// What pointer sensing gives a memoized view's run in the running pass (`runtime::lazy`): of the components that own
/// shapes the run registered (arena roots and members) and of its egui widgets, the ones under the pass's hover point
/// and what they win there. A component's facts are its own: a member's view sees a move over a sibling member or its
/// root as nothing. Equal answers in two passes mean every hover, part and pointer-over fact the run's components read
/// is the same; a hover position is not part of it, as the code that reads one marks itself ([`follows_pointer`]).
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct Sensed {
/// The press winners and the shape that hovers beside them (`Under`), each as its kind, root, owner and part, of
/// the run's roots. None while a press is open: only the press's target hovers, and the press runs it.
/// the run's components. None while a press is open: only the press's target hovers, and the press runs it.
hover: SmallVec<[(u8, Id, Id, Option<PartRef>); 3]>,
/// The run's roots with a shape under the point.
/// The run's components with a shape under the point.
over: SmallVec<[Id; 4]>,
/// The own parts of the run's roots with a shape under the point (`Under::parts`).
parts: SmallVec<[(Id, PartRef); 4]>,
@@ -1127,24 +1129,24 @@ impl Sensed {
}
}
/// What pointer sensing gives the arena roots `roots` and egui widgets `widgets` of a run in the running pass
/// What pointer sensing gives the components `sensors` and egui widgets `widgets` of a run in the running pass
/// ([`Sensed`]): read from the pass's one resolution at the hover point.
pub(crate) fn sensed(ctx: &Context, roots: &IdSet, widgets: &IdSet) -> Sensed {
pub(crate) fn sensed(ctx: &Context, sensors: &IdSet, widgets: &IdSet) -> Sensed {
PerViewport::<Shapes>::with(ctx, pass::current_viewport(ctx), |record| {
let mut sensed = Sensed::default();
if let Some((_, _, under)) = &record.hover
&& !roots.is_empty()
&& !sensors.is_empty()
{
if !record.captured {
let found = [under.press.click, under.press.drag, under.hover_top];
for (kind, (winner, root)) in (0u8..).zip(found).filter_map(|(kind, found)| Some((kind, found?))) {
if roots.contains(&root) {
if sensors.contains(&winner.owner) {
sensed.hover.push((kind, root, winner.owner, winner.part));
}
}
}
sensed.over.extend(under.over.iter().copied().filter(|root| roots.contains(root)));
sensed.parts.extend(under.parts.iter().copied().filter(|(root, _)| roots.contains(root)));
sensed.over.extend(under.owners.iter().copied().filter(|owner| sensors.contains(owner)));
sensed.parts.extend(under.parts.iter().copied().filter(|(root, _)| sensors.contains(root)));
}
if let Some((contains, click, drag)) = &record.hover_widgets
&& !widgets.is_empty()
@@ -1241,6 +1243,9 @@ fn find_under(ctx: &Context, viewport: ViewportId, at: Pos2, targets: PressTarge
}
for &index in &kept {
let shape = &entry.shapes[index];
if !under.owners.contains(&shape.owner) {
under.owners.push(shape.owner);
}
if let Some(part) = shape.part.filter(|_| shape.owner == root)
&& !under.parts.contains(&(root, part))
{
+7 -9
View File
@@ -193,9 +193,9 @@ pub(crate) struct Facts {
pub(crate) overlays: Vec<ShownLayer>,
/// The layer stack entries the run recorded (`note_layer`): a close queued for one is taken only by a run.
pub(crate) layers: Vec<egui::Id>,
/// The arena roots the run registered shapes or egui widgets for (`note_root`): what pointer sensing gives them is
/// what the run saw of the pointer (`pointer::Sensed`).
pub(crate) roots: IdSet,
/// The components (arena roots and members) that own shapes the run registered (`note_sensors`): what pointer
/// sensing gives them is what the run saw of the pointer (`pointer::Sensed`), with the run's egui widgets.
pub(crate) sensors: IdSet,
/// The screen rects the run's content follows the pointer in (`pointer::follows_pointer`).
pub(crate) follows: Vec<Rect>,
/// The wheel takers the run registered (`wheel::register`): a share of the wheel for one runs it.
@@ -322,7 +322,7 @@ pub(crate) fn close(ctx: &Context, layer: Layer) -> Record {
outer.facts.instances.extend(open.facts.instances.iter().copied());
outer.facts.overlays.extend(open.facts.overlays.iter().copied());
outer.facts.layers.extend(open.facts.layers.iter().copied());
outer.facts.roots.extend(open.facts.roots.iter().copied());
outer.facts.sensors.extend(open.facts.sensors.iter().copied());
outer.facts.follows.extend(open.facts.follows.iter().copied());
outer.facts.takers.extend(open.facts.takers.iter().copied());
} else {
@@ -572,11 +572,9 @@ pub(crate) fn note_overlay(ctx: &Context, layer: Layer, rect: Rect) {
with_open(ctx, |facts| facts.overlays.push(ShownLayer { layer, rect }));
}
/// Notes that the running code registered shapes or egui widgets for the arena root `root`, by a run or a replay.
pub(crate) fn note_root(ctx: &Context, root: egui::Id) {
with_open(ctx, |facts| {
facts.roots.insert(root);
});
/// Notes that the running code registered shapes owned by the components `owners`, by a run or a replay.
pub(crate) fn note_sensors(ctx: &Context, owners: impl IntoIterator<Item = egui::Id>) {
with_open(ctx, |facts| facts.sensors.extend(owners));
}
/// Notes that what the running code shows in the screen rect `rect` follows the pointer, by a run or a replay.