summaryrefslogtreecommitdiff
path: root/scene/gui/container.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-07-06 19:06:55 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-07-06 19:06:55 -0300
commit7c679dd8303d906ffbb469ee5b1f53efe25f69af (patch)
tree0eeb6814b2606222553f31a62e9389e58fd50626 /scene/gui/container.cpp
parentbd9d98c172bd4e9aab962f8df675120bf9f7b085 (diff)
More fill modes for containers, closes #9504
Diffstat (limited to 'scene/gui/container.cpp')
-rw-r--r--scene/gui/container.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 92bb5d43a7..2a96f8260c 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -95,13 +95,25 @@ void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
Rect2 r = p_rect;
if (!(p_child->get_h_size_flags() & SIZE_FILL)) {
- r.size.x = minsize.x;
- r.position.x += Math::floor((p_rect.size.x - minsize.x) / 2);
+ r.size.x = minsize.width;
+ if (p_child->get_h_size_flags() & SIZE_SHRINK_END) {
+ r.position.x += p_rect.size.width - minsize.width;
+ } else if (p_child->get_h_size_flags() & SIZE_SHRINK_CENTER) {
+ r.position.x += Math::floor((p_rect.size.x - minsize.width) / 2);
+ } else {
+ r.position.x += 0;
+ }
}
if (!(p_child->get_v_size_flags() & SIZE_FILL)) {
r.size.y = minsize.y;
- r.position.y += Math::floor((p_rect.size.y - minsize.y) / 2);
+ if (p_child->get_v_size_flags() & SIZE_SHRINK_END) {
+ r.position.y += p_rect.size.height - minsize.height;
+ } else if (p_child->get_v_size_flags() & SIZE_SHRINK_CENTER) {
+ r.position.y += Math::floor((p_rect.size.y - minsize.height) / 2);
+ } else {
+ r.position.y += 0;
+ }
}
for (int i = 0; i < 4; i++)