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

Pass current value to EditorInterface node/property popups #94323

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

Naros
Copy link
Contributor

@Naros Naros commented Jul 13, 2024

Fixes #94322

As outlined in the issue, while these new methods are nice in Godot 4.3, they don't seem to hit the mark in terms of being fully user friendly without being able to specify a current value, should these be used in cases where the addon already has an existing value and would prefer to highlight that in the dialog when its shown.

@Naros Naros requested a review from a team as a code owner July 13, 2024 18:14
@Naros Naros force-pushed the GH-94322 branch 2 times, most recently from 1dabc9c to 998e212 Compare July 13, 2024 18:34
@AThousandShips

This comment was marked as resolved.

@Naros
Copy link
Contributor Author

Naros commented Jul 13, 2024

You need to bind compatibility methods, see here

Even if these methods were introduced in an alpha/beta build of Godot 4.3?

The practical reason behind this PR in the first place was to address the shortcomings of the original implementation so that when it gets into a stable build, these APIs are reasonably feature complete and to avoid needing compatibility methods.

@AThousandShips
Copy link
Member

Oh my bad didn't know they were current, then it's unnecessary

AThousandShips
AThousandShips previously approved these changes Jul 18, 2024
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

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

Not familiar with the internals so a second eye on this would be good but the code looks good to me and the existing interface is just employed

@AThousandShips AThousandShips requested a review from a team July 18, 2024 18:15
@KoBeWi
Copy link
Member

KoBeWi commented Jul 22, 2024

The current_value in popup_property_selector() seems to do nothing. Nothing is selected no matter what I tried to use.

@Naros
Copy link
Contributor Author

Naros commented Jul 23, 2024

The current_value in popup_property_selector() seems to do nothing. Nothing is selected no matter what I tried to use.

I wonder if that is a bug in the actual base dialog implementation because all this PR allows you to pass the same value the editor would pass when using this dialog in the engine or C++ modules.

I'll take a look after work today and get back to you, @KoBeWi.

@Naros
Copy link
Contributor Author

Naros commented Jul 25, 2024

Hi @KoBeWi so I checked the code in the property_selector.h and property_selector.cpp files and it does seem that while one can pass the current "selected" value into the dialog, the logic within PropertySelector::_update_search does not actually do anything with the member variable selected.

Looking more closely at the uses of PropertySelector, there are 8 public methods that pass the current value and store that in the selected member variable; however, while the member variable's value is set by those 8 methods, it's not used internally in any of the presentation logic sadly.

So I think for completeness, we should at the very least keep the ability to pass this value on the EditorInterface. This minimizes the need to introduce any compatibility method after-the-fact. I think the question is really how do we want to address this bug, as a part of this PR or a follow-up.

I'm of the opinion that give where we are with 4.3, we should likely take care of addressing the PropertySelector implementation bug separately at the outset of 4.4 and then consider backporting that fix. That would give us enough time to battle test not only the variant exposed by the EditorInterface, but the other 7 public methods on the class in case the editor would like to make use of those in the future. What do others think? @akien-mga ?

@AThousandShips AThousandShips dismissed their stale review July 25, 2024 08:52

Questions remain

@KoBeWi
Copy link
Member

KoBeWi commented Jul 25, 2024

Well, you added a new argument and it didn't require any compatibility code, so looks like adding arguments in the future is not a problem.
I think this can be pushed to 4.4 and let you can finish it properly.

@KoBeWi
Copy link
Member

KoBeWi commented Aug 19, 2024

Almost. The view is not centered on the property, but awkwardly cut at the top:
image

@Naros
Copy link
Contributor Author

Naros commented Aug 19, 2024

Almost. The view is not centered on the property, but awkwardly cut at the top

I'll take a look and see if I can reproduce it; however, I used scroll_to_item with center on item 🤔

@KoBeWi
Copy link
Member

KoBeWi commented Aug 19, 2024

Well my test code is this:

@tool
extends EditorScript

func _run() -> void:
	EditorInterface.popup_property_selector(get_scene().get_node("Icon"), Callable(), [], "z_index")

(requires "Icon" node in the current scene)

@Naros
Copy link
Contributor Author

Naros commented Aug 23, 2024

Thanks @KoBeWi, fixed. It appears I needed to delay the scroll_to_item until the end of the frame since building of the list was still in-flight and the offset would obviously change due to additional items added.

@AThousandShips
Copy link
Member

AThousandShips commented Aug 23, 2024

You've added your own compatibility file, this isn't correct, it should be added to the existing 4.3-stable.expected (creation of these files is handled by maintainers, you don't need to do it yourself)

@Naros
Copy link
Contributor Author

Naros commented Aug 24, 2024

You've added your own compatibility file, this isn't correct, it should be added to the existing 4.3-stable.expected (creation of these files is handled by maintainers, you don't need to do it yourself)

Well, as you can see that file doesn't exist based on the HEAD of this PR, and so I based those changes on what I saw in other PRs. I'll rebase and amend the existing file. Is this documented somewhere ?

@Naros Naros force-pushed the GH-94322 branch 3 times, most recently from eeced9a to 45ce5f1 Compare August 24, 2024 06:07
@AThousandShips
Copy link
Member

Don't think it's documented but it's a general maintenance thing, good to rebase after a release to make sure things are up to date

<description>
Pops up an editor dialog for selecting a [Node] from the edited scene. The [param callback] must take a single argument of type [NodePath]. It is called on the selected [NodePath] or the empty path [code]^""[/code] if the dialog is canceled. If [param valid_types] is provided, the dialog will only show Nodes that match one of the listed Node types.
Pops up an editor dialog for selecting a [Node] from the edited scene. The [param callback] must take a single argument of type [NodePath]. It is called on the selected [NodePath] or the empty path [code]^""[/code] if the dialog is canceled. If [param valid_types] is provided, the dialog will only show Nodes that match one of the listed Node types. If [param current_value] is provided, the Node will be automatically selected in the tree, if it exists.
Copy link
Member

@KoBeWi KoBeWi Sep 1, 2024

Choose a reason for hiding this comment

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

Extraneous space

Suggested change
Pops up an editor dialog for selecting a [Node] from the edited scene. The [param callback] must take a single argument of type [NodePath]. It is called on the selected [NodePath] or the empty path [code]^""[/code] if the dialog is canceled. If [param valid_types] is provided, the dialog will only show Nodes that match one of the listed Node types. If [param current_value] is provided, the Node will be automatically selected in the tree, if it exists.
Pops up an editor dialog for selecting a [Node] from the edited scene. The [param callback] must take a single argument of type [NodePath]. It is called on the selected [NodePath] or the empty path [code]^""[/code] if the dialog is canceled. If [param valid_types] is provided, the dialog will only show Nodes that match one of the listed Node types. If [param current_value] is provided, the Node will be automatically selected in the tree, if it exists.

Same below.

@Naros Naros force-pushed the GH-94322 branch 2 times, most recently from 52de0e8 to b6abb12 Compare September 1, 2024 23:19
@akien-mga akien-mga merged commit c282e17 into godotengine:master Sep 3, 2024
19 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants