diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-05-13 13:13:12 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-05-13 13:13:12 -0300 |
commit | da7a9aae2782af46b21d70452a4edcf317b8c38b (patch) | |
tree | d176ec5c1a787cad40a37ba7a8698cd88b85b3e3 | |
parent | bd3dbe5fa306c96f79190ccfcd116436d27acb93 (diff) | |
parent | d38454b9670483707f980e638a00f3c8b947906d (diff) |
Merge pull request #4096 from neikeq/pr-margin-cont-imp
MarginContainer improvements
-rw-r--r-- | scene/gui/margin_container.cpp | 24 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 5 |
2 files changed, 18 insertions, 11 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)); } } diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index ade56c4f49..9feadf91cf 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -837,7 +837,10 @@ void make_default_theme() { t->set_constant("separation","HBoxContainer",4); t->set_constant("separation","VBoxContainer",4); - t->set_constant("margin","MarginContainer",8); + t->set_constant("margin_left","MarginContainer",8); + t->set_constant("margin_top","MarginContainer",0); + t->set_constant("margin_right","MarginContainer",0); + t->set_constant("margin_bottom","MarginContainer",0); t->set_constant("hseparation","GridContainer",4); t->set_constant("vseparation","GridContainer",4); t->set_constant("separation","HSplitContainer",12); |