-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Make the "Quick Open" dialog available via EditorInterface
#97633
Conversation
Needs rebase after #56772 |
f2f9687
to
5736066
Compare
editor/editor_interface.cpp
Outdated
@@ -36,6 +36,7 @@ | |||
#include "editor/editor_main_screen.h" | |||
#include "editor/editor_node.h" | |||
#include "editor/editor_paths.h" | |||
#include "editor/editor_quick_open.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "editor/editor_quick_open.h" | |
#include "editor/gui/editor_quick_open_dialog.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the dialog is used and some features changed. It will require a bit more changes.
It is a close-on-selection dialogue now. Support for multi-selection was removed. |
5736066
to
74411f2
Compare
I changed the arguments to match the new implementation. Also, there was no way to tell if the dialog was canceled since the new implementation uses a callback instead of signals and it doesn't call when canceled. I made changes so it calls with an empty string when canceled. |
error when using default second argument. You can make it default to
Is it a problem that canceled dialog doesn't call the callback?
Opening multiple files with the dialog is rather rare, so it was removed to allow opening the file faster. |
74411f2
to
cc21128
Compare
Not sure if that's possible with the binding API, I couldn't find any example. I made it a required argument with an error check.
Not for the editor's current behavior. But for addons the user may want a way to know. The other popups call it when canceled as well. |
You could use
You can make a TypedArray variable, append default and put it in DEFVAL. |
editor/editor_interface.cpp
Outdated
@@ -336,6 +337,20 @@ void EditorInterface::popup_property_selector(Object *p_object, const Callable & | |||
property_selector->connect(SNAME("canceled"), canceled_callback, CONNECT_DEFERRED); | |||
} | |||
|
|||
void EditorInterface::popup_quick_open(const Callable &p_callback, const TypedArray<StringName> &p_base_types) { | |||
ERR_FAIL_COND_MSG(p_base_types.is_empty(), "The list of base types for quick open dialog can't be empty."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you can just append "Resource" when the array is empty.
cc21128
to
09988b9
Compare
Windows don't have it. Used |
70b2abe
to
6f4e171
Compare
Although it works fine CI is failing because the test suite doesn't support appended values for TypedArrays. godot\tests/core/object/test_class_db.h(453): ERROR: CHECK_FALSE( !arg_defval_valid_data ) is NOT correct!
values: CHECK_FALSE( true )
logged: Invalid default value for parameter 'base_types' of method 'EditorInterface.popup_quick_open'. Must be zero. |
Well after you made |
6f4e171
to
ca9bb07
Compare
editor/editor_interface.cpp
Outdated
for (int i = 0; i < p_base_types.size(); i++) { | ||
base_types.append(p_base_types[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (int i = 0; i < p_base_types.size(); i++) { | |
base_types.append(p_base_types[i]); | |
for (const StringName &type : p_base_types) { | |
base_types.append(type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another thing with TypedArrays that fail CI even though it works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you need to use Variant as type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see much benefit. TypedArrays are iterated with regular loops throughout the code base, including other PRs I did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely because range iteration on Array wasn't supported until recently and there is legacy code.
But whatever, someone might make a cleanup pass in the future anyway.
Looks good now. One last thing that would be nice is checking for supported types. QuickOpen dialog only supports Resource types, if you use e.g. Node or some non-existent type, the dialog will be empty with no proper feedback. You can check valid types like this: for (const StringName &type : p_base_types) {
ERR_FAIL_COND_MSG(!ClassDB::is_parent_class(type, "Resource"), "Only Resource-deriving types are supported in QuickOpen.");
} It should also be documented in the method's description. |
3b46b9d
to
775b58b
Compare
775b58b
to
35b3999
Compare
Thanks! |
Allows to use the "Quick Open" dialog in tool scripts via the
EditorInterface
without exposing internal classes. Works the same as other editor popups added in #81655.