From fb14785f8e56308c54bf915a768d2a464aa34cd1 Mon Sep 17 00:00:00 2001 From: Babken Egoian <101829110+green2grey@users.noreply.github.com> Date: Mon, 6 Jul 2026 00:24:40 -0700 Subject: [PATCH 1/2] fix: clamp Quick Preview panel to its intended size The canvas measures at the image's natural size and gtk::Overlay allocates centered overlay children at natural size, so any image larger than 900x700 grew the panel over the whole layer surface: no backdrop left to click and the image rendered 1:1 cropped instead of fit. Nested adw::Clamp widgets (horizontal + vertical) cap the maximum while the existing size request keeps the minimum, pinning the panel at exactly 900x700. Found by Codex review on PR #5 post-merge. --- .../quickview-ui/src/windows/quick_preview.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/quickview-ui/src/windows/quick_preview.rs b/crates/quickview-ui/src/windows/quick_preview.rs index 548da07..0a4224d 100644 --- a/crates/quickview-ui/src/windows/quick_preview.rs +++ b/crates/quickview-ui/src/windows/quick_preview.rs @@ -65,12 +65,28 @@ pub fn present( backdrop.add_controller(click); } + // The canvas reports the image's natural size, and gtk::Overlay + // allocates centered overlay children at natural size — without a + // clamp a large image would grow the panel over the whole surface, + // leaving no backdrop to click. set_size_request is only a minimum; + // the clamps cap the maximum, so the panel is exactly + // PANEL_WIDTH x PANEL_HEIGHT and the canvas letterboxes inside it. + let vclamp = adw::Clamp::builder() + .maximum_size(PANEL_HEIGHT) + .orientation(gtk::Orientation::Vertical) + .child(&viewer.widget()) + .build(); + let hclamp = adw::Clamp::builder() + .maximum_size(PANEL_WIDTH) + .child(&vclamp) + .build(); + let panel = gtk::Box::new(gtk::Orientation::Vertical, 0); panel.set_halign(gtk::Align::Center); panel.set_valign(gtk::Align::Center); panel.set_size_request(PANEL_WIDTH, PANEL_HEIGHT); panel.add_css_class("qv-preview-panel"); - panel.append(&viewer.widget()); + panel.append(&hclamp); let overlay = gtk::Overlay::new(); overlay.set_child(Some(&backdrop)); From ada98fb2f538f49677b0d435cc76e396037abbc6 Mon Sep 17 00:00:00 2001 From: Babken Egoian <101829110+green2grey@users.noreply.github.com> Date: Mon, 6 Jul 2026 00:34:41 -0700 Subject: [PATCH 2/2] fix: pin clamp tightening threshold to maximum size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AdwClamp's default tightening_threshold (400) makes the clamp's own natural size ease out well past maximum_size to give the child a run-in, and gtk::Overlay allocates centered children at natural size — so a large image could still push the panel to ~1900x1300. Threshold == maximum removes the easing margin entirely. Found by Codex on PR #8. --- crates/quickview-ui/src/windows/quick_preview.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/quickview-ui/src/windows/quick_preview.rs b/crates/quickview-ui/src/windows/quick_preview.rs index 0a4224d..916d99a 100644 --- a/crates/quickview-ui/src/windows/quick_preview.rs +++ b/crates/quickview-ui/src/windows/quick_preview.rs @@ -71,13 +71,18 @@ pub fn present( // leaving no backdrop to click. set_size_request is only a minimum; // the clamps cap the maximum, so the panel is exactly // PANEL_WIDTH x PANEL_HEIGHT and the canvas letterboxes inside it. + // tightening_threshold == maximum_size: with the default (400) the + // clamp's own natural size eases out well past maximum to give the + // child a run-in, which the Overlay would happily allocate. let vclamp = adw::Clamp::builder() .maximum_size(PANEL_HEIGHT) + .tightening_threshold(PANEL_HEIGHT) .orientation(gtk::Orientation::Vertical) .child(&viewer.widget()) .build(); let hclamp = adw::Clamp::builder() .maximum_size(PANEL_WIDTH) + .tightening_threshold(PANEL_WIDTH) .child(&vclamp) .build();