summaryrefslogtreecommitdiff
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
authorMichael Alexsander <michaelalexsander@protonmail.com>2022-08-04 17:11:32 -0300
committerMichael Alexsander <michaelalexsander@protonmail.com>2022-08-05 02:25:15 -0300
commit2b86c458bfc1ad093bc2dbc2847baa6f07391e1c (patch)
treeb91df005a33f3d1aaa2e16b57321bf5dcc8fd3ad /scene/main/viewport.cpp
parentb1580ea334595fc0bd2b1c2d048e43ca1c5e7cbc (diff)
Fix some bugs with `Window`s
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 4dd4c8419c..584fad9648 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2498,17 +2498,20 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
if (gui.subwindow_drag == SUB_WINDOW_DRAG_RESIZE) {
Vector2i diff = mm->get_position() - gui.subwindow_drag_from;
Size2i min_size = gui.subwindow_focused->get_min_size();
+
+ Size2i min_size_adjusted = min_size;
if (gui.subwindow_focused->is_wrapping_controls()) {
Size2i cms = gui.subwindow_focused->get_contents_minimum_size();
- min_size.x = MAX(cms.x, min_size.x);
- min_size.y = MAX(cms.y, min_size.y);
+ min_size_adjusted.x = MAX(cms.x, min_size.x);
+ min_size_adjusted.y = MAX(cms.y, min_size.y);
}
- min_size.x = MAX(min_size.x, 1);
- min_size.y = MAX(min_size.y, 1);
+
+ min_size_adjusted.x = MAX(min_size_adjusted.x, 1);
+ min_size_adjusted.y = MAX(min_size_adjusted.y, 1);
Rect2i r = gui.subwindow_resize_from_rect;
- Size2i limit = r.size - min_size;
+ Size2i limit = r.size - min_size_adjusted;
switch (gui.subwindow_resize_mode) {
case SUB_WINDOW_RESIZE_TOP_LEFT: {
@@ -2563,6 +2566,19 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
}
}
+ Size2i max_size = gui.subwindow_focused->get_max_size();
+ if ((max_size.x > 0 || max_size.y > 0) && (max_size.x >= min_size.x && max_size.y >= min_size.y)) {
+ max_size.x = MAX(max_size.x, 1);
+ max_size.y = MAX(max_size.y, 1);
+
+ if (r.size.x > max_size.x) {
+ r.size.x = max_size.x;
+ }
+ if (r.size.y > max_size.y) {
+ r.size.y = max_size.y;
+ }
+ }
+
gui.subwindow_focused->_rect_changed_callback(r);
}
@@ -2600,7 +2616,7 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
Ref<Texture2D> close_icon = sw.window->get_theme_icon(SNAME("close"));
Rect2 close_rect;
- close_rect.position = Vector2(r.position.x + r.size.x - close_v_ofs, r.position.y - close_h_ofs);
+ close_rect.position = Vector2(r.position.x + r.size.x - close_h_ofs, r.position.y - close_v_ofs);
close_rect.size = close_icon->get_size();
if (gui.subwindow_focused != sw.window) {