Skip to content

armgit / godot

Public Imported from GitHub
0

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

Fix `set_offsets_preset`

Sotoac5877f30fda
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index e73388351f5..f101dd8050b 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1352,7 +1352,7 @@ void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz
ERR_FAIL_INDEX((int)p_resize_mode, 4);
// Calculate the size if the node is not resized
- Size2 min_size = get_minimum_size();
+ Size2 min_size = get_bound_minimum_size();
Size2 new_size = get_size();
if (p_resize_mode == PRESET_MODE_MINSIZE || p_resize_mode == PRESET_MODE_KEEP_HEIGHT) {
new_size.x = min_size.x;
@@ -1377,21 +1377,21 @@ void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz
case PRESET_LEFT_WIDE:
case PRESET_HCENTER_WIDE:
case PRESET_FULL_RECT:
- data.offset[0] = x * (0.0 - data.anchor[0]) + p_margin + parent_rect.position.x;
+ data.offset[0] = x * (0.0 - data.anchor[0]) + p_margin;
break;
case PRESET_CENTER_TOP:
case PRESET_CENTER_BOTTOM:
case PRESET_CENTER:
case PRESET_VCENTER_WIDE:
- data.offset[0] = x * (0.5 - data.anchor[0]) - new_size.x / 2 + parent_rect.position.x;
+ data.offset[0] = x * (0.5 - data.anchor[0]) - new_size.x / 2;
break;
case PRESET_TOP_RIGHT:
case PRESET_BOTTOM_RIGHT:
case PRESET_CENTER_RIGHT:
case PRESET_RIGHT_WIDE:
- data.offset[0] = x * (1.0 - data.anchor[0]) - new_size.x - p_margin + parent_rect.position.x;
+ data.offset[0] = x * (1.0 - data.anchor[0]) - new_size.x - p_margin;
break;
}
@@ -1405,21 +1405,21 @@ void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz
case PRESET_TOP_WIDE:
case PRESET_VCENTER_WIDE:
case PRESET_FULL_RECT:
- data.offset[1] = parent_rect.size.y * (0.0 - data.anchor[1]) + p_margin + parent_rect.position.y;
+ data.offset[1] = parent_rect.size.y * (0.0 - data.anchor[1]) + p_margin;
break;
case PRESET_CENTER_LEFT:
case PRESET_CENTER_RIGHT:
case PRESET_CENTER:
case PRESET_HCENTER_WIDE:
- data.offset[1] = parent_rect.size.y * (0.5 - data.anchor[1]) - new_size.y / 2 + parent_rect.position.y;
+ data.offset[1] = parent_rect.size.y * (0.5 - data.anchor[1]) - new_size.y / 2;
break;
case PRESET_BOTTOM_LEFT:
case PRESET_BOTTOM_RIGHT:
case PRESET_CENTER_BOTTOM:
case PRESET_BOTTOM_WIDE:
- data.offset[1] = parent_rect.size.y * (1.0 - data.anchor[1]) - new_size.y - p_margin + parent_rect.position.y;
+ data.offset[1] = parent_rect.size.y * (1.0 - data.anchor[1]) - new_size.y - p_margin;
break;
}
@@ -1429,14 +1429,14 @@ void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz
case PRESET_BOTTOM_LEFT:
case PRESET_CENTER_LEFT:
case PRESET_LEFT_WIDE:
- data.offset[2] = x * (0.0 - data.anchor[2]) + new_size.x + p_margin + parent_rect.position.x;
+ data.offset[2] = x * (0.0 - data.anchor[2]) + new_size.x + p_margin;
break;
case PRESET_CENTER_TOP:
case PRESET_CENTER_BOTTOM:
case PRESET_CENTER:
case PRESET_VCENTER_WIDE:
- data.offset[2] = x * (0.5 - data.anchor[2]) + new_size.x / 2 + parent_rect.position.x;
+ data.offset[2] = x * (0.5 - data.anchor[2]) + new_size.x / 2;
break;
case PRESET_TOP_RIGHT:
@@ -1447,7 +1447,7 @@ void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz
case PRESET_BOTTOM_WIDE:
case PRESET_HCENTER_WIDE:
case PRESET_FULL_RECT:
- data.offset[2] = x * (1.0 - data.anchor[2]) - p_margin + parent_rect.position.x;
+ data.offset[2] = x * (1.0 - data.anchor[2]) - p_margin;
break;
}
@@ -1457,14 +1457,14 @@ void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz
case PRESET_TOP_RIGHT:
case PRESET_CENTER_TOP:
case PRESET_TOP_WIDE:
- data.offset[3] = parent_rect.size.y * (0.0 - data.anchor[3]) + new_size.y + p_margin + parent_rect.position.y;
+ data.offset[3] = parent_rect.size.y * (0.0 - data.anchor[3]) + new_size.y + p_margin;
break;
case PRESET_CENTER_LEFT:
case PRESET_CENTER_RIGHT:
case PRESET_CENTER:
case PRESET_HCENTER_WIDE:
- data.offset[3] = parent_rect.size.y * (0.5 - data.anchor[3]) + new_size.y / 2 + parent_rect.position.y;
+ data.offset[3] = parent_rect.size.y * (0.5 - data.anchor[3]) + new_size.y / 2;
break;
case PRESET_BOTTOM_LEFT:
@@ -1475,7 +1475,7 @@ void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz
case PRESET_BOTTOM_WIDE:
case PRESET_VCENTER_WIDE:
case PRESET_FULL_RECT:
- data.offset[3] = parent_rect.size.y * (1.0 - data.anchor[3]) - p_margin + parent_rect.position.y;
+ data.offset[3] = parent_rect.size.y * (1.0 - data.anchor[3]) - p_margin;
break;
}