From 5688ca688c0a372b0f43a1d4bef630da01a0d383 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 16 Feb 2022 22:29:11 +0800 Subject: [PATCH] Backport editor type icons Co-authored-by: FireForge --- editor/editor_properties_array_dict.cpp | 70 +++++++++++++++++-------- editor/editor_properties_array_dict.h | 1 + editor/project_settings_editor.cpp | 32 ++++++----- editor/project_settings_editor.h | 4 +- 4 files changed, 71 insertions(+), 36 deletions(-) diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 1cce305b9a2..1568bfd7bfd 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -501,20 +501,33 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d } void EditorPropertyArray::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAG_BEGIN) { - if (is_visible_in_tree()) { - if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { - dropping = true; + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + 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_icon(type, "EditorIcons"), type, i); + } + change_type->add_separator(); + change_type->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Remove Item"), Variant::VARIANT_MAX); + } break; + + case NOTIFICATION_DRAG_BEGIN: { + if (is_visible_in_tree()) { + if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { + dropping = true; + edit->update(); + } + } + } break; + + case NOTIFICATION_DRAG_END: { + if (dropping) { + dropping = false; edit->update(); } - } - } - - if (p_what == NOTIFICATION_DRAG_END) { - if (dropping) { - dropping = false; - edit->update(); - } + } break; } } @@ -1092,10 +1105,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", this, "_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_icon("Add", "EditorIcons")); + button_add_item->connect("pressed", this, "_add_key_value"); + add_vbox->add_child(button_add_item); } } @@ -1115,6 +1129,22 @@ void EditorPropertyDictionary::_object_id_selected(const String &p_property, Obj } void EditorPropertyDictionary::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + 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_icon(type, "EditorIcons"), type, i); + } + change_type->add_separator(); + change_type->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Remove Item"), Variant::VARIANT_MAX); + + if (Object::cast_to