From 7e51840348c8c48cd9ad508778e3b7d0ad3a8775 Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 24 Nov 2026 01:13:22 +0100 Subject: [PATCH 1/3] WIP: own-window full-window dialogs keep their size (photocraft#16595) Co-Authored-By: Claude Opus 5.5 From 07a223c0ff56b43c51bd97828c0b3ca70411381c Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 24 Nov 2026 01:25:34 +0100 Subject: [PATCH 2/3] ui-contract: a full-window container's own window keeps its size A full-window container in its own OS window was sent its body's size every pass. The body leaves out the side panels, header and footer, so the window shrank by them each frame: RAW Develop's window ended a pixel wide and, still modal, blocked the app (photocraft#16595). The window now opens at the opener's content size and from then on its size is the user's, as a resizable window's is. Co-Authored-By: Claude Opus 5.5 --- crates/ui-contract/src/contract/mount.rs | 17 +++++----- .../ui-contract/tests/it/runtime/windows.rs | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/crates/ui-contract/src/contract/mount.rs b/crates/ui-contract/src/contract/mount.rs index 8f90ce438..1c7e632af 100644 --- a/crates/ui-contract/src/contract/mount.rs +++ b/crates/ui-contract/src/contract/mount.rs @@ -365,25 +365,24 @@ impl Host for ViewportHost { let spec = self.spec.clone().unwrap_or_else(by_rank); let placed = self.overlay.placed; let full_window = self.overlay.is_full_window(); - // A full-window container fills its window, so the window's own layout memory holds the size the user gave - // it; before it has one the window opens at the opener's content size, large enough for a workspace. - let measured = || { - let remembered = layout_memory::read(&ctx, id); - if full_window { remembered.or_else(|| Some(ctx.content_rect().size())) } else { remembered } - }; + // A full-window container fills its window and has no content size: its window opens at the opener's content + // size, large enough for a workspace. What its body took is no size for the window: side panels, header and + // footer are no part of it, and a window sent it shrank by them each pass (photocraft#16595). + let measured = || if full_window { Some(ctx.content_rect().size()) } else { layout_memory::read(&ctx, id) }; let open = ViewportOpen { id, title: title.as_str(), // A placed rect is the caller's size for the window, within the window's limits, which the OS would clamp it // to; then a resizable fallback's default size, as the layer takes it; the measured size is for a window // sized by content: what its body took in the window, recorded once the window reported its place - // (`steps::record_body_size`). + // (`steps::record_body_size`), or a full-window container's opening size. size: placed .map(|rect| self.overlay.size_limits.clamp(rect.size())) .or(self.overlay.size.filter(|_| self.overlay.fit == overlay::OverlayFit::Resizable)) .or_else(measured), - // A resizable window takes its default or content size to open; from then on its size is the user's. - follows_size: placed.is_some() || self.overlay.fit != overlay::OverlayFit::Resizable, + // A resizable window takes its default or content size to open; from then on its size is the user's, as a + // full-window container's is. + follows_size: placed.is_some() || (!full_window && self.overlay.fit != overlay::OverlayFit::Resizable), save: self.save.as_deref(), spec: &spec, limits: (Some(self.overlay.size_limits.min), self.overlay.size_limits.max), diff --git a/crates/ui-contract/tests/it/runtime/windows.rs b/crates/ui-contract/tests/it/runtime/windows.rs index 4827c04c6..1349e98ca 100644 --- a/crates/ui-contract/tests/it/runtime/windows.rs +++ b/crates/ui-contract/tests/it/runtime/windows.rs @@ -764,6 +764,38 @@ fn a_content_sized_window_takes_its_content_size_once_it_reported_its_place() { ); } +/// photocraft#16595: a full-window container in a window of its own keeps the size the window has. Its body takes +/// less than the window (side panels, header and footer are no part of it), and the window was sent that size each +/// frame, so it shrank until it was a pixel wide. +#[trial] +fn a_full_window_viewport_keeps_its_window_size() { + const GIVEN: Vec2 = Vec2::new(1000.0, 700.0); + let windows = Windows::new(); + let frame = || { + windows.frame(vec![], vec![], |ui| { + Palette::full_window("Workspace").show(ui, |ui, _| { + ui.allocate_exact_size(Vec2::new(300.0, 200.0), egui::Sense::hover()); + }); + }) + }; + let (dialog, _) = builder_titled(&frame(), "Workspace"); + let given = Rect::from_min_size(Pos2::new(100.0, 100.0), GIVEN); + windows.child_info(ViewportInfo { + inner_rect: Some(given), + outer_rect: Some(given), + native_pixels_per_point: Some(1.0), + ..ViewportInfo::default() + }); + let sent: Vec = (0..6) + .flat_map(|_| frame().commands) + .filter_map(|(id, command)| match command { + ViewportCommand::InnerSize(size) if id == dialog => Some(size), + _ => None, + }) + .collect(); + assert_eq!(sent, Vec::::new(), "the workspace's window keeps the size it has"); +} + /// Placing a minimized window below its smallest inner size restores it and lowers that size to the placed one, so the /// window takes the place it is given. #[trial] From b43aa1259330f7f199f59f51c3e3b74416f3b10b Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 24 Nov 2026 15:41:10 +0100 Subject: [PATCH 3/3] ui-canvas: a full-window dialog's own window is at least OWN_WINDOW_MIN_SIZE (640 x 480), so a placement saved while it shrank opens usable A placement saved while photocraft#16595 shrank RAW Develop's window could be 1 pt wide. place() raised it only to the full-window overlay's minimum, 0 x 0, and since the window now keeps its size nothing grew it again. The minimum reaches the OS window's min size and the floor a restored placement is fitted to. Co-Authored-By: Claude Opus 5.5 --- crates/imaging/tests/it/raw_develop.rs | 22 ++++++++++- crates/ui-canvas/src/canvas/full_window.rs | 14 +++++-- crates/ui-canvas/src/lib.rs | 4 +- .../ui-contract/tests/it/runtime/windows.rs | 37 +++++++++++-------- 4 files changed, 56 insertions(+), 21 deletions(-) diff --git a/crates/imaging/tests/it/raw_develop.rs b/crates/imaging/tests/it/raw_develop.rs index 782930247..213d5fb77 100644 --- a/crates/imaging/tests/it/raw_develop.rs +++ b/crates/imaging/tests/it/raw_develop.rs @@ -19,7 +19,7 @@ use craft_imaging::ui::wide_angle::PreviewDone; use craft_imaging::ui::{ChannelColor, HistogramSet, ScopeChannel}; use craft_ui::InstallSpec; use craft_ui::canvas::{PixelRect, RasterSource}; -use craft_ui::dialog::{DialogHost, DialogResult, FullWindowWorkspace as _, HostedWorkspace}; +use craft_ui::dialog::{DialogHost, DialogResult, FullWindowWorkspace as _, HostedWorkspace, OWN_WINDOW_MIN_SIZE}; use craft_ui::primitives::Revision; use craft_ui::runtime::access::Role; use craft_ui::runtime::pending::Job; @@ -251,6 +251,26 @@ fn raw_develop_window_keeps_its_size_when_the_saved_screen_is_gone() { assert!((0.0..=880.0).contains(&pos.x) && (0.0..=320.0).contains(&pos.y), "restored position is in reach: {pos:?}"); } +/// photocraft#16595: while the window shrank each frame, the placement store saved its size, 1 pt wide at 100 % +/// scaling. Restored, the window opens no smaller than a full-window dialog's own window may be, and the OS keeps it +/// there. +#[trial] +fn raw_develop_window_saved_while_shrinking_opens_at_its_minimum() { + let store = Arc::new(Mutex::new(Store::in_memory())); + store.lock().unwrap().set("craft_imaging.raw_develop.window", &Placement::new([1.0, 500.0], 1.0)); + let system = Arc::new(FakeSystem::new()); + system.set_monitors(vec![Monitor::new(MonitorKey::new("Attached", [1920, 1080]), [0, 0], [1920, 1080], 1.0)]); + let windows = Windows::with(InstallSpec::new(ShellInfo::default(), system).placement(store)); + let mut host = DialogHost::new(); + host.open(HostedWorkspace::new(RawDevelopWorkspace::new(open(RawTarget::OpenRaw)), Source::new())); + let output = windows.frame(vec![], vec![], |ui| { + host.run(ui); + }); + let (_, builder) = output.builders.iter().find(|(id, _)| *id != ViewportId::ROOT).expect("Raw Develop opens a child window"); + assert_eq!(builder.inner_size, Some(Vec2::new(OWN_WINDOW_MIN_SIZE.x, 500.0)), "the saved width is raised to the minimum"); + assert_eq!(builder.min_inner_size, Some(OWN_WINDOW_MIN_SIZE), "the OS keeps the window at least that big"); +} + #[trial] fn raw_develop_switches_raws_and_finishes_with_each_footer_button() { let host = Rc::new(RefCell::new(DialogHost::new())); diff --git a/crates/ui-canvas/src/canvas/full_window.rs b/crates/ui-canvas/src/canvas/full_window.rs index 6244a0f7e..8a8f4a594 100644 --- a/crates/ui-canvas/src/canvas/full_window.rs +++ b/crates/ui-canvas/src/canvas/full_window.rs @@ -16,7 +16,7 @@ use crate::runtime::windows::WindowSpec; use crate::sections::FooterButton; use crate::style::{ComponentStyle, StyleCx, SurfaceKind}; use craft_behavior::{Metrics, Sense}; -use egui::Ui; +use egui::{Ui, Vec2, vec2}; pub use hosted::{FullWindowWorkspace, HostedWorkspace, WorkspaceCx, WorkspacePass}; @@ -26,6 +26,11 @@ pub(crate) mod stories; #[cfg(feature = "suite")] pub(crate) mod trials; +/// The least a full-window dialog's own window may be, in points: the OS window's minimum, and the floor a restored +/// placement is fitted to. A placement saved while photocraft#16595 shrank the window could be 1 pt wide; without +/// a floor it opened that small and nothing grew it again. +pub const OWN_WINDOW_MIN_SIZE: Vec2 = vec2(640.0, 480.0); + /// The style of a full-window dialog: the surface comes from the container. #[derive(Clone, Debug, Default, PartialEq, ComponentStyle)] #[non_exhaustive] @@ -121,13 +126,14 @@ impl<'a> FullWindowDialog<'a> { .label(title) } - /// Shows the dialog in its own OS window described by `spec`, resizable, opening at the saved placement; where - /// viewports are unavailable it fills the main window. The dialog's focus policy moves into the fallback overlay. + /// Shows the dialog in its own OS window described by `spec`, resizable down to [`OWN_WINDOW_MIN_SIZE`], opening at + /// the saved placement; where viewports are unavailable it fills the main window. The dialog's focus policy moves + /// into the fallback overlay. #[must_use] pub fn own_window(mut self, spec: WindowSpec) -> Self { // A viewport mount takes its scope from the fallback overlay and holds `props.focus` at none. let focus = std::mem::replace(self.focus_mut(), FocusPolicy::NONE); - self.props.mount = Mount::viewport_with(Overlay::full_window(focus), spec); + self.props.mount = Mount::viewport_with(Overlay::full_window(focus).min_size(OWN_WINDOW_MIN_SIZE), spec); self } diff --git a/crates/ui-canvas/src/lib.rs b/crates/ui-canvas/src/lib.rs index faeef0e77..639a1a938 100644 --- a/crates/ui-canvas/src/lib.rs +++ b/crates/ui-canvas/src/lib.rs @@ -31,7 +31,9 @@ pub mod canvas_controls; /// Dialog shells and prompts, with the full-window dialog family that shows a canvas. pub mod dialog { - pub use crate::canvas::full_window::{FullWindowDialog, FullWindowDialogStyle, FullWindowWorkspace, HostedWorkspace, WorkspaceCx, WorkspacePass}; + pub use crate::canvas::full_window::{ + FullWindowDialog, FullWindowDialogStyle, FullWindowWorkspace, HostedWorkspace, OWN_WINDOW_MIN_SIZE, WorkspaceCx, WorkspacePass, + }; pub use crate::canvas::full_window_parts::{ FullWindowCanvas, FullWindowCanvasOutput, FullWindowSide, FullWindowSideOutput, FullWindowSideStyle, FullWindowStatus, FullWindowStatusOutput, FullWindowTitle, FullWindowTitleOutput, FullWindowView, FullWindowZoomBar, FullWindowZoomBarOutput, RasterOverlay, diff --git a/crates/ui-contract/tests/it/runtime/windows.rs b/crates/ui-contract/tests/it/runtime/windows.rs index 878672139..c4583d428 100644 --- a/crates/ui-contract/tests/it/runtime/windows.rs +++ b/crates/ui-contract/tests/it/runtime/windows.rs @@ -779,21 +779,28 @@ fn a_full_window_viewport_keeps_its_window_size() { }) }; let (dialog, _) = builder_titled(&frame(), "Workspace"); - let given = Rect::from_min_size(Pos2::new(100.0, 100.0), GIVEN); - windows.child_info(ViewportInfo { - inner_rect: Some(given), - outer_rect: Some(given), - native_pixels_per_point: Some(1.0), - ..ViewportInfo::default() - }); - let sent: Vec = (0..6) - .flat_map(|_| frame().commands) - .filter_map(|(id, command)| match command { - ViewportCommand::InnerSize(size) if id == dialog => Some(size), - _ => None, - }) - .collect(); - assert_eq!(sent, Vec::::new(), "the workspace's window keeps the size it has"); + let report = |size: Vec2| { + let rect = Rect::from_min_size(Pos2::new(100.0, 100.0), size); + windows.child_info(ViewportInfo { + inner_rect: Some(rect), + outer_rect: Some(rect), + native_pixels_per_point: Some(1.0), + ..ViewportInfo::default() + }); + }; + let sizes_sent = || -> Vec { + (0..6) + .flat_map(|_| frame().commands) + .filter_map(|(id, command)| match command { + ViewportCommand::InnerSize(size) if id == dialog => Some(size), + _ => None, + }) + .collect() + }; + report(GIVEN); + assert_eq!(sizes_sent(), Vec::::new(), "the workspace's window keeps the size it has"); + report(Vec2::new(1200.0, 820.0)); + assert_eq!(sizes_sent(), Vec::::new(), "a size the user gives the window is kept too"); } /// Placing a minimized window below its smallest inner size restores it and lowers that size to the placed one, so the