Revert "Fix #100536: Control set_position resizes offsets/anchors"
This reverts commit ca57fe1db4.
This commit is contained in:
@ -902,13 +902,6 @@ void Control::_compute_offsets(Rect2 p_rect, const real_t p_anchors[4], real_t (
|
||||
r_offsets[3] = p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y);
|
||||
}
|
||||
|
||||
void Control::_compute_edge_positions(Rect2 p_rect, real_t (&r_edge_positions)[4]) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
real_t area = p_rect.size[i & 1];
|
||||
r_edge_positions[i] = data.offset[i] + (data.anchor[i] * area);
|
||||
}
|
||||
}
|
||||
|
||||
/// Presets and layout modes.
|
||||
|
||||
void Control::_set_layout_mode(LayoutMode p_mode) {
|
||||
@ -1439,13 +1432,10 @@ void Control::set_position(const Point2 &p_point, bool p_keep_offsets) {
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
real_t edge_pos[4];
|
||||
_compute_edge_positions(get_parent_anchorable_rect(), edge_pos);
|
||||
Size2 offset_size(edge_pos[2] - edge_pos[0], edge_pos[3] - edge_pos[1]);
|
||||
if (p_keep_offsets) {
|
||||
_compute_anchors(Rect2(p_point, offset_size), data.offset, data.anchor);
|
||||
_compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor);
|
||||
} else {
|
||||
_compute_offsets(Rect2(p_point, offset_size), data.anchor, data.offset);
|
||||
_compute_offsets(Rect2(p_point, data.size_cache), data.anchor, data.offset);
|
||||
}
|
||||
_size_changed();
|
||||
}
|
||||
@ -1735,8 +1725,14 @@ Size2 Control::get_combined_minimum_size() const {
|
||||
|
||||
void Control::_size_changed() {
|
||||
Rect2 parent_rect = get_parent_anchorable_rect();
|
||||
|
||||
real_t edge_pos[4];
|
||||
_compute_edge_positions(parent_rect, edge_pos);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
real_t area = parent_rect.size[i & 1];
|
||||
edge_pos[i] = data.offset[i] + (data.anchor[i] * area);
|
||||
}
|
||||
|
||||
Point2 new_pos_cache = Point2(edge_pos[0], edge_pos[1]);
|
||||
Size2 new_size_cache = Point2(edge_pos[2], edge_pos[3]) - new_pos_cache;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user