Godot Engine – Multi-platform 2D and 3D game engine
Fix EditorPropertyArray using theme cache too early
kobewi5f03b5686799
diff --git a/editor/inspector/editor_properties_array_dict.cpp b/editor/inspector/editor_properties_array_dict.cppindex 38bf4716a0f..0a6d34c8acf 100644--- a/editor/inspector/editor_properties_array_dict.cpp+++ b/editor/inspector/editor_properties_array_dict.cpp@@ -254,6 +254,21 @@ void EditorPropertyArray::initialize_array(Variant &p_array) {}}+void EditorPropertyArray::_update_slots_size() {+ float name_size = 0;+ for (Slot &slot : slots) {+ if (name_size == 0) {+ int max_index = (page_index + 1) * page_length - 1;+ const String ms = String("M").repeat(itos(max_index).length());++ Ref<Font> font = theme_cache.font;+ int font_size = theme_cache.font_size;+ name_size = slots[0].reorder_button->get_minimum_size().x + theme_cache.horizontal_separation + font->get_string_size(ms, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x;+ }+ slot.prop->set_name_fixed_size(name_size);+ }+}+void EditorPropertyArray::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) {if (!p_property.begins_with("indices")) {return;@@ -494,7 +509,6 @@ void EditorPropertyArray::update_property() {paginator->update(page_index, max_page);paginator->set_visible(max_page > 0);- float name_size = 0;for (Slot &slot : slots) {bool slot_visible = &slot != &reorder_slot && slot.index < size;slot.container->set_visible(slot_visible);@@ -553,17 +567,11 @@ void EditorPropertyArray::update_property() {callable_mp(slot.prop, &EditorProperty::grab_focus).call_deferred(0);changing_type_index = EditorPropertyArrayObject::NOT_CHANGING_TYPE;}- if (name_size == 0) {- int max_index = (page_index + 1) * page_length - 1;- const String ms = String("M").repeat(itos(max_index).length());-- Ref<Font> font = theme_cache.font;- int font_size = theme_cache.font_size;- name_size = slots[0].reorder_button->get_minimum_size().x + theme_cache.horizontal_separation + font->get_string_size(ms, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x;- }- slot.prop->set_name_fixed_size(name_size);slot.prop->update_property();}+ if (is_inside_tree()) {+ _update_slots_size();+ }updating = false;@@ -801,6 +809,7 @@ void EditorPropertyArray::_notification(int p_what) {slot.remove_button->set_button_icon(get_editor_theme_icon(SNAME("Remove")));}}+ _update_slots_size();} break;case NOTIFICATION_DRAG_BEGIN: {if (is_visible_in_tree()) {diff --git a/editor/inspector/editor_properties_array_dict.h b/editor/inspector/editor_properties_array_dict.hindex 03b6821e0dd..df62096fac5 100644--- a/editor/inspector/editor_properties_array_dict.h+++ b/editor/inspector/editor_properties_array_dict.h@@ -133,6 +133,7 @@ class EditorPropertyArray : public EditorProperty {int reorder_to_index = -1;float reorder_mouse_y_delta = 0.0f;void initialize_array(Variant &p_array);+ void _update_slots_size();void _page_changed(int p_page);