|
@@ -883,6 +883,13 @@ 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);
|
|
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.
|
|
/// Presets and layout modes.
|
|
|
|
|
|
void Control::_set_layout_mode(LayoutMode p_mode) {
|
|
void Control::_set_layout_mode(LayoutMode p_mode) {
|
|
@@ -1413,10 +1420,13 @@ void Control::set_position(const Point2 &p_point, bool p_keep_offsets) {
|
|
}
|
|
}
|
|
#endif // TOOLS_ENABLED
|
|
#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) {
|
|
if (p_keep_offsets) {
|
|
- _compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor);
|
|
|
|
|
|
+ _compute_anchors(Rect2(p_point, offset_size), data.offset, data.anchor);
|
|
} else {
|
|
} else {
|
|
- _compute_offsets(Rect2(p_point, data.size_cache), data.anchor, data.offset);
|
|
|
|
|
|
+ _compute_offsets(Rect2(p_point, offset_size), data.anchor, data.offset);
|
|
}
|
|
}
|
|
_size_changed();
|
|
_size_changed();
|
|
}
|
|
}
|
|
@@ -1706,14 +1716,8 @@ Size2 Control::get_combined_minimum_size() const {
|
|
|
|
|
|
void Control::_size_changed() {
|
|
void Control::_size_changed() {
|
|
Rect2 parent_rect = get_parent_anchorable_rect();
|
|
Rect2 parent_rect = get_parent_anchorable_rect();
|
|
-
|
|
|
|
real_t edge_pos[4];
|
|
real_t edge_pos[4];
|
|
-
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ _compute_edge_positions(parent_rect, edge_pos);
|
|
Point2 new_pos_cache = Point2(edge_pos[0], edge_pos[1]);
|
|
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;
|
|
Size2 new_size_cache = Point2(edge_pos[2], edge_pos[3]) - new_pos_cache;
|
|
|
|
|