summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorPaweł <pkowal1982@gmail.com>2022-10-26 19:43:50 +0200
committerYuri Sizov <yuris@humnom.net>2023-03-27 16:28:29 +0200
commitca0ba83f0307cad3e8119945e6e2de9570190803 (patch)
treeaee4546c51972175538c5b20e6bd1c9553cebb2e /scene/gui
parent5262fe21de8ec04a6b25b1a73c2789a7bdc3dc03 (diff)
Fix scrolling behaviour with low page value
(cherry picked from commit 1608bea18809dcb4e744ee936f8de8f5660adfbe)
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/scroll_bar.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index b8faf22a59..fcf9302953 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -55,12 +55,14 @@ void ScrollBar::gui_input(const Ref<InputEvent> &p_event) {
accept_event();
if (b->get_button_index() == MouseButton::WHEEL_DOWN && b->is_pressed()) {
- set_value(get_value() + get_page() / 4.0);
+ double change = get_page() != 0.0 ? get_page() / 4.0 : (get_max() - get_min()) / 16.0;
+ set_value(get_value() + MAX(change, get_step()));
accept_event();
}
if (b->get_button_index() == MouseButton::WHEEL_UP && b->is_pressed()) {
- set_value(get_value() - get_page() / 4.0);
+ double change = get_page() != 0.0 ? get_page() / 4.0 : (get_max() - get_min()) / 16.0;
+ set_value(get_value() - MAX(change, get_step()));
accept_event();
}
@@ -99,7 +101,8 @@ void ScrollBar::gui_input(const Ref<InputEvent> &p_event) {
if (scrolling) {
target_scroll = CLAMP(target_scroll - get_page(), get_min(), get_max() - get_page());
} else {
- target_scroll = CLAMP(get_value() - get_page(), get_min(), get_max() - get_page());
+ double change = get_page() != 0.0 ? get_page() : (get_max() - get_min()) / 16.0;
+ target_scroll = CLAMP(get_value() - change, get_min(), get_max() - get_page());
}
if (smooth_scroll_enabled) {
@@ -122,7 +125,8 @@ void ScrollBar::gui_input(const Ref<InputEvent> &p_event) {
if (scrolling) {
target_scroll = CLAMP(target_scroll + get_page(), get_min(), get_max() - get_page());
} else {
- target_scroll = CLAMP(get_value() + get_page(), get_min(), get_max() - get_page());
+ double change = get_page() != 0.0 ? get_page() : (get_max() - get_min()) / 16.0;
+ target_scroll = CLAMP(get_value() + change, get_min(), get_max() - get_page());
}
if (smooth_scroll_enabled) {