diff options
author | fire540 <isaacr.7.2005@gmail.com> | 2022-01-24 18:16:05 -0600 |
---|---|---|
committer | FireForge <isaacr.7.2005@gmail.com> | 2022-02-03 13:02:18 -0600 |
commit | d5d05386a658875bf3fff908ceb879158d1a1c2f (patch) | |
tree | 1568ecffeaccb88506bde51963c88dff9d467d53 /editor/editor_properties_array_dict.cpp | |
parent | 30701e3966fe0869868d09d57249ff140e55849e (diff) |
Add type icons to Project Settings, Array, and Dictionary editors
Diffstat (limited to 'editor/editor_properties_array_dict.cpp')
-rw-r--r-- | editor/editor_properties_array_dict.cpp | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 71a855b22c..cfed86d1ae 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<Button>(button_add_item)) { + button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + } + } } void EditorPropertyDictionary::_edit_pressed() { @@ -1179,16 +1196,10 @@ EditorPropertyDictionary::EditorPropertyDictionary() { add_focusable(edit); vbox = nullptr; page_slider = nullptr; + button_add_item = nullptr; updating = false; change_type = memnew(PopupMenu); add_child(change_type); change_type->connect("id_pressed", callable_mp(this, &EditorPropertyDictionary::_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; } |