Godot Engine – Multi-platform 2D and 3D game engine
Fix buttons in `EditorProperty` overlapping with values
Michael Alexsander582a8ef44af9
diff --git a/editor/gui/editor_spin_slider.cpp b/editor/gui/editor_spin_slider.cppindex f0e569d47f8..9531f272d48 100644--- a/editor/gui/editor_spin_slider.cpp+++ b/editor/gui/editor_spin_slider.cpp@@ -62,6 +62,9 @@ Size2 EditorSpinSlider::get_minimum_size() const {int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("LineEdit"));Size2 ms = sb->get_minimum_size();+ Ref<Texture2D> updown = read_only ? theme_cache.updown_disabled_icon : theme_cache.updown_icon;+ ms.width += updown->get_width();+ms.height += font->get_height(font_size);ms.height = MAX(ms.height, get_theme_constant(SNAME("inspector_property_height"), EditorStringName(Editor)));@@ -352,8 +355,6 @@ void EditorSpinSlider::_draw_spin_slider() {int label_width = font->get_string_size(label, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width;int number_width = size.width - sb->get_minimum_size().width - label_width - sep;- Ref<Texture2D> updown = get_theme_icon(read_only ? SNAME("updown_disabled") : SNAME("updown"), SNAME("SpinBox"));-String numstr = get_text_value();int vofs = (size.height - font->get_height(font_size)) / 2 + font->get_ascent(font_size);diff --git a/editor/inspector/editor_inspector.cpp b/editor/inspector/editor_inspector.cppindex eb293f5e849..386ec6caa33 100644--- a/editor/inspector/editor_inspector.cpp+++ b/editor/inspector/editor_inspector.cpp@@ -250,6 +250,20 @@ Size2 EditorProperty::get_minimum_size() const {ms = ms.max(minsize);}+ if (!label.is_empty()) {+ ms.width += theme_cache.font_offset + theme_cache.horizontal_separation;+ }++ // Always take the revert and pin values into account, since their state can be changed at whim+ // and we don't want to update the min width every time this happens.+ {+ if (!is_read_only()) {+ ms.width += theme_cache.revert_icon->get_width() + theme_cache.padding + theme_cache.horizontal_separation;+ }++ ms.width += theme_cache.pin_icon->get_width() + theme_cache.horizontal_separation;+ }+if (keying) {ms.width += theme_cache.key_icon->get_width() + theme_cache.padding + theme_cache.horizontal_separation;}@@ -344,12 +358,13 @@ void EditorProperty::_notification(int p_what) {{int child_room = size.width * (1.0 - split_ratio) - name_fixed_size;- int separation = 4 * EDSCALE;+ int separation = theme_cache.horizontal_separation;int height = theme_cache.inspector_property_height;+ int minw = 0;int half_padding = theme_cache.padding / 2;bool no_children = true;- //compute room needed+ // Compute the room needed.for (int i = 0; i < get_child_count(); i++) {Control *c = as_sortable_control(get_child(i));if (!c) {@@ -361,7 +376,8 @@ void EditorProperty::_notification(int p_what) {Size2 minsize = c->get_combined_minimum_size();if (c != left_container && c != right_container) {- child_room = MAX(child_room, minsize.width);+ minw = MAX(minw, minsize.width);+ child_room = MAX(child_room, minw);no_children = false;}height = MAX(height, minsize.height);@@ -410,7 +426,7 @@ void EditorProperty::_notification(int p_what) {if (no_children) {// Use full padding to avoid overlapping with the revert button.- text_size -= key->get_width() + half_padding * 2 + separation;+ text_size -= key->get_width() + half_padding * (2 * EDSCALE) + separation;}}@@ -429,16 +445,27 @@ void EditorProperty::_notification(int p_what) {// Account for the space needed on the outer side// when any of the icons are visible.if (keying || deletable) {- separation = theme_cache.horizontal_separation;rect.size.x -= separation;if (is_layout_rtl()) {rect.position.x += separation;}}++ // Guarantee that the minimum width+ // of the properties are respected.+ int diff = rect.size.x - minw;+ if (diff < 0) {+ text_size += diff;++ rect.size.x = minw;+ if (!is_layout_rtl()) {+ rect.position.x += diff;+ }+ }}- //set children+ // Set the children's positions.for (int i = 0; i < get_child_count(); i++) {Control *c = as_sortable_control(get_child(i));if (!c) {@@ -480,7 +507,7 @@ void EditorProperty::_notification(int p_what) {fit_child_in_rect(left_container, Rect2(0, 0, size.x - right_size, ls.y));}- queue_redraw(); //need to redraw text+ queue_redraw(); // Need to redraw the text.} break;case NOTIFICATION_DRAW: {@@ -528,8 +555,8 @@ void EditorProperty::_notification(int p_what) {int ofs = theme_cache.font_offset;int text_limit = text_size - ofs;- int half_padding = EDITOR_GET("interface/theme/base_spacing");- int padding = half_padding * 2;+ int padding = theme_cache.padding;+ int half_padding = theme_cache.padding / 2;int left_ofs = left_container->get_combined_minimum_size().x;ofs += left_ofs;@@ -547,7 +574,7 @@ void EditorProperty::_notification(int p_what) {Point2 rtl_pos;if (rtl) {- rtl_pos = Point2(size.width - check_rect.position.x - (checkbox->get_width() + padding + (1 * EDSCALE)), check_rect.position.y);+ rtl_pos = Point2(size.width - check_rect.position.x - (checkbox->get_width() + padding + EDSCALE), check_rect.position.y);}Color color2(1, 1, 1);@@ -579,12 +606,13 @@ void EditorProperty::_notification(int p_what) {if (can_revert && !is_read_only()) {const Ref<Texture2D> &reload_icon = theme_cache.revert_icon;- text_limit -= reload_icon->get_width() + half_padding + theme_cache.horizontal_separation;- revert_rect = Rect2(ofs + text_limit, 0, reload_icon->get_width() + padding + (1 * EDSCALE), size.height);+ int rectw = reload_icon->get_width() + half_padding + theme_cache.horizontal_separation;+ text_limit -= rectw;+ revert_rect = Rect2(ofs + text_limit, 0, rectw, size.height);Point2 rtl_pos;if (rtl) {- rtl_pos = Point2(size.width - revert_rect.position.x - (reload_icon->get_width() + padding + (1 * EDSCALE)), revert_rect.position.y);+ rtl_pos = Point2(size.width - revert_rect.position.x - rectw, revert_rect.position.y);}Color color2(1, 1, 1);@@ -5161,6 +5189,9 @@ void EditorInspector::update_tree() {get_root_inspector()->set_follow_focus(true);}use_folding = old_use_folding_state;++ // The minimum size of the properties could have changed.+ update_minimum_size();}void EditorInspector::update_property(const String &p_prop) {