diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-14 13:40:24 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-14 13:40:24 +0100 |
commit | 830eff64a75a9cad211a60e91a2d804592d4d7e8 (patch) | |
tree | ac7feb223f12fc4346f2a253fb15177c0c87d531 /scene/main | |
parent | f9b043aad7bbcb2d392efece6279dbcc43cc1fca (diff) | |
parent | 7601808455bd95ab3f943719becd467d3b813616 (diff) |
Merge pull request #68027 from ktxyz/window-on-top
Update sub_windows order with respect to FLAG_ALWAYS_ON_TOP
Diffstat (limited to 'scene/main')
-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 23b7c072be..126b1d54fc 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -166,6 +166,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); } |