From e442e3d220a8ac43460e8927da2afe56da76392f Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 24 Oct 2026 23:36:03 +0000 Subject: [PATCH] Docking: a panel with no recorded place opens beside the photo on its side Showing a panel that has no hidden entry skips craft-ui's right-edge fallback and opens it beside the photo view on the panel's default side. Test: Library opens to the left of the photo, Presets to the right. --- crates/ui-egui/src/docking.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index 636081967..017ffe842 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -128,10 +128,14 @@ fn set_visible(workspace: &mut Workspace, panel: Panel, visible: bool) -> Result return apply(workspace, Action::Close { panel }); } validate(workspace)?; - let mut next = workspace.clone(); - if next.set_visible(panel, true, None, permissions).is_ok() && validate(&next).is_ok() { - *workspace = next; - return Ok(()); + // Without a recorded place craft-ui opens the panel at the right edge; LightCraft puts it + // beside the photo instead. + if workspace.hidden.iter().any(|(hidden, _)| *hidden == panel) { + let mut next = workspace.clone(); + if next.set_visible(panel, true, None, permissions).is_ok() && validate(&next).is_ok() { + *workspace = next; + return Ok(()); + } } apply(workspace, Action::OpenAt { panel, anchor: Panel::Canvas, placement: Placement::Split(panel.default_side()) }) } @@ -578,4 +582,15 @@ mod tests { assert_eq!(saved["version"], 2); assert_eq!(saved["layout"]["floating"][0]["panels"], json!(["tools"]), "a one-group window keeps the v1 shape"); } + + #[test] + fn a_panel_without_a_recorded_place_opens_beside_the_photo_on_its_side() { + for (panel, zone) in [(Panel::Library, Zone::Left), (Panel::Presets, Zone::Right)] { + let root = split(SplitAxis::Horizontal, SplitSize::FixedSecond(300.0), tabs(Panel::Canvas), tabs(Panel::Tools)); + let mut workspace = Workspace::new(Layout { root: Some(root), floating: Vec::new() }); + set_visible(&mut workspace, panel, true).unwrap(); + let location = workspace.layout.location(&panel).unwrap(); + assert_eq!((location.anchor, location.placement), (Some(Panel::Canvas), Placement::Split(zone)), "{panel:?}"); + } + } }