diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index 8c40c9248..5414f07c8 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -92,6 +92,9 @@ pub struct TaskBar<'a> { /// The side of the anchor the bar hangs on; `None` gives the kind's side: above for `Selection`, below for `Task`. side: Option, align: Align, + /// A moved bar whose offset place would cover this point (a document point, like the anchor) shows at its unmoved + /// place and keeps its offset. + #[prop] keep_clear: Option, /// What an outside press does to the bar. #[prop] @@ -256,14 +259,6 @@ impl<'a> TaskBar<'a> { self } - /// A moved bar whose offset place would cover `point` (a document point, like the anchor) shows at its unmoved - /// place and keeps its offset. - #[must_use] - pub fn keep_clear(mut self, point: Point) -> Self { - self.keep_clear = Some(point); - self - } - /// Shows the bar inside `area`; `body` fills its members. pub fn show(self, ui: &mut Ui, area: Rect, mut body: impl FnMut(&mut Ui, &mut TaskBarCx<'_>) -> R) -> Inner { let TaskBar { label, anchor, mut place, rows, kind, side, align, keep_clear, dismiss } = self; diff --git a/crates/ui-panels/src/docking/floating.rs b/crates/ui-panels/src/docking/floating.rs index 4668ad918..0f6e0c4ea 100644 --- a/crates/ui-panels/src/docking/floating.rs +++ b/crates/ui-panels/src/docking/floating.rs @@ -287,8 +287,13 @@ pub struct FloatingGroup<'a> { take_drop: Option>, /// A move by the title began this pass. moving: bool, - /// Where the pointer is inside the window whose move band takes over the held press this pass; set by - /// `continue_move`. + /// The window takes over the held primary press in this pass: its own move gesture begins from that press with the + /// pointer at this point inside the window, so the window follows the pointer and, with + /// [`window_of`](FloatingGroup::window_of), docks where it would dock on release. A request of the pass, for the + /// pass after a rail's `torn_off`; without a held press it does nothing. Only a window on a layer takes the press: + /// the OS keeps a held button's moves with the window it went down in, so a group shown in an OS window + /// ([`native`](FloatingGroup::native)) moves only when pressed again. + #[prop(quantity = "grab point")] continue_move: Option, /// The files dropped on the group's OS window that no target there took. files: Vec, @@ -368,18 +373,6 @@ impl<'a> FloatingGroup<'a> { self } - /// The window takes over the held primary press in this pass: its own move gesture begins from that press with the - /// pointer at `grab` inside the window, so the window follows the pointer and, with - /// [`window_of`](FloatingGroup::window_of), docks where it would dock on release. A request of the pass, for the - /// pass after a rail's `torn_off`; without a held press it does nothing. Only a window on a layer takes the press: - /// the OS keeps a held button's moves with the window it went down in, so a group shown in an OS window - /// ([`native`](FloatingGroup::native)) moves only when pressed again. - #[must_use] - pub fn continue_move(mut self, grab: Vec2) -> Self { - self.continue_move = Some(grab); - self - } - /// The action parts at the end of the title row, in reading order. #[must_use] pub fn actions(mut self, actions: impl IntoIterator) -> Self { diff --git a/crates/ui-panels/src/rails/drawer.rs b/crates/ui-panels/src/rails/drawer.rs index 617285d3b..650fd7fda 100644 --- a/crates/ui-panels/src/rails/drawer.rs +++ b/crates/ui-panels/src/rails/drawer.rs @@ -148,10 +148,14 @@ pub struct ToolbarDrawer<'a, T: Value + 'static> { #[prop] opens: Side, /// The tool whose row wears the target mark. + #[prop] mark: Option<&'a T>, - /// A request of the pass: scrolls the tool's row into the list's view. + /// A request of the pass: scrolls the tool's row into the list's view. Send it in the pass that needs it, not every + /// pass. + #[prop] reveal: Option<&'a T>, - /// The rows of the menu the header's menu button opens; no button without rows. + /// With rows, an icon button after the title opens a menu of them. + #[prop] menu: Vec, dropped: Option, opener: Option, @@ -170,18 +174,6 @@ impl<'a, T: Value + 'static> ToolbarDrawer<'a, T> { self.opener = Some(opener.clone()); self } - - /// The tool whose row wears the target mark; `None` marks none. - pub fn mark(mut self, tool: Option<&'a T>) -> Self { - self.mark = tool; - self - } - - /// A request: scrolls the row of `tool` into the list's view. Send it in the pass that needs it, not every pass. - pub fn reveal(mut self, tool: Option<&'a T>) -> Self { - self.reveal = tool; - self - } } /// A row of the drawer's list. @@ -262,13 +254,6 @@ fn on_toolbar(toolbar: &[ToolSlot], id: &T) -> bool { } impl ToolbarDrawer<'_, T> { - /// With rows, an icon button after the title opens a menu of `rows`. - #[must_use] - pub fn menu(mut self, rows: Vec) -> Self { - self.menu = rows; - self - } - /// Shows the drawer and reports what the user changed. pub fn show(self, ui: &mut Ui) -> ToolbarDrawerOutput { self.show_with(ui, |_| {}) diff --git a/crates/ui-panels/src/rails/drawer/stories.rs b/crates/ui-panels/src/rails/drawer/stories.rs index 157c4f908..8d282a9f1 100644 --- a/crates/ui-panels/src/rails/drawer/stories.rs +++ b/crates/ui-panels/src/rails/drawer/stories.rs @@ -80,5 +80,15 @@ fn toolbar_drawer_menu_footer_and_runs(ui: &mut Ui, data: &mut StoryData) -> Sto fn toolbar_drawer_marked_tool(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let marked = 4_u8; let groups = [DrawerGroup::new("Drawing", tools(&[0, 1, 2])), DrawerGroup::new("Retouching", tools(&[3, 4]))]; - staged(ui, data, &groups, &toolbar(), |drawer, fresh| drawer.mark(Some(&marked)).reveal(fresh.then_some(&marked)), |_| {}) + staged( + ui, + data, + &groups, + &toolbar(), + |drawer, fresh| { + let drawer = drawer.mark(&marked); + if fresh { drawer.reveal(&marked) } else { drawer } + }, + |_| {}, + ) } diff --git a/crates/ui-panels/tests/it/rails/drawer.rs b/crates/ui-panels/tests/it/rails/drawer.rs index 47c36e46f..048b42313 100644 --- a/crates/ui-panels/tests/it/rails/drawer.rs +++ b/crates/ui-panels/tests/it/rails/drawer.rs @@ -178,8 +178,14 @@ fn a_revealed_tool_scrolls_into_view_and_wears_the_mark() { let toolbar = [slot(0, &[UNDO])]; let rail = Rect::from_min_size(Pos2::ZERO, Vec2::new(48.0, ROOM.y)); let target = CUT; - let reveal = pending.replace(false).then_some(&target); - ToolbarDrawer::new(rail, &groups, &toolbar, None).reveal(reveal).mark(marked.then_some(&target)).show(ui); + let mut drawer = ToolbarDrawer::new(rail, &groups, &toolbar, None); + if pending.replace(false) { + drawer = drawer.reveal(&target); + } + if marked { + drawer = drawer.mark(&target); + } + drawer.show(ui); }); fixture.room(ROOM).idle(60); // The drawer is a popover over the window, which is larger than the room: its list scrolls inside it. diff --git a/crates/ui-patterns/src/patterns/panels/palette.rs b/crates/ui-patterns/src/patterns/panels/palette.rs index 7be65d6dd..bf3e16713 100644 --- a/crates/ui-patterns/src/patterns/panels/palette.rs +++ b/crates/ui-patterns/src/patterns/panels/palette.rs @@ -140,6 +140,8 @@ pub struct CommandPalette<'a> { entries: &'a [HelpEntry], index: &'a SearchIndex, open: Bind<'a, bool>, + /// The pick counts that rank the results, 0 for a command never picked. + #[prop] uses: Option<&'a dyn Fn(&CommandRef) -> u32>, /// The commands last run, newest first. #[prop] @@ -176,13 +178,6 @@ impl<'a> CommandPalette<'a> { } } - /// The pick counts that rank the results, 0 for a command never picked. - #[must_use] - pub fn uses(mut self, uses: &'a dyn Fn(&CommandRef) -> u32) -> Self { - self.uses = Some(uses); - self - } - /// Puts `command` first in `recents`, once, keeping the newest `RECENT_KEPT`. pub fn remember(recents: &mut Vec, command: CommandRef) { recents.retain(|held| *held != command); diff --git a/crates/ui-patterns/src/patterns/presets/browser.rs b/crates/ui-patterns/src/patterns/presets/browser.rs index af3a6fc50..cefee84bb 100644 --- a/crates/ui-patterns/src/patterns/presets/browser.rs +++ b/crates/ui-patterns/src/patterns/presets/browser.rs @@ -344,6 +344,8 @@ pub struct PresetBrowser<'a, K: Clone + Eq + Hash + Send + Sync + MemoProps + 's #[prop] drop_zone: Option, actions: Vec