Skip to content

Commit

Permalink
Allow to get a list of visible embedded Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
YeldhamDev committed Aug 16, 2023
1 parent 90f90cb commit de27df5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/classes/Viewport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
Returns an individual bit on the rendering layer mask.
</description>
</method>
<method name="get_embedded_subwindows" qualifiers="const">
<return type="Window[]" />
<description>
Returns a list of the visible embedded [Window]s inside the viewport.
[b]Note:[/b] [Window]s inside other viewports will not be listed.
</description>
</method>
<method name="get_final_transform" qualifiers="const">
<return type="Transform2D" />
<description>
Expand Down
11 changes: 11 additions & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,7 @@ Window *Viewport::get_base_window() const {

return w;
}

void Viewport::_gui_remove_focus_for_window(Node *p_window) {
if (get_base_window() == p_window) {
gui_release_focus();
Expand Down Expand Up @@ -3656,6 +3657,15 @@ bool Viewport::is_embedding_subwindows() const {
return gui.embed_subwindows_hint;
}

TypedArray<Window> Viewport::get_embedded_subwindows() const {
TypedArray<Window> windows;
for (int i = 0; i < gui.sub_windows.size(); i++) {
windows.append(gui.sub_windows[i].window);
}

return windows;
}

void Viewport::subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_rect) {
int index = _sub_window_find(p_window);
ERR_FAIL_COND(index == -1);
Expand Down Expand Up @@ -4384,6 +4394,7 @@ void Viewport::_bind_methods() {

ClassDB::bind_method(D_METHOD("set_embedding_subwindows", "enable"), &Viewport::set_embedding_subwindows);
ClassDB::bind_method(D_METHOD("is_embedding_subwindows"), &Viewport::is_embedding_subwindows);
ClassDB::bind_method(D_METHOD("get_embedded_subwindows"), &Viewport::get_embedded_subwindows);

ClassDB::bind_method(D_METHOD("set_canvas_cull_mask", "mask"), &Viewport::set_canvas_cull_mask);
ClassDB::bind_method(D_METHOD("get_canvas_cull_mask"), &Viewport::get_canvas_cull_mask);
Expand Down
1 change: 1 addition & 0 deletions scene/main/viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ class Viewport : public Node {

void set_embedding_subwindows(bool p_embed);
bool is_embedding_subwindows() const;
TypedArray<Window> get_embedded_subwindows() const;
void subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_rect);
Rect2i subwindow_get_popup_safe_rect(Window *p_window) const;

Expand Down

0 comments on commit de27df5

Please sign in to comment.