Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix inpector properties overlapping their left containers

Michael Alexsandere0b0998f6431
diff --git a/editor/inspector/editor_inspector.cpp b/editor/inspector/editor_inspector.cpp
index 92fd2dd633d..b020228686d 100644
--- a/editor/inspector/editor_inspector.cpp
+++ b/editor/inspector/editor_inspector.cpp
@@ -376,12 +376,15 @@ void EditorProperty::_notification(int p_what) {
right_child_rect = Rect2();
bottom_child_rect = Rect2();
+ Size2 left_container_ms = left_container->get_combined_minimum_size();
+ Size2 right_container_ms = right_container->get_combined_minimum_size();
+
{
int child_room = size.width * (1.0 - split_ratio) - name_fixed_size;
int separation = theme_cache.horizontal_separation;
int height = theme_cache.inspector_property_height;
- int minw = 0;
int half_padding = theme_cache.padding / 2;
+ real_t minw = 0;
bool no_children = true;
// Compute the room needed.
@@ -394,12 +397,16 @@ void EditorProperty::_notification(int p_what) {
continue;
}
- Size2 minsize = c->get_combined_minimum_size();
+ Size2 minsize;
if (c != left_container && c != right_container) {
+ minsize = c->get_combined_minimum_size();
minw = MAX(minw, minsize.width);
child_room = MAX(child_room, minw);
no_children = false;
+ } else {
+ minsize = c == left_container ? left_container_ms : right_container_ms;
}
+
height = MAX(height, minsize.height);
}
@@ -418,11 +425,9 @@ void EditorProperty::_notification(int p_what) {
}
}
- if (rect.size.x > 1) {
- rect.size.x -= right_container->get_combined_minimum_size().x;
- if (is_layout_rtl()) {
- rect.position.x += right_container->get_combined_minimum_size().x;
- }
+ rect.size.width -= right_container_ms.width;
+ if (is_layout_rtl()) {
+ rect.position.x += right_container_ms.width;
}
if (bottom_editor) {
@@ -479,7 +484,7 @@ void EditorProperty::_notification(int p_what) {
// Guarantee that the minimum width
// of the properties are respected.
- int diff = rect.size.x - minw;
+ real_t diff = rect.size.x - minw;
if (diff < 0) {
text_size += diff;
@@ -488,6 +493,18 @@ void EditorProperty::_notification(int p_what) {
rect.position.x += diff;
}
}
+
+ // Respect the left container's minimum width.
+ if (is_layout_rtl()) {
+ real_t current_left_container_size = size.x - (rect.position.x + rect.size.x);
+ if (current_left_container_size < left_container_ms.width) {
+ rect.size.x -= left_container_ms.width - current_left_container_size;
+ }
+ } else if (rect.position.x < left_container_ms.width) {
+ diff = left_container_ms.width - rect.position.x;
+ rect.position.x += diff;
+ rect.size.width -= diff;
+ }
}
// Set the children's positions.
@@ -515,7 +532,7 @@ void EditorProperty::_notification(int p_what) {
bottom_child_rect = bottom_rect;
}
- Size2 rs = right_container->get_combined_minimum_size();
+ Size2 rs = right_container_ms;
rs.y = MAX(rs.y, rect.size.y);
if (is_layout_rtl()) {
fit_child_in_rect(right_container, Rect2(0, 0, rs.width, rs.y));
@@ -523,7 +540,7 @@ void EditorProperty::_notification(int p_what) {
fit_child_in_rect(right_container, Rect2(size.width - rs.width, 0, rs.width, rs.y));
}
- Size2 ls = left_container->get_combined_minimum_size();
+ Size2 ls = left_container_ms;
real_t right_size = rect.size.x + rs.x;
ls.y = MAX(ls.y, rect.size.y);
if (is_layout_rtl()) {