summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-01-02 22:34:22 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-01-02 22:34:22 -0300
commitd722537154cd87dca134e7055aa2bfdc187eb1b0 (patch)
treefe55aa815802d2b8c5628e2f160fc7a625f559e2 /scene
parent7a5a4d135e127416c2a2fadcedc9bf5e7a13b37d (diff)
-proper minimum size computation for TabContainer
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/tab_container.cpp33
-rw-r--r--scene/gui/tab_container.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 2d6f3cd27a..12a8a83f26 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -602,6 +602,39 @@ void TabContainer::get_translatable_strings(List<String> *p_strings) const {
}
+Size2 TabContainer::get_minimum_size() const {
+
+ Size2 ms;
+
+ for(int i=0;i<get_child_count();i++) {
+
+ Control *c = get_child(i)->cast_to<Control>();
+ if (!c)
+ continue;
+ if (c->is_set_as_toplevel())
+ continue;
+
+ if (!c->has_meta("_tab_name"))
+ continue;
+
+ if (!c->is_visible())
+ continue;
+
+ Size2 cms = c->get_minimum_size();
+ ms.x=MAX(ms.x,cms.x);
+ ms.y=MAX(ms.y,cms.y);
+ }
+
+ Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
+ Ref<Font> font = get_font("font");
+
+ ms.y+=MAX(tab_bg->get_minimum_size().y,tab_fg->get_minimum_size().y);
+ ms.y+=font->get_height();
+
+ return ms;
+}
+
void TabContainer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"),&TabContainer::_input_event);
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index d5b6a2b503..df7b03e040 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -85,6 +85,8 @@ public:
void set_current_tab(int p_current);
int get_current_tab() const;
+ virtual Size2 get_minimum_size() const;
+
virtual void get_translatable_strings(List<String> *p_strings) const;
TabContainer();