From d5d05386a658875bf3fff908ceb879158d1a1c2f Mon Sep 17 00:00:00 2001 From: fire540 Date: Mon, 24 Jan 2022 18:16:05 -0600 Subject: [PATCH] Add type icons to Project Settings, Array, and Dictionary editors --- editor/editor_properties_array_dict.cpp | 47 +++++++++++++++---------- editor/editor_properties_array_dict.h | 1 + editor/project_settings_editor.cpp | 22 ++++++------ 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 71a855b22c2..cfed86d1ae6 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -502,6 +502,16 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d } void EditorPropertyArray::_notification(int p_what) { + if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { + change_type->clear(); + for (int i = 0; i < Variant::VARIANT_MAX; i++) { + String type = Variant::get_type_name(Variant::Type(i)); + change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i); + } + change_type->add_separator(); + change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX); + } + if (p_what == NOTIFICATION_DRAG_BEGIN) { if (is_visible_in_tree()) { if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { @@ -691,13 +701,6 @@ EditorPropertyArray::EditorPropertyArray() { change_type = memnew(PopupMenu); add_child(change_type); change_type->connect("id_pressed", callable_mp(this, &EditorPropertyArray::_change_type_menu)); - - for (int i = 0; i < Variant::VARIANT_MAX; i++) { - String type = Variant::get_type_name(Variant::Type(i)); - change_type->add_item(type, i); - } - change_type->add_separator(); - change_type->add_item(TTR("Remove Item"), Variant::VARIANT_MAX); changing_type_index = -1; subtype = Variant::NIL; @@ -1119,10 +1122,11 @@ void EditorPropertyDictionary::update_property() { prop->update_property(); if (i == amount + 1) { - Button *butt_add_item = memnew(Button); - butt_add_item->set_text(TTR("Add Key/Value Pair")); - butt_add_item->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_add_key_value)); - add_vbox->add_child(butt_add_item); + button_add_item = memnew(Button); + button_add_item->set_text(TTR("Add Key/Value Pair")); + button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_add_key_value)); + add_vbox->add_child(button_add_item); } } @@ -1142,6 +1146,19 @@ void EditorPropertyDictionary::_object_id_selected(const StringName &p_property, } void EditorPropertyDictionary::_notification(int p_what) { + if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { + change_type->clear(); + for (int i = 0; i < Variant::VARIANT_MAX; i++) { + String type = Variant::get_type_name(Variant::Type(i)); + change_type->add_icon_item(get_theme_icon(type, SNAME("EditorIcons")), type, i); + } + change_type->add_separator(); + change_type->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Remove Item"), Variant::VARIANT_MAX); + + if (Object::cast_to