From cbf17f41b937ae3a1abfcd4ba063d03a89c9f963 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 23 Nov 2026 13:20:49 +0700 Subject: [PATCH] ui-panels: the rail's locate trial is reached by a module, against the rail's Tracked slots and its reveal and mark props --- crates/ui-panels/tests/it/rails/locate.rs | 16 +++++++++++----- crates/ui-panels/tests/it/rails/mod.rs | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/ui-panels/tests/it/rails/locate.rs b/crates/ui-panels/tests/it/rails/locate.rs index 308366de9..2249829ce 100644 --- a/crates/ui-panels/tests/it/rails/locate.rs +++ b/crates/ui-panels/tests/it/rails/locate.rs @@ -2,7 +2,7 @@ //! neither chooses it. use super::{CUT, REDO, UNDO, tools}; -use craft_ui::contract::{Role, Show as _}; +use craft_ui::contract::{Role, Tracked}; use craft_ui::display::TargetMark; use craft_ui::rails::{LastUsed, SlotId, ToolRail, ToolSlot}; use craft_ui::testing::{Fixture, trial}; @@ -20,11 +20,17 @@ fn rig(reveal: Option, mark: Option) -> Rig { let selected = Rc::new(RefCell::new(Vec::new())); let flyout = Rc::new(Cell::new(None)); let (seen, opened) = (selected.clone(), flyout.clone()); + let slots = Tracked::new(vec![ToolSlot::new(0, tools(&[UNDO, REDO, CUT]))]); + let last = Tracked::new(LastUsed::default()); let mut fixture = Fixture::new(move |ui| { - let slots = [ToolSlot::new(0, tools(&[UNDO, REDO, CUT]))]; - let last = LastUsed::default(); - let current = UNDO; - let out = ToolRail::new("Tools", &slots, ¤t, &last).reveal(reveal.as_ref()).mark(mark.as_ref()).show_rail(ui, |_, _| {}); + let mut rail = ToolRail::new("Tools", &slots, &UNDO, &last); + if let Some(tool) = &reveal { + rail = rail.reveal(tool); + } + if let Some(tool) = &mark { + rail = rail.mark(tool); + } + let out = rail.show_rail(ui, |_, _| {}); if let Some(tool) = out.select { seen.borrow_mut().push(tool); } diff --git a/crates/ui-panels/tests/it/rails/mod.rs b/crates/ui-panels/tests/it/rails/mod.rs index 7488aedfc..24d4dcca3 100644 --- a/crates/ui-panels/tests/it/rails/mod.rs +++ b/crates/ui-panels/tests/it/rails/mod.rs @@ -2,6 +2,7 @@ //! click, a press dragged away, the flyout's tear-off bar and the window a torn-off group floats in. pub(crate) mod drawer; +pub(crate) mod locate; use craft_behavior::{GesturePhase, Mixed}; use craft_ui::contract::overlay::{PlacementChange, PlacementKind};