Fix scrolling behaviour with low page value
(cherry picked from commit 1608bea188
)
This commit is contained in:
parent
d6221bd614
commit
268f83e07f
1 changed files with 8 additions and 4 deletions
|
@ -54,12 +54,14 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
|
||||||
accept_event();
|
accept_event();
|
||||||
|
|
||||||
if (b->get_button_index() == BUTTON_WHEEL_DOWN && b->is_pressed()) {
|
if (b->get_button_index() == BUTTON_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();
|
accept_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b->get_button_index() == BUTTON_WHEEL_UP && b->is_pressed()) {
|
if (b->get_button_index() == BUTTON_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();
|
accept_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +100,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
|
||||||
if (scrolling) {
|
if (scrolling) {
|
||||||
target_scroll = CLAMP(target_scroll - get_page(), get_min(), get_max() - get_page());
|
target_scroll = CLAMP(target_scroll - get_page(), get_min(), get_max() - get_page());
|
||||||
} else {
|
} 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) {
|
if (smooth_scroll_enabled) {
|
||||||
|
@ -121,7 +124,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
|
||||||
if (scrolling) {
|
if (scrolling) {
|
||||||
target_scroll = CLAMP(target_scroll + get_page(), get_min(), get_max() - get_page());
|
target_scroll = CLAMP(target_scroll + get_page(), get_min(), get_max() - get_page());
|
||||||
} else {
|
} 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) {
|
if (smooth_scroll_enabled) {
|
||||||
|
|
Loading…
Reference in a new issue