From 398ca4e71a78c4b58a90bdec540989367d80fa67 Mon Sep 17 00:00:00 2001 From: MewPurPur Date: Tue, 1 Aug 2023 20:04:28 +0300 Subject: [PATCH] Use the gray color for all abstract classes --- editor/create_dialog.cpp | 14 ++++++-------- editor/editor_feature_profile.cpp | 6 +++--- editor/editor_help.cpp | 2 +- editor/editor_help_search.cpp | 9 +-------- editor/editor_help_search.h | 1 - editor/editor_inspector.cpp | 4 ++-- editor/editor_node.cpp | 12 +++++++++++- editor/editor_node.h | 2 +- editor/editor_themes.cpp | 7 +++++-- editor/icons/BaseButton.svg | 2 +- editor/icons/CameraAttributes.svg | 2 +- editor/icons/CanvasItem.svg | 2 +- editor/icons/Font.svg | 2 +- editor/icons/GeometryInstance3D.svg | 2 +- editor/icons/Mesh.svg | 2 +- editor/icons/ObjectDisabled.svg | 1 + editor/icons/Occluder3D.svg | 2 +- editor/icons/Range.svg | 2 +- editor/icons/VideoStream.svg | 2 +- editor/icons/Viewport.svg | 2 +- editor/icons/VisualInstance3D.svg | 2 +- 21 files changed, 42 insertions(+), 38 deletions(-) create mode 100644 editor/icons/ObjectDisabled.svg diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 8b71d7586ff..e2cb989e6a9 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -289,14 +289,12 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String bool can_instantiate = (p_type_category == TypeCategory::CPP_TYPE && ClassDB::can_instantiate(p_type)) || p_type_category == TypeCategory::OTHER_TYPE; - bool is_virtual = ClassDB::class_exists(p_type) && ClassDB::is_virtual(p_type); + bool instantiable = can_instantiate && !(ClassDB::class_exists(p_type) && ClassDB::is_virtual(p_type)); - r_item->set_meta(SNAME("__instantiable"), can_instantiate && !is_virtual); + r_item->set_meta(SNAME("__instantiable"), instantiable); - if (can_instantiate && !is_virtual) { - r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, icon_fallback)); - } else { - r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, "NodeDisabled")); + r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type)); + if (!instantiable) { r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } @@ -714,7 +712,7 @@ void CreateDialog::_save_and_update_favorite_list() { TreeItem *ti = favorites->create_item(root); ti->set_text(0, l); - ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(name, icon_fallback)); + ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(name)); } } } @@ -731,7 +729,7 @@ void CreateDialog::_load_favorites_and_history() { String name = l.get_slicec(' ', 0); if (EditorNode::get_editor_data().is_type_recognized(name) && !_is_class_disabled_by_feature_profile(name)) { - recent->add_item(l, EditorNode::get_singleton()->get_class_icon(name, icon_fallback)); + recent->add_item(l, EditorNode::get_singleton()->get_class_icon(name)); } } } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 308bf33da51..6019e9e8956 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -495,7 +495,7 @@ void EditorFeatureProfileManager::_profile_selected(int p_what) { void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected) { TreeItem *class_item = class_list->create_item(p_parent); class_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - class_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_class, "Node")); + class_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_class)); String text = p_class; bool disabled = edited->is_class_disabled(p_class); @@ -522,11 +522,11 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S class_item->select(0); } if (disabled) { - //class disabled, do nothing else (do not show further) + // Class disabled, do nothing else (do not show further). return; } - class_item->set_checked(0, true); // if its not disabled, its checked + class_item->set_checked(0, true); // If it's not disabled, it's checked. List child_classes; ClassDB::get_direct_inheriters_from_class(p_class, &child_classes); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 7573fcd21e9..14d80334b32 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -367,7 +367,7 @@ void EditorHelp::_add_type_icon(const String &p_type, int p_size, const String & Ref icon = EditorNode::get_singleton()->get_class_icon(p_type, p_fallback); Vector2i size = Vector2i(icon->get_width(), icon->get_height()); if (p_size > 0) { - // Ensures icon scales proportionally on both axis, based on icon height. + // Ensures icon scales proportionally on both axes, based on icon height. float ratio = p_size / float(size.height); size.width *= ratio; size.height *= ratio; diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 6aa508f40e0..f06a23607e5 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -593,16 +593,10 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_ } TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) { - Ref icon = empty_icon; - if (ui_service->has_theme_icon(p_doc->name, SNAME("EditorIcons"))) { - icon = ui_service->get_theme_icon(p_doc->name, SNAME("EditorIcons")); - } else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) { - icon = ui_service->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); - } String tooltip = DTR(p_doc->brief_description.strip_edges()); TreeItem *item = results_tree->create_item(p_parent); - item->set_icon(0, icon); + item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_doc->name)); item->set_text(0, p_doc->name); item->set_text(1, TTR("Class")); item->set_tooltip_text(0, tooltip); @@ -706,6 +700,5 @@ EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree, results_tree(p_results_tree), term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()), search_flags(p_search_flags), - empty_icon(ui_service->get_theme_icon(SNAME("ArrowRight"), SNAME("EditorIcons"))), disabled_color(ui_service->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))) { } diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index 6e71d788e7f..e8056ce6acd 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -122,7 +122,6 @@ class EditorHelpSearch::Runner : public RefCounted { Vector terms; int search_flags; - Ref empty_icon; Color disabled_color; HashMap::Iterator iterator_doc; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 7ac812101aa..89dcac28edf 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2795,7 +2795,7 @@ void EditorInspector::update_tree() { // Find the icon corresponding to the script. if (script_name != StringName()) { - category->icon = EditorNode::get_singleton()->get_class_icon(script_name, "Object"); + category->icon = EditorNode::get_singleton()->get_class_icon(script_name); } else { category->icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object"); } @@ -2803,7 +2803,7 @@ void EditorInspector::update_tree() { } if (category->icon.is_null() && !type.is_empty()) { - category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object"); + category->icon = EditorNode::get_singleton()->get_class_icon(type); } // Set the category label. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c6f5a6082bd..a51e1da334f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4330,9 +4330,19 @@ Ref EditorNode::_get_class_or_script_icon(const String &p_class, cons return gui_base->get_theme_icon(p_class, SNAME("EditorIcons")); } - if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, SNAME("EditorIcons"))) { + if (!p_fallback.is_empty() && gui_base->has_theme_icon(p_fallback, SNAME("EditorIcons"))) { return gui_base->get_theme_icon(p_fallback, SNAME("EditorIcons")); } + + // 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 gui_base->get_theme_icon(instantiable ? "Node" : "NodeDisabled", SNAME("EditorIcons")); + } else { + return gui_base->get_theme_icon(instantiable ? "Object" : "ObjectDisabled", SNAME("EditorIcons")); + } + } } return nullptr; diff --git a/editor/editor_node.h b/editor/editor_node.h index 86b4847e5be..7fbe095fc3d 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -868,7 +868,7 @@ public: Ref