Dock drop spots: a settled region registers them again when it replays

DockTargets notes each registration in the open run records, so a group or column that replays its last run keeps its drop spots, room and bands.
This commit is contained in:
aiongg
2026-11-17 23:53:08 +00:00
parent 725df6bf03
commit e55ae75b95
3 changed files with 21 additions and 4 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ pub mod pen;
pub mod pending;
pub mod pointer;
pub(crate) mod reads;
pub(crate) mod replay;
#[doc(hidden)]
pub mod replay;
pub mod requests;
pub mod sampler;
pub mod toast;
+3 -2
View File
@@ -161,8 +161,9 @@ fn with_open(ctx: &Context, f: impl FnOnce(&mut Facts)) {
}
/// Notes, in the records open around the running code, the registration `make` builds: called again, it registers
/// what the running code registered.
pub(crate) fn journal<F: Fn(&Context) + Send + Sync + 'static>(ctx: &Context, make: impl FnOnce() -> F) {
/// what the running code registered. A service outside this crate that keeps registrations per pass (a dock's drop
/// spots) notes each one here, so a settled region's replay makes it again.
pub fn journal<F: Fn(&Context) + Send + Sync + 'static>(ctx: &Context, make: impl FnOnce() -> F) {
if recording(ctx) {
let entry: Entry = Arc::new(make());
pass_state::with::<Recorder, _>(ctx, |recorder| recorder.journal.push(entry));
+16 -1
View File
@@ -403,7 +403,7 @@ impl<P> Default for Pass<P> {
}
}
impl<P: Clone + Send + 'static> DockTargets<P> {
impl<P: Clone + Send + Sync + 'static> DockTargets<P> {
/// Runs `f` on the registries of the running pass; `None` outside a pass.
fn with_pass<R>(ctx: &Context, f: impl FnOnce(&mut Pass<P>) -> R) -> Option<R> {
let facts = frame::running(ctx)?;
@@ -435,6 +435,10 @@ impl<P: Clone + Send + 'static> DockTargets<P> {
if !crate::runtime::measure::effect(ctx, "dock::register_target") {
return;
}
Self::journal(ctx, || {
let spot = spot.clone();
move |ctx: &Context| Self::register_in(ctx, dock, spot.clone(), hit, applies)
});
Self::with_dock(ctx, dock, |targets| targets.add(spot, hit, applies, hit));
}
@@ -445,6 +449,10 @@ impl<P: Clone + Send + 'static> DockTargets<P> {
if !crate::runtime::measure::effect(ctx, "dock::register_target") {
return;
}
Self::journal(ctx, || {
let spot = spot.clone();
move |ctx: &Context| Self::register_band(ctx, dock, spot.clone(), band, line, reach)
});
let near = line.expand(reach).intersect(band);
Self::with_dock(ctx, dock, |targets| targets.add(spot, band, band, near));
}
@@ -456,9 +464,16 @@ impl<P: Clone + Send + 'static> DockTargets<P> {
if !crate::runtime::measure::effect(ctx, "dock::register_room") {
return;
}
Self::journal(ctx, || move |ctx: &Context| Self::register_room(ctx, dock, room));
Self::with_dock(ctx, dock, |targets| targets.room = Some(room));
}
/// Notes a registration in the records of the settling regions around the running code, so a region that settles
/// registers its drop spots again when it replays its last run.
fn journal<F: Fn(&Context) + Send + Sync + 'static>(ctx: &Context, make: impl FnOnce() -> F) {
crate::runtime::replay::journal(ctx, make);
}
/// Runs `f` on the registry of `dock` in the running pass, made empty the first time.
fn with_dock(ctx: &Context, dock: Id, f: impl FnOnce(&mut DockTargets<P>)) {
Self::with_pass(ctx, |pass| {