From 7991048105dab27ae25aeda5c2fe5b59a6d0c27b Mon Sep 17 00:00:00 2001 From: pelya Date: Sun, 20 Jul 2014 00:35:07 +0300 Subject: [PATCH] Slower scrolling for dropdown lists and scrollbars --- src/widget.cpp | 4 ++-- src/widgets/dropdown.cpp | 7 +++++-- src/window.cpp | 2 +- src/window_gui.h | 3 +++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/widget.cpp b/src/widget.cpp index 7a939abb06..5f2c6233ec 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -103,7 +103,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in /* Pressing the upper button? */ SetBit(sb->disp_flags, NDB_SCROLLBAR_UP); if (_scroller_click_timeout <= 1) { - _scroller_click_timeout = 3; + _scroller_click_timeout = SCROLLER_CLICK_DELAY; sb->UpdatePosition(rtl ? 1 : -1); } w->scrolling_scrollbar = sb->index; @@ -112,7 +112,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in SetBit(sb->disp_flags, NDB_SCROLLBAR_DOWN); if (_scroller_click_timeout <= 1) { - _scroller_click_timeout = 3; + _scroller_click_timeout = SCROLLER_CLICK_DELAY; sb->UpdatePosition(rtl ? -1 : 1); } w->scrolling_scrollbar = sb->index; diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index a5b7be1ea1..a05966a106 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -256,8 +256,11 @@ struct DropdownWindow : Window { if (this->scrolling != 0) { int pos = this->vscroll->GetPosition(); - this->vscroll->UpdatePosition(this->scrolling); - this->scrolling = 0; + if (_scroller_click_timeout <= 1) { + _scroller_click_timeout = SCROLLER_CLICK_DELAY; + this->vscroll->UpdatePosition(this->scrolling); + this->scrolling = 0; + } if (pos != this->vscroll->GetPosition()) { this->SetDirty(); diff --git a/src/window.cpp b/src/window.cpp index c4877e9163..42c9853ec3 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2395,7 +2395,7 @@ static EventState HandleScrollbarScrolling() if (sb->disp_flags & ND_SCROLLBAR_BTN) { if (_scroller_click_timeout == 1) { - _scroller_click_timeout = 3; + _scroller_click_timeout = SCROLLER_CLICK_DELAY; sb->UpdatePosition(rtl == HasBit(sb->disp_flags, NDB_SCROLLBAR_UP) ? 1 : -1); w->SetDirty(); } diff --git a/src/window_gui.h b/src/window_gui.h index bf8500f0f3..e03912b12d 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -885,6 +885,9 @@ extern Point _cursorpos_drag_start; extern int _scrollbar_start_pos; extern int _scrollbar_size; extern byte _scroller_click_timeout; +enum { + SCROLLER_CLICK_DELAY = 6 ///< Delay in video frames between scrollbar doing scroll, we don't want to get to the bottom of the list in an instant +}; extern bool _scrolling_viewport; extern bool _mouse_hovering;