-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Refactor editor icon retrieval #21717
Conversation
There are some style issues: https://travis-ci.org/godotengine/godot/jobs/423784992 |
72282c9
to
ad11551
Compare
@akien-mga Should be good to go, if someone wants to review it. |
editor/animation_bezier_editor.cpp
Outdated
@@ -29,6 +29,7 @@ | |||
/*************************************************************************/ | |||
|
|||
#include "animation_bezier_editor.h" | |||
#include "editor/editor_node.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.
Please always leave an empty line between the .cpp's own header (animation_bezier_editor.h
) and the other Godot headers.
Rebase needed after my change of |
7ffb941
to
afd5d6d
Compare
editor/editor_data.cpp
Outdated
} | ||
} | ||
|
||
Ref<Texture> EditorData::get_object_icon(const Object *p_object, const Control *p_control, const String &p_fallback) const { |
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 way too complicated. Make the function part of EditorNode and get the icon from the theme or from the gui_base instance, so you dont have to pass instances around.
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.
Done.
e344cff
to
bd328c1
Compare
editor/editor_node.cpp
Outdated
return NULL; | ||
} | ||
|
||
Ref<Texture> EditorNode::get_object_icon_name(const String &p_class, const String &p_fallback) const { |
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.
Two suggestions about this function:
- rename to get_class_icon (i think it makes more sense)
- fallback could have a default argument "Object" so it does not need to be passed always
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.
Done.
bd328c1
to
5436abe
Compare
Thanks! |
It looks like this has a ton of different changes, but the vast majority of this is just about centralizing copy-pasta code all over the Godot Editor into a centralized location that does the same processing in every case (rather than bits and pieces that the copy-pasta had induced at various locations).
Fixes #21615 and circumvents any previous "fixes" surrounding "_editor_icon" metadata.
EditorData::script_class_get_name(p_path)
so that a path alone can fetch us the name, and from there, the icon path. Start caching these values duringEditorFileSystem::_scan_script_classes(...)
.EditorData::get_object_icon(obj, ...)
andEditorData::get_object_icon_name(name, ...)
to fetch the appropriate editor icon depending on whether an object pointer or a String/StringName is available. Edit: we changedget_object_icon_name
toget_class_icon
.current_item_is_preferred
in thecpp_type
case (prevents a possibleClassDB::is_parent_class()
ERR_FAIL_COND_V trigger).get_icon(...)
calls in the editor classes, so I started to evaluate all of those files and determine if their usage could be converted into an EditorData call without compromising their logical functionality. I believe I've done that, but I'm sure people will want to investigate it further.