Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion crates/quickview-ui/src/windows/quick_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,33 @@ 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.
// 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Set clamp thresholds to keep panel bounded

For large images this still lets the overlay child measure larger than the intended panel: AdwClamp::maximum_size caps the child allocation, but the clamp keeps its default tightening_threshold (400), so its own natural size eases out to about 400 + 3 * (maximum - 400) (1900px wide, 1300px tall here). Because gtk::Overlay allocates centered overlays at their natural size, a 1080p layer-shell surface can still have the preview panel fill the height and leave no clickable backdrop. Set the tightening threshold to the same value as the maximum (for both clamps) or otherwise force the clamp/panel natural size to 900×700.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid — AdwClamp's easing means the clamp's natural size runs past maximum_size when tightening_threshold (default 400) is below it, and the Overlay allocates that natural size. Fixed in ada98fb: both clamps now set tightening_threshold equal to maximum_size, removing the easing margin so the panel's natural size is truly capped at 900×700.

.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();

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));
Expand Down
Loading