Expand Window + Resize areas to be large enough for last frames content
@@ -182,6 +182,8 @@ impl Resize {
.at_least(self.min_size)
.at_most(self.max_size);
+ let mut user_requested_size = state.requested_size.take();
+
let corner_response = if self.resizable {
// Resize-corner:
let corner_size = Vec2::splat(ui.style().visuals.resize_corner_size);
@@ -191,7 +193,8 @@ impl Resize {
if corner_response.active {
if let Some(mouse_pos) = ui.input().mouse.pos {
- state.desired_size = mouse_pos - position + 0.5 * corner_response.rect.size();
+ user_requested_size =
+ Some(mouse_pos - position + 0.5 * corner_response.rect.size());
}
}
Some(corner_response)
@@ -199,9 +202,15 @@ impl Resize {
None
};
- if let Some(requested_size) = state.requested_size.take() {
- state.desired_size = requested_size;
+ if let Some(user_requested_size) = user_requested_size {
+ state.desired_size = user_requested_size;
+ } else {
+ // We are not being actively resized, so auto-expand to include size of last frame.
+ // This prevents auto-shrinking if the contents contain width-filling widgets (separators etc)
+ // but it makes a lot of interactions with `Window`s nicer.
+ state.desired_size = state.desired_size.max(state.last_content_size);
}
+
state.desired_size = state
.desired_size
.at_least(self.min_size)
@@ -269,11 +278,6 @@ impl Resize {
ui.allocate_space(state.last_content_size);
}
- if ui.memory().resize.get(&id).is_none() {
- // First frame.
- state.desired_size = state.desired_size.at_least(state.last_content_size);
- }
-
// ------------------------------
if self.with_stroke && corner_response.is_some() {
