diff options
author | ktxyz <kamil@tokarski.xyz> | 2022-10-30 15:03:01 +0100 |
---|---|---|
committer | Kamil Tokarski <kamil@tokarski.xyz> | 2022-11-08 13:20:45 +0100 |
commit | 7601808455bd95ab3f943719becd467d3b813616 (patch) | |
tree | 06f4b11ebdcbd866d80cde8227fcf3093259fcac /scene/main/viewport.cpp | |
parent | a499f7bdc4be5877c75bd898e040937a02b99b85 (diff) |
Update sub_windows order with respect to FLAG_ALWAYS_ON_TOP
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r-- | scene/main/viewport.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index f8b0a66a71..da6291ade8 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -162,6 +162,24 @@ ViewportTexture::~ViewportTexture() { } void Viewport::_sub_window_update_order() { + if (gui.sub_windows.size() < 2) { + return; + } + + if (!gui.sub_windows[gui.sub_windows.size() - 1].window->get_flag(Window::FLAG_ALWAYS_ON_TOP)) { + int index = gui.sub_windows.size() - 1; + + while (index > 0 && gui.sub_windows[index - 1].window->get_flag(Window::FLAG_ALWAYS_ON_TOP)) { + --index; + } + + if (index != (gui.sub_windows.size() - 1)) { + SubWindow sw = gui.sub_windows[gui.sub_windows.size() - 1]; + gui.sub_windows.remove_at(gui.sub_windows.size() - 1); + gui.sub_windows.insert(index, sw); + } + } + for (int i = 0; i < gui.sub_windows.size(); i++) { RS::get_singleton()->canvas_item_set_draw_index(gui.sub_windows[i].canvas_item, i); } |