Merge pull request #94522 from RoyBerardo/move-array-dict-remove-item

Make "Remove Item" appear at the top of the list when editing the value of an array or dictionary
This commit is contained in:
Rémi Verschelde 2024-08-28 09:45:31 +02:00
commit 51c7ff86ff
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 4 additions and 4 deletions

View File

@ -644,6 +644,8 @@ void EditorPropertyArray::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
change_type->clear(); change_type->clear();
change_type->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Remove Item"), Variant::VARIANT_MAX);
change_type->add_separator();
for (int i = 0; i < Variant::VARIANT_MAX; i++) { for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) { if (i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) {
// These types can't be constructed or serialized properly, so skip them. // These types can't be constructed or serialized properly, so skip them.
@ -653,8 +655,6 @@ void EditorPropertyArray::_notification(int p_what) {
String type = Variant::get_type_name(Variant::Type(i)); String type = Variant::get_type_name(Variant::Type(i));
change_type->add_icon_item(get_editor_theme_icon(type), type, i); change_type->add_icon_item(get_editor_theme_icon(type), type, i);
} }
change_type->add_separator();
change_type->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Remove Item"), Variant::VARIANT_MAX);
if (button_add_item) { if (button_add_item) {
button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); button_add_item->set_icon(get_editor_theme_icon(SNAME("Add")));
@ -1117,6 +1117,8 @@ void EditorPropertyDictionary::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
change_type->clear(); change_type->clear();
change_type->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Remove Item"), Variant::VARIANT_MAX);
change_type->add_separator();
for (int i = 0; i < Variant::VARIANT_MAX; i++) { for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) { if (i == Variant::CALLABLE || i == Variant::SIGNAL || i == Variant::RID) {
// These types can't be constructed or serialized properly, so skip them. // These types can't be constructed or serialized properly, so skip them.
@ -1126,8 +1128,6 @@ void EditorPropertyDictionary::_notification(int p_what) {
String type = Variant::get_type_name(Variant::Type(i)); String type = Variant::get_type_name(Variant::Type(i));
change_type->add_icon_item(get_editor_theme_icon(type), type, i); change_type->add_icon_item(get_editor_theme_icon(type), type, i);
} }
change_type->add_separator();
change_type->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Remove Item"), Variant::VARIANT_MAX);
if (button_add_item) { if (button_add_item) {
button_add_item->set_icon(get_editor_theme_icon(SNAME("Add"))); button_add_item->set_icon(get_editor_theme_icon(SNAME("Add")));