summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorTomasz Chabora <kobewi4e@gmail.com>2019-09-01 18:31:32 +0200
committerTomasz Chabora <kobewi4e@gmail.com>2019-09-01 18:31:32 +0200
commitaa444453b881546eb3830fe9f1b8b00774d64c3a (patch)
tree42cf2a8c5e4b6d374dadfad84caef44b0a80eb78 /scene/gui
parent4611977d49e001b9c56bf07d9c3fc1b58047f307 (diff)
Ignore size of hidden scrollbars in ScrollContainer
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/scroll_container.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 461281a4ed..a840e3fec1 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -382,7 +382,10 @@ void ScrollContainer::update_scrollbars() {
Size2 min = child_max_size;
- if (!scroll_v || min.height <= size.height - hmin.height) {
+ bool hide_scroll_v = !scroll_v || min.height <= size.height - hmin.height;
+ bool hide_scroll_h = !scroll_h || min.width <= size.width - vmin.width;
+
+ if (hide_scroll_v) {
v_scroll->hide();
v_scroll->set_max(0);
@@ -391,11 +394,16 @@ void ScrollContainer::update_scrollbars() {
v_scroll->show();
v_scroll->set_max(min.height);
- v_scroll->set_page(size.height - hmin.height);
+ if (hide_scroll_h) {
+ v_scroll->set_page(size.height);
+ } else {
+ v_scroll->set_page(size.height - hmin.height);
+ }
+
scroll.y = v_scroll->get_value();
}
- if (!scroll_h || min.width <= size.width - vmin.width) {
+ if (hide_scroll_h) {
h_scroll->hide();
h_scroll->set_max(0);
@@ -404,7 +412,12 @@ void ScrollContainer::update_scrollbars() {
h_scroll->show();
h_scroll->set_max(min.width);
- h_scroll->set_page(size.width - vmin.width);
+ if (hide_scroll_v) {
+ h_scroll->set_page(size.width);
+ } else {
+ h_scroll->set_page(size.width - vmin.width);
+ }
+
scroll.x = h_scroll->get_value();
}
}