mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Fallback to parent class icon by default for gdextension
This commit is contained in:
parent
250ef8dc32
commit
ce2fae79b1
19 changed files with 41 additions and 31 deletions
|
|
@ -412,7 +412,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
|
|||
if (node) {
|
||||
int ofs = 0;
|
||||
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node);
|
||||
|
||||
text = node->get_name();
|
||||
ofs += h_separation;
|
||||
|
|
|
|||
|
|
@ -858,7 +858,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
|
|||
|
||||
if (base->has_node(accum)) {
|
||||
Node *node = base->get_node(accum);
|
||||
ti->set_icon(0, EditorNode::get_singleton()->get_object_icon(node, "Node"));
|
||||
ti->set_icon(0, EditorNode::get_singleton()->get_object_icon(node));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2177,7 +2177,7 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
}
|
||||
text_color.a *= 0.7;
|
||||
} else if (node) {
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node);
|
||||
const Vector2 icon_size = Vector2(1, 1) * get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor));
|
||||
|
||||
icon_rect = Rect2(Point2(ofs, (get_size().height - check->get_height()) / 2).round(), icon->get_size());
|
||||
|
|
@ -5110,7 +5110,7 @@ void AnimationTrackEditor::_update_tracks() {
|
|||
if (root) {
|
||||
Node *n = root->get_node_or_null(base_path);
|
||||
if (n) {
|
||||
icon = EditorNode::get_singleton()->get_object_icon(n, "Node");
|
||||
icon = EditorNode::get_singleton()->get_object_icon(n);
|
||||
name = n->get_name();
|
||||
tooltip = String(root->get_path_to(n));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
|
|||
} else {
|
||||
item->set_tooltip_text(0, node.name + "\n" + TTR("Instance:") + " " + node.scene_file_path + "\n" + TTR("Type:") + " " + node.type_name);
|
||||
}
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(node.type_name, "");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(node.type_name);
|
||||
if (icon.is_valid()) {
|
||||
item->set_icon(0, icon);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -974,7 +974,7 @@ void EditorHelp::_update_doc() {
|
|||
_push_title_font();
|
||||
|
||||
class_desc->add_text(TTR("Class:") + " ");
|
||||
_add_type_icon(edited_class, theme_cache.doc_title_font_size, "Object");
|
||||
_add_type_icon(edited_class, theme_cache.doc_title_font_size, "");
|
||||
class_desc->add_text(nbsp);
|
||||
|
||||
class_desc->push_color(theme_cache.headline_color);
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ void InspectorDock::_prepare_history() {
|
|||
|
||||
already.insert(id);
|
||||
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj, "Object");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
|
||||
|
||||
String text;
|
||||
if (obj->has_method("_get_editor_name")) {
|
||||
|
|
|
|||
|
|
@ -5266,7 +5266,7 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na
|
|||
}
|
||||
}
|
||||
|
||||
Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, const String &p_script_path, const String &p_fallback, bool p_fallback_script_to_theme) {
|
||||
Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, const String &p_script_path, const String &p_fallback, bool p_fallback_script_to_theme, bool p_skip_fallback_virtual) {
|
||||
ERR_FAIL_COND_V_MSG(p_class.is_empty(), nullptr, "Class name cannot be empty.");
|
||||
EditorData &ed = EditorNode::get_editor_data();
|
||||
|
||||
|
|
@ -5289,8 +5289,9 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons
|
|||
base_type = scr->get_instance_base_type();
|
||||
}
|
||||
}
|
||||
if (theme.is_valid() && theme->has_icon(base_type, EditorStringName(EditorIcons))) {
|
||||
return theme->get_icon(base_type, EditorStringName(EditorIcons));
|
||||
if (theme.is_valid()) {
|
||||
bool instantiable = !ClassDB::is_virtual(p_class) && ClassDB::can_instantiate(p_class);
|
||||
return _get_class_or_script_icon(base_type, "", "", false, p_skip_fallback_virtual || instantiable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5324,11 +5325,20 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons
|
|||
|
||||
// If the fallback is empty or wasn't found, use the default fallback.
|
||||
if (ClassDB::class_exists(p_class)) {
|
||||
bool instantiable = !ClassDB::is_virtual(p_class) && ClassDB::can_instantiate(p_class);
|
||||
if (ClassDB::is_parent_class(p_class, SNAME("Node"))) {
|
||||
return theme->get_icon(instantiable ? "Node" : "NodeDisabled", EditorStringName(EditorIcons));
|
||||
} else {
|
||||
return theme->get_icon(instantiable ? "Object" : "ObjectDisabled", EditorStringName(EditorIcons));
|
||||
if (!p_skip_fallback_virtual) {
|
||||
bool instantiable = !ClassDB::is_virtual(p_class) && ClassDB::can_instantiate(p_class);
|
||||
if (!instantiable) {
|
||||
if (ClassDB::is_parent_class(p_class, SNAME("Node"))) {
|
||||
return theme->get_icon("NodeDisabled", EditorStringName(EditorIcons));
|
||||
} else {
|
||||
return theme->get_icon("ObjectDisabled", EditorStringName(EditorIcons));
|
||||
}
|
||||
}
|
||||
}
|
||||
StringName parent = ClassDB::get_parent_class_nocheck(p_class);
|
||||
if (parent) {
|
||||
// Skip virtual class if `p_skip_fallback_virtual` is true or `p_class` is instantiable.
|
||||
return _get_class_or_script_icon(parent, "", "", false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ private:
|
|||
void _feature_profile_changed();
|
||||
bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);
|
||||
|
||||
Ref<Texture2D> _get_class_or_script_icon(const String &p_class, const String &p_script_path, const String &p_fallback = "Object", bool p_fallback_script_to_theme = false);
|
||||
Ref<Texture2D> _get_class_or_script_icon(const String &p_class, const String &p_script_path, const String &p_fallback = "", bool p_fallback_script_to_theme = false, bool p_skip_fallback_virtual = false);
|
||||
Ref<Texture2D> _get_editor_theme_native_menu_icon(const StringName &p_name, bool p_global_menu, bool p_dark_mode) const;
|
||||
|
||||
void _pick_main_scene_custom_action(const String &p_custom_action_name);
|
||||
|
|
@ -938,7 +938,7 @@ public:
|
|||
|
||||
Ref<Script> get_object_custom_type_base(const Object *p_object) const;
|
||||
StringName get_object_custom_type_name(const Object *p_object) const;
|
||||
Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "Object");
|
||||
Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "");
|
||||
Ref<Texture2D> get_class_icon(const String &p_class, const String &p_fallback = "");
|
||||
|
||||
bool is_object_of_custom_type(const Object *p_object, const StringName &p_class);
|
||||
|
|
|
|||
|
|
@ -1886,7 +1886,7 @@ void EditorInspectorCategory::_update_icon() {
|
|||
if (scr.is_valid()) {
|
||||
StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
||||
if (script_name == StringName()) {
|
||||
icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
|
||||
icon = EditorNode::get_singleton()->get_object_icon(scr.ptr());
|
||||
} else {
|
||||
icon = EditorNode::get_singleton()->get_class_icon(script_name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3082,7 +3082,7 @@ void EditorPropertyNodePath::update_property() {
|
|||
}
|
||||
|
||||
assign->set_text(target_node->get_name());
|
||||
assign->set_button_icon(EditorNode::get_singleton()->get_object_icon(target_node, "Node"));
|
||||
assign->set_button_icon(EditorNode::get_singleton()->get_object_icon(target_node));
|
||||
}
|
||||
|
||||
void EditorPropertyNodePath::setup(const Vector<StringName> &p_valid_types, bool p_use_path_from_scene_root, bool p_editing_node) {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ void EditorResourcePicker::_update_resource() {
|
|||
assign_button->set_text(TTR("<empty>"));
|
||||
assign_button->set_tooltip_text("");
|
||||
} else {
|
||||
assign_button->set_button_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), SNAME("Object")));
|
||||
assign_button->set_button_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->()));
|
||||
|
||||
if (!edited_resource->get_name().is_empty()) {
|
||||
assign_button->set_text(edited_resource->get_name());
|
||||
|
|
@ -576,7 +576,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
|
|||
|
||||
inheritors_array.push_back(t);
|
||||
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(t, "Object");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(t);
|
||||
int id = TYPE_BASE_ID + idx;
|
||||
edit_menu->add_icon_item(icon, t, id);
|
||||
edit_menu->set_item_auto_translate_mode(-1, AUTO_TRANSLATE_MODE_DISABLED);
|
||||
|
|
@ -1557,7 +1557,7 @@ void EditorAudioStreamPicker::_preview_draw() {
|
|||
icon_modulate = Color(1, 0.5, 0.5, 1); // get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
|
||||
}
|
||||
} else {
|
||||
icon = EditorNode::get_singleton()->get_object_icon(audio_stream.operator->(), "Object");
|
||||
icon = EditorNode::get_singleton()->get_object_icon(audio_stream.operator->());
|
||||
}
|
||||
String text;
|
||||
if (!audio_stream->get_name().is_empty()) {
|
||||
|
|
|
|||
|
|
@ -1674,7 +1674,7 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
|
|||
for (int i = 0; i < selection_results.size(); i++) {
|
||||
Node3D *spat = selection_results[i];
|
||||
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat);
|
||||
|
||||
String node_path = "/" + root_name + "/" + String(root_path.rel_path_to(spat->get_path()));
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ void EditorPropertyRootMotion::_node_assign() {
|
|||
|
||||
if (base->has_node(accum)) {
|
||||
Node *node = base->get_node(accum);
|
||||
ti->set_icon(0, EditorNode::get_singleton()->get_object_icon(node, "Node"));
|
||||
ti->set_icon(0, EditorNode::get_singleton()->get_object_icon(node));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2369,7 +2369,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|||
for (int i = 0; i < selection_results.size(); i++) {
|
||||
CanvasItem *item = selection_results[i].item;
|
||||
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(item, "Node");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(item);
|
||||
String node_path = "/" + root_name + "/" + String(root_path.rel_path_to(item->get_path()));
|
||||
|
||||
int locked = 0;
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ void EditorSceneTabs::_update_tab_titles() {
|
|||
Node *type_node = EditorNode::get_editor_data().get_edited_scene_root(i);
|
||||
Ref<Texture2D> icon;
|
||||
if (type_node) {
|
||||
icon = EditorNode::get_singleton()->get_object_icon(type_node, "Node");
|
||||
icon = EditorNode::get_singleton()->get_object_icon(type_node);
|
||||
}
|
||||
scene_tabs->set_tab_icon(i, icon);
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ void ResourcePreloaderEditor::_update_library() {
|
|||
ERR_CONTINUE(r.is_null());
|
||||
|
||||
String type = r->get_class();
|
||||
ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(type, "Object"));
|
||||
ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(type));
|
||||
ti->set_tooltip_text(0, TTR("Instance:") + " " + r->get_path() + "\n" + TTR("Type:") + " " + type);
|
||||
|
||||
ti->set_text(1, r->get_path());
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ void SceneTreeEditor::_update_node(Node *p_node, TreeItem *p_item, bool p_part_o
|
|||
}
|
||||
}
|
||||
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_node, "Node");
|
||||
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_node);
|
||||
p_item->set_icon(0, icon);
|
||||
p_item->set_metadata(0, p_node->get_path());
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ void ConnectionInfoDialog::popup_connections(const String &p_method, const Vecto
|
|||
TreeItem *node_item = tree->create_item(root);
|
||||
|
||||
node_item->set_text(0, Object::cast_to<Node>(connection.signal.get_object())->get_name());
|
||||
node_item->set_icon(0, EditorNode::get_singleton()->get_object_icon(connection.signal.get_object(), "Node"));
|
||||
node_item->set_icon(0, EditorNode::get_singleton()->get_object_icon(connection.signal.get_object()));
|
||||
node_item->set_selectable(0, false);
|
||||
node_item->set_editable(0, false);
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ void ConnectionInfoDialog::popup_connections(const String &p_method, const Vecto
|
|||
node_item->set_editable(1, false);
|
||||
|
||||
node_item->set_text(2, Object::cast_to<Node>(connection.callable.get_object())->get_name());
|
||||
node_item->set_icon(2, EditorNode::get_singleton()->get_object_icon(connection.callable.get_object(), "Node"));
|
||||
node_item->set_icon(2, EditorNode::get_singleton()->get_object_icon(connection.callable.get_object()));
|
||||
node_item->set_selectable(2, false);
|
||||
node_item->set_editable(2, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ String TextEditor::get_name() {
|
|||
}
|
||||
|
||||
Ref<Texture2D> TextEditor::get_theme_icon() {
|
||||
return EditorNode::get_singleton()->get_object_icon(edited_res.ptr(), "TextFile");
|
||||
return EditorNode::get_singleton()->get_object_icon(edited_res.ptr());
|
||||
}
|
||||
|
||||
Ref<Resource> TextEditor::get_edited_resource() const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue