ui-patterns: the dock area derives its prune through PruneKey::new and hide::shown; a held form keeps a blocking host refusal shown until the host withdraws it

This commit is contained in:
bflatastic
2026-11-22 01:33:51 +07:00
parent ab7554e1e9
commit 43ae81394e
2 changed files with 11 additions and 8 deletions
+3 -4
View File
@@ -596,9 +596,8 @@ fn show_area<P: Clone + Eq + Hash + Debug + Send + Sync + 'static>(
let shell = body.shell();
let mut memory = body.memory::<AreaMemory<P>>().clone();
let protected = |panel: &P| rights.get(panel).is_some_and(|rights| rights.is_protected());
let (hide, floating) = hide::resolved(hide, shell.as_ref());
let prune = PruneKey { model, hide, floating, maximized: maximized.map(PanelKey::of) };
let view = derived(ctx, id.with("pruned"), &prune, || frame::maximize(current.layout(), maximized, hide, &protected).into_owned());
let prune = PruneKey::new(model, hide, shell.as_ref(), maximized.map(PanelKey::of));
let view = derived(ctx, id.with("pruned"), &prune, || hide::shown(current.layout(), maximized, hide, shell.as_ref(), &protected).into_owned());
let layout: &Layout<P> = &view.layout;
let bounds = shell.as_ref().map_or(body.rect, ShellCx::float_bounds);
let space = float_space(ctx, bounds, &sizes, config, specs);
@@ -678,7 +677,7 @@ fn show_area<P: Clone + Eq + Hash + Debug + Send + Sync + 'static>(
};
register_bands(&scene, ctx, body.rect, &leaves);
let started = memory.moving.as_ref().map(|moving| moving.before.layout());
let moved = if floating { pass.windows(ui, body, &open, started) } else { None };
let moved = if prune.floating { pass.windows(ui, body, &open, started) } else { None };
let mut report = pass.report;
let label: Arc<str> = Arc::from(body.words::<DockWords>().move_window.as_str());
if let Some((anchor, change, edge)) = moved
@@ -451,8 +451,10 @@ impl<'a, V: Value + Default> FormDialog<'a, V> {
// The app accepted the held OK: this pass finishes it. A second pass of the frame finds the answer already taken.
let finish = !measuring_run && hold.as_deref().is_some_and(|held| held.is_accepted());
// The refusal and the values it refused are read before the body, which may edit the values; the notice is decided
// after the body, in the same pass, against the values the body left.
let refusal = hold.as_deref().and_then(|held| held.refusal().map(|(reason, refused)| (reason.clone(), refused.clone())));
// after the body, in the same pass, against the values the body left. A blocking (host) refusal shows whatever the
// values are.
let refusal =
hold.as_deref().and_then(|held| held.refusal().map(|(reason, refused)| (reason.clone(), refused.clone(), held.refusal_blocks())));
let reason_cell = Rc::new(Cell::new(None::<Label>));
let waiting = hold.as_deref().is_some_and(|held| held.is_waiting());
let ok_enabled = ok_enabled && !waiting;
@@ -617,8 +619,8 @@ impl<'a, V: Value + Default> FormDialog<'a, V> {
let _ = held.reborrow().write(cx, &EditEvent::set(Mixed::Same(before.clone()), values.clone(), name.clone(), None));
*changed.borrow_mut() = Some(values.clone());
}
if let Some((reason, refused)) = &refusal
&& *refused == values
if let Some((reason, refused, blocks)) = &refusal
&& (*blocks || *refused == values)
{
reason_cell.set(Some(reason.clone()));
}
@@ -637,8 +639,10 @@ impl<'a, V: Value + Default> FormDialog<'a, V> {
};
if let Some(held) = hold {
let values = work.into_inner();
// A blocking refusal ends only when the host withdraws it.
if let (Some((_, refused)), Some(values)) = (held.refusal(), values.as_ref())
&& refused != values
&& !held.refusal_blocks()
{
held.clear_refusal();
}