Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose dialog parent-and-popup logic to the API #76025

Merged
merged 1 commit into from
May 16, 2023

Conversation

YuriSizov
Copy link
Contributor

@YuriSizov YuriSizov commented Apr 13, 2023

This was introduced in a hacky way before to fix immediate issues with some of the editor windows (see #73365). But I think we should have this feature generally accessible, so we can address similar issues in other editor windows, and so plugin developers could use it too. In fact, this is probably useful to user projects as well, if they support multiple windows.

So this removes the old hacky class and moves the necessary functionality to other places.

  • EditorInterface receives new popup_dialog_* methods to automatically reparent a window to the editor UI before popping it up.
  • Window receives set_unparent_when_invisible, a new scripting-only method to enable the "unparent this window when visibility changes to not visible" logic. It's scripting-only because using it requires you to have a script, and enabling it by accident can lead to orphan nodes. Window also receives new popup_exclusive_* methods, which power EditorInterface methods secretly.
  • Node receives get_last_exclusive_window, which tries to find the top-most exclusive child of the owner window, or returns the parent window (or nothing, if there is no window); this can be exposed as a part of Window as well, but being a part of Node makes it easier to use, as it can handle the owner window internally and return a clean result.

Marking as a draft as this is based on the EditorInterface refactoring from #75694.

@YuriSizov YuriSizov added this to the 4.1 milestone Apr 13, 2023
@YuriSizov YuriSizov force-pushed the editor-reparentable-windows branch from c5b0c37 to 0aac5e4 Compare April 19, 2023 13:51
@YuriSizov YuriSizov marked this pull request as ready for review April 19, 2023 14:02
@YuriSizov YuriSizov requested review from a team as code owners April 19, 2023 14:02
@YuriSizov
Copy link
Contributor Author

Since relevant parts were extracted with #76176, which is merged, this is now rebased on top of master and ready for review.

@YuriSizov YuriSizov requested a review from a team April 19, 2023 14:03
doc/classes/Window.xml Outdated Show resolved Hide resolved
doc/classes/EditorInterface.xml Outdated Show resolved Hide resolved
@YuriSizov YuriSizov force-pushed the editor-reparentable-windows branch from 0aac5e4 to dfb2e28 Compare April 20, 2023 14:14
@YuriSizov
Copy link
Contributor Author

@bruvzg I added popup_exclusive_* methods to Window, but kept special EditorInterface methods as well because they require a reference to EditorNode, and it just makes using the feature within the editor and plugins easier.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if popup_exclusive() is accurate name, because dialogs are exclusive by default (otherwise we wouldn't be getting exclusive errors).

Other than that looks fine.

@YuriSizov YuriSizov force-pushed the editor-reparentable-windows branch from dfb2e28 to 17f492f Compare May 15, 2023 17:49
@YuriSizov
Copy link
Contributor Author

YuriSizov commented May 15, 2023

I wonder if popup_exclusive() is accurate name, because dialogs are exclusive by default (otherwise we wouldn't be getting exclusive errors).

That's a good point. The idea behind the name is that it ensures that exclusivity is respected, but perhaps it's not clear. Don't have a better suggestion myself at the moment. I don't think it's a misnomer though.

@akien-mga akien-mga merged commit 508a5bf into godotengine:master May 16, 2023
@akien-mga
Copy link
Member

Thanks!

@YuriSizov YuriSizov deleted the editor-reparentable-windows branch May 16, 2023 11:03
reduz added a commit to reduz/godot that referenced this pull request Jan 14, 2024
This intends to be the correct way to handle non-child windows becoming covered by the current window when becoming focused.
Enabling this property on select windows, they will become transient to the currently focused one when becoming visible.

This deprecates the "unparent_when_invisible" function introduced by godotengine#76025.
GuybrushThreepwood-GitHub pushed a commit to GuybrushThreepwood-GitHub/godot that referenced this pull request Jan 27, 2024
This intends to be the correct way to handle non-child windows becoming covered by the current window when becoming focused.
Enabling this property on select windows, they will become transient to the currently focused one when becoming visible.

This deprecates the "unparent_when_invisible" function introduced by godotengine#76025.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants