summaryrefslogtreecommitdiff
path: root/scene/gui/scroll_container.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/scroll_container.cpp')
-rw-r--r--scene/gui/scroll_container.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index a2fc038f9e..9bf93aff77 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -35,7 +35,37 @@ bool ScrollContainer::clips_input() const {
Size2 ScrollContainer::get_minimum_size() const {
- return Size2(1, 1);
+
+ Size2 min_size;
+
+ 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 == h_scroll || c == v_scroll)
+ continue;
+ Size2 minsize = c->get_combined_minimum_size();
+
+
+ if (!scroll_h) {
+ min_size.x = MAX(min_size.x, minsize.x);
+ }
+ if (!scroll_v) {
+ min_size.y = MAX(min_size.y, minsize.y);
+
+ }
+ }
+
+ if (h_scroll->is_visible()) {
+ min_size.y+=h_scroll->get_minimum_size().y;
+ }
+ if (v_scroll->is_visible()) {
+ min_size.x+=v_scroll->get_minimum_size().x;
+ }
+ return min_size;
};
@@ -179,6 +209,12 @@ void ScrollContainer::_notification(int p_what) {
child_max_size = Size2(0, 0);
Size2 size = get_size();
+ if (h_scroll->is_visible())
+ size.y-=h_scroll->get_minimum_size().y;
+
+ if (v_scroll->is_visible())
+ size.x-=h_scroll->get_minimum_size().x;
+
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();