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 c495eb5 commit b7d5304
Show file tree
Hide file tree
Showing 3 changed files with 21 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
12 changes: 12 additions & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,16 @@ Window *Viewport::get_base_window() const {

return w;
}

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::_gui_remove_focus_for_window(Node *p_window) {
if (get_base_window() == p_window) {
gui_release_focus();
Expand Down Expand Up @@ -4385,6 +4395,8 @@ 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
2 changes: 2 additions & 0 deletions scene/main/viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ class Viewport : public Node {
Viewport *get_parent_viewport() const;
Window *get_base_window() const;

TypedArray<Window> get_embedded_subwindows() const;

void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);

void set_canvas_cull_mask(uint32_t p_layers);
Expand Down

0 comments on commit b7d5304

Please sign in to comment.