Skip to content

Commit

Permalink
Use the gray color for all abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MewPurPur committed Aug 31, 2023
1 parent 6758a7f commit 398ca4e
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 38 deletions.
14 changes: 6 additions & 8 deletions editor/create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}

Expand Down Expand Up @@ -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));
}
}
}
Expand All @@ -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));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions editor/editor_feature_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<StringName> child_classes;
ClassDB::get_direct_inheriters_from_class(p_class, &child_classes);
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void EditorHelp::_add_type_icon(const String &p_type, int p_size, const String &
Ref<Texture2D> 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;
Expand Down
9 changes: 1 addition & 8 deletions editor/editor_help_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Texture2D> 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);
Expand Down Expand Up @@ -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"))) {
}
1 change: 0 additions & 1 deletion editor/editor_help_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class EditorHelpSearch::Runner : public RefCounted {
Vector<String> terms;
int search_flags;

Ref<Texture2D> empty_icon;
Color disabled_color;

HashMap<String, DocData::ClassDoc>::Iterator iterator_doc;
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2795,15 +2795,15 @@ 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");
}
}
}

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.
Expand Down
12 changes: 11 additions & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4330,9 +4330,19 @@ Ref<Texture2D> 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;
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ class EditorNode : public Node {
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_class_icon(const String &p_class, const String &p_fallback = "Object");
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);

Expand Down
7 changes: 5 additions & 2 deletions editor/editor_themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ void EditorColorMap::create() {
add_conversion_color_pair("#f9f9f9", "#606060"); // Scrollbar grabber highlight color

add_conversion_color_pair("#c38ef1", "#a85de9"); // Animation
add_conversion_color_pair("#fc7f7f", "#cd3838"); // Spatial
add_conversion_color_pair("#8da5f3", "#3d64dd"); // 2D
add_conversion_color_pair("#4b70ea", "#1a3eac"); // 2D Dark
add_conversion_color_pair("#8eef97", "#2fa139"); // Control
add_conversion_color_pair("#7582a8", "#6d83c8"); // 2D Abstract
add_conversion_color_pair("#fc7f7f", "#cd3838"); // 3D
add_conversion_color_pair("#b56d6d", "#be6a6a"); // 3D Abstract
add_conversion_color_pair("#8eef97", "#2fa139"); // GUI Control
add_conversion_color_pair("#76ad7b", "#64a66a"); // GUI Control Abstract

add_conversion_color_pair("#5fb2ff", "#0079f0"); // Selection (blue)
add_conversion_color_pair("#003e7a", "#2b74bb"); // Selection (darker blue)
Expand Down
2 changes: 1 addition & 1 deletion editor/icons/BaseButton.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/CameraAttributes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/CanvasItem.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/Font.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/GeometryInstance3D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/Mesh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions editor/icons/ObjectDisabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/Occluder3D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/Range.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/VideoStream.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/Viewport.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion editor/icons/VisualInstance3D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 398ca4e

Please sign in to comment.