diff options
Diffstat (limited to 'scene/gui/margin_container.cpp')
-rw-r--r-- | scene/gui/margin_container.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp index fde5df6b72..5f798f445c 100644 --- a/scene/gui/margin_container.cpp +++ b/scene/gui/margin_container.cpp @@ -31,7 +31,10 @@ Size2 MarginContainer::get_minimum_size() const { - int margin = get_constant("margin"); + int margin_left = get_constant("margin_left"); + int margin_top = get_constant("margin_top"); + int margin_right = get_constant("margin_right"); + int margin_bottom = get_constant("margin_bottom"); Size2 max; @@ -52,9 +55,10 @@ Size2 MarginContainer::get_minimum_size() const { max.height = s.height; } - max.width += margin; - return max; + max.width += (margin_left + margin_right); + max.height += (margin_top + margin_bottom); + return max; } @@ -62,7 +66,10 @@ void MarginContainer::_notification(int p_what) { if (p_what==NOTIFICATION_SORT_CHILDREN) { - int margin = get_constant("margin"); + int margin_left = get_constant("margin_left"); + int margin_top = get_constant("margin_top"); + int margin_right = get_constant("margin_right"); + int margin_bottom = get_constant("margin_bottom"); Size2 s = get_size(); @@ -73,13 +80,10 @@ void MarginContainer::_notification(int p_what) { continue; if (c->is_set_as_toplevel()) continue; - int w; - if (c->get_h_size_flags() & Control::SIZE_EXPAND) - w=s.width-margin; - else - w=c->get_combined_minimum_size().width; - fit_child_in_rect(c,Rect2(margin,0,s.width-margin,s.height)); + int w=s.width-margin_left-margin_right; + int h=s.height-margin_top-margin_bottom; + fit_child_in_rect(c,Rect2(margin_left,margin_top,w,h)); } } |