Merge pull request #76025 from YuriSizov/editor-reparentable-windows

Expose dialog parent-and-popup logic to the API
This commit is contained in:
Rémi Verschelde 2023-05-16 10:49:09 +02:00
commit 508a5bf16e
No known key found for this signature in database
GPG key ID: C3336907360768E1
12 changed files with 242 additions and 82 deletions

View file

@ -205,6 +205,43 @@
Plays the main scene.
</description>
</method>
<method name="popup_dialog">
<return type="void" />
<param index="0" name="dialog" type="Window" />
<param index="1" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)" />
<description>
Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive]. The dialog must have no current parent, otherwise the method fails.
See also [method Window.set_unparent_when_invisible].
</description>
</method>
<method name="popup_dialog_centered">
<return type="void" />
<param index="0" name="dialog" type="Window" />
<param index="1" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
<description>
Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive_centered]. The dialog must have no current parent, otherwise the method fails.
See also [method Window.set_unparent_when_invisible].
</description>
</method>
<method name="popup_dialog_centered_clamped">
<return type="void" />
<param index="0" name="dialog" type="Window" />
<param index="1" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
<param index="2" name="fallback_ratio" type="float" default="0.75" />
<description>
Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive_centered_clamped]. The dialog must have no current parent, otherwise the method fails.
See also [method Window.set_unparent_when_invisible].
</description>
</method>
<method name="popup_dialog_centered_ratio">
<return type="void" />
<param index="0" name="dialog" type="Window" />
<param index="1" name="ratio" type="float" default="0.8" />
<description>
Pops up the [param dialog] in the editor UI with [method Window.popup_exclusive_centered_ratio]. The dialog must have no current parent, otherwise the method fails.
See also [method Window.set_unparent_when_invisible].
</description>
</method>
<method name="reload_scene_from_path">
<return type="void" />
<param index="0" name="scene_filepath" type="String" />

View file

@ -328,6 +328,12 @@
If [param include_internal] is [code]false[/code], the index won't take internal children into account, i.e. first non-internal child will have index of 0 (see [code]internal[/code] parameter in [method add_child]).
</description>
</method>
<method name="get_last_exclusive_window" qualifiers="const">
<return type="Window" />
<description>
Returns the [Window] that contains this node, or the last exclusive child in a chain of windows starting with the one that contains this node.
</description>
</method>
<method name="get_multiplayer_authority" qualifiers="const">
<return type="int" />
<description>

View file

@ -375,6 +375,52 @@
Popups the [Window] centered inside its parent [Window] and sets its size as a [param ratio] of parent's size.
</description>
</method>
<method name="popup_exclusive">
<return type="void" />
<param index="0" name="from_node" type="Node" />
<param index="1" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)" />
<description>
Attempts to parent this dialog to the last exclusive window relative to [param from_node], and then calls [method Window.popup] on it. The dialog must have no current parent, otherwise the method fails.
See also [method set_unparent_when_invisible] and [method Node.get_last_exclusive_window].
</description>
</method>
<method name="popup_exclusive_centered">
<return type="void" />
<param index="0" name="from_node" type="Node" />
<param index="1" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
<description>
Attempts to parent this dialog to the last exclusive window relative to [param from_node], and then calls [method Window.popup_centered] on it. The dialog must have no current parent, otherwise the method fails.
See also [method set_unparent_when_invisible] and [method Node.get_last_exclusive_window].
</description>
</method>
<method name="popup_exclusive_centered_clamped">
<return type="void" />
<param index="0" name="from_node" type="Node" />
<param index="1" name="minsize" type="Vector2i" default="Vector2i(0, 0)" />
<param index="2" name="fallback_ratio" type="float" default="0.75" />
<description>
Attempts to parent this dialog to the last exclusive window relative to [param from_node], and then calls [method Window.popup_centered_clamped] on it. The dialog must have no current parent, otherwise the method fails.
See also [method set_unparent_when_invisible] and [method Node.get_last_exclusive_window].
</description>
</method>
<method name="popup_exclusive_centered_ratio">
<return type="void" />
<param index="0" name="from_node" type="Node" />
<param index="1" name="ratio" type="float" default="0.8" />
<description>
Attempts to parent this dialog to the last exclusive window relative to [param from_node], and then calls [method Window.popup_centered_ratio] on it. The dialog must have no current parent, otherwise the method fails.
See also [method set_unparent_when_invisible] and [method Node.get_last_exclusive_window].
</description>
</method>
<method name="popup_exclusive_on_parent">
<return type="void" />
<param index="0" name="from_node" type="Node" />
<param index="1" name="parent_rect" type="Rect2i" />
<description>
Attempts to parent this dialog to the last exclusive window relative to [param from_node], and then calls [method Window.popup_on_parent] on it. The dialog must have no current parent, otherwise the method fails.
See also [method set_unparent_when_invisible] and [method Node.get_last_exclusive_window].
</description>
</method>
<method name="popup_on_parent">
<return type="void" />
<param index="0" name="parent_rect" type="Rect2i" />
@ -465,6 +511,14 @@
Sets layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew).
</description>
</method>
<method name="set_unparent_when_invisible">
<return type="void" />
<param index="0" name="unparent" type="bool" />
<description>
If [param unparent] is [code]true[/code], the window is automatically unparented when going invisible.
[b]Note:[/b] Make sure to keep a reference to the node, otherwise it will be orphaned. You also need to manually call [method Node.queue_free] to free the window if it's not parented.
</description>
</method>
<method name="set_use_font_oversampling">
<return type="void" />
<param index="0" name="enable" type="bool" />