mirror of
https://github.com/danbulant/cushy
synced 2026-06-14 03:51:17 +00:00
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:
parent
03e93adb15
commit
bd37279282
2 changed files with 6 additions and 1 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue