summaryrefslogtreecommitdiffstats
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8cd57536bf..feddb1e779 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -875,6 +875,17 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override,
}
emit_signal(SNAME("size_changed"));
+
+ Rect2i limit = get_visible_rect();
+ for (int i = 0; i < gui.sub_windows.size(); ++i) {
+ Window *sw = gui.sub_windows[i].window;
+ Rect2i rect = Rect2i(sw->position, sw->size);
+ Rect2i new_rect = sw->fit_rect_in_parent(rect, limit);
+ if (new_rect != rect) {
+ sw->set_position(new_rect.position);
+ sw->set_size(new_rect.size);
+ }
+ }
}
Size2i Viewport::_get_size() const {
@@ -2553,23 +2564,7 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
Rect2i new_rect(gui.subwindow_drag_pos + diff, gui.subwindow_focused->get_size());
if (gui.subwindow_focused->is_clamped_to_embedder()) {
- Size2i limit = get_visible_rect().size;
- if (new_rect.position.x + new_rect.size.x > limit.x) {
- new_rect.position.x = limit.x - new_rect.size.x;
- }
- if (new_rect.position.y + new_rect.size.y > limit.y) {
- new_rect.position.y = limit.y - new_rect.size.y;
- }
-
- if (new_rect.position.x < 0) {
- new_rect.position.x = 0;
- }
-
- int title_height = gui.subwindow_focused->get_flag(Window::FLAG_BORDERLESS) ? 0 : gui.subwindow_focused->get_theme_constant(SNAME("title_height"));
-
- if (new_rect.position.y < title_height) {
- new_rect.position.y = title_height;
- }
+ new_rect = gui.subwindow_focused->fit_rect_in_parent(new_rect, get_visible_rect());
}
gui.subwindow_focused->_rect_changed_callback(new_rect);