Resizable windows now expand automatically

This expansion only triggers if the root widget measures larger than the
window's current size. We can't set a minimum size explicitly unless a
Resize widget is present, as we don't have enough knowledge to ensure
that the exact measurement we received was indeed the smallest layout in
any given direction. We only know that given the current constraints,
the returned measurement was the smallest possible. All future queries
will have to still be done again, as any change to the constraints could
impact the measured size.
This commit is contained in:
Jonathan Johnson 2023-11-29 19:05:43 -08:00
parent 03e93adb15
commit bd37279282
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
2 changed files with 6 additions and 1 deletions

View file

@ -150,6 +150,7 @@ impl FrameInfo {
fn measure(&self, available: ConstraintLimit, content: UPx) -> (UPx, UPx, UPx) {
match available {
ConstraintLimit::Fill(size) => {
let size = size.max(content);
let remaining = size.saturating_sub(content);
let (a, b) = match (self.a, self.b) {
(Some(a), Some(b)) => (a, b),

View file

@ -664,7 +664,7 @@ where
window_size.map(ConstraintLimit::SizeToFit)
});
let actual_size = if root_mode == RootMode::Align {
window_size
window_size.max(layout_size)
} else {
layout_size
};
@ -680,6 +680,10 @@ where
let _ = layout_context
.winit()
.request_inner_size(PhysicalSize::from(new_size));
} else if render_size != actual_size && resizable {
let _ = layout_context
.winit()
.request_inner_size(PhysicalSize::from(actual_size));
}
self.root.set_layout(Rect::from(render_size.into_signed()));