From ad6575845d49859ced2e3cb301c3f72d49f0160e Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 14:03:47 +0000 Subject: [PATCH] canvas-w8: net change of 5 commits - canvas-w8: written from its sheet - canvas-w8: repair 1 - canvas-w8: finished by an agent - canvas-w8: review fixes (review-1) - canvas-w8: review fixes (review-1b) --- .../ui-canvas/src/canvas_controls/task_bar.rs | 108 +++++++++++++----- .../src/canvas_controls/task_bar/stories.rs | 46 +++++++- .../tests/it/canvas_controls/task_bar.rs | 108 +++++++++++++++++- crates/ui-widgets/src/menu/popup.rs | 94 ++++++++++++++- crates/ui-widgets/src/menu/words.rs | 1 + crates/ui-widgets/tests/it/menu/companion.rs | 93 +++++++++++++++ crates/ui-widgets/tests/it/menu/mod.rs | 4 + 7 files changed, 417 insertions(+), 37 deletions(-) create mode 100644 crates/ui-widgets/tests/it/menu/companion.rs diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index cc8d420d6..e273dc2c1 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -7,7 +7,7 @@ use super::CanvasControlWords; use crate::bars::{Bar, BarKind}; use crate::buttons::IconButton; use crate::canvas::canvas_space; -use crate::contract::overlay::{Anchor, Place, PlacementChange, PlacementKind}; +use crate::contract::overlay::{Anchor, Dismiss, Outside, Place, PlacementChange, PlacementKind}; use crate::contract::{ Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderRegion, Inner, Mount, NoValue, Outcome, Overlay, Pad, PopupKind, Props as _, Role, Show as _, ShowContainer as _, Sizing, Trigger, @@ -16,6 +16,7 @@ use crate::display::Icon; use crate::menu::{Menu, MenuItem}; use crate::primitives::IconSpec; use crate::runtime::env::{Env, Label}; +use crate::runtime::overlay::CloseReason; use crate::style::{ComponentStyle, StyleCx, SurfaceKind}; use craft_behavior::kurbo::Point; use craft_behavior::overlay::{Align, Side}; @@ -113,7 +114,7 @@ pub struct TaskBarOutput { pub hide: bool, /// The bar's rect on screen. pub rect: Rect, - /// The bar was closed by an outside press. + /// The bar closed: an outside press, Escape or its anchor going. The caller stops showing it. pub closed: bool, } @@ -149,6 +150,8 @@ enum MenuPick { /// The More button and its menu, placed once per run of the bar's body. struct MoreMenu { words: Arc, + /// Whether the bar has a More menu: a selection bar has none. + offered: bool, placed: bool, pick: Option, } @@ -156,7 +159,7 @@ struct MoreMenu { impl MoreMenu { /// Shows the button and its menu here unless this run of the body showed them already. fn place(&mut self, ui: &mut Ui) { - if std::mem::replace(&mut self.placed, true) { + if !self.offered || std::mem::replace(&mut self.placed, true) { return; } let words = Arc::clone(&self.words); @@ -187,14 +190,23 @@ impl<'a> TaskBar<'a> { /// A bar named `label` anchored above or at `side` of a selection whose bounds are `anchor` (document points), /// flipped and clamped to fit. pub fn selection(label: impl Into