summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-20 11:55:10 +0000
committerrubidium <rubidium@openttd.org>2010-08-20 11:55:10 +0000
commit3e3cd472226bdfe3dd73cb9707fcc2a1b5aee576 (patch)
treeb5fa2f6ad7be9bc49e4e9a0b366c6d253c098d04 /src
parent1231dc7b57f7c81a9db896eded5a96a7f12f4188 (diff)
downloadopenttd-3e3cd472226bdfe3dd73cb9707fcc2a1b5aee576.tar.xz
(svn r20577) -Fix [FS#4043]: scroll button flickering when pressed
Diffstat (limited to 'src')
-rw-r--r--src/widget.cpp8
-rw-r--r--src/window.cpp26
2 files changed, 16 insertions, 18 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 25abdf1c5..008a5b92a 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -85,8 +85,8 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
if (pos <= mi + 9) {
/* Pressing the upper button? */
SetBit(sb->disp_flags, NDB_SCROLLBAR_UP);
- if (_scroller_click_timeout == 0) {
- _scroller_click_timeout = 6;
+ if (_scroller_click_timeout <= 1) {
+ _scroller_click_timeout = 3;
sb->UpdatePosition(rtl ? 1 : -1);
}
_left_button_clicked = false;
@@ -94,8 +94,8 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in
/* Pressing the lower button? */
SetBit(sb->disp_flags, NDB_SCROLLBAR_DOWN);
- if (_scroller_click_timeout == 0) {
- _scroller_click_timeout = 6;
+ if (_scroller_click_timeout <= 1) {
+ _scroller_click_timeout = 3;
sb->UpdatePosition(rtl ? -1 : 1);
}
_left_button_clicked = false;
diff --git a/src/window.cpp b/src/window.cpp
index 09accd16e..4e2e42091 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -54,7 +54,7 @@ Point _cursorpos_drag_start;
int _scrollbar_start_pos;
int _scrollbar_size;
-byte _scroller_click_timeout;
+byte _scroller_click_timeout = 0;
bool _scrolling_viewport; ///< A viewport is being scrolled with the mouse.
bool _mouse_hovering; ///< The mouse is hovering over the same point.
@@ -1373,14 +1373,16 @@ static void DecreaseWindowCounters()
{
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
- /* Unclick scrollbar buttons if they are pressed. */
- for (uint i = 0; i < w->nested_array_size; i++) {
- NWidgetBase *nwid = w->nested_array[i];
- if (nwid != NULL && (nwid->type == NWID_HSCROLLBAR || nwid->type == NWID_VSCROLLBAR)) {
- NWidgetScrollbar *sb = static_cast<NWidgetScrollbar*>(nwid);
- if (sb->disp_flags & (ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN)) {
- sb->disp_flags &= ~(ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN);
- sb->SetDirty(w);
+ if (_scroller_click_timeout == 0) {
+ /* Unclick scrollbar buttons if they are pressed. */
+ for (uint i = 0; i < w->nested_array_size; i++) {
+ NWidgetBase *nwid = w->nested_array[i];
+ if (nwid != NULL && (nwid->type == NWID_HSCROLLBAR || nwid->type == NWID_VSCROLLBAR)) {
+ NWidgetScrollbar *sb = static_cast<NWidgetScrollbar*>(nwid);
+ if (sb->disp_flags & (ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN)) {
+ sb->disp_flags &= ~(ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN);
+ sb->SetDirty(w);
+ }
}
}
}
@@ -2500,11 +2502,7 @@ void InvalidateWindowClassesData(WindowClass cls, int data)
*/
void CallWindowTickEvent()
{
- if (_scroller_click_timeout > 3) {
- _scroller_click_timeout -= 3;
- } else {
- _scroller_click_timeout = 0;
- }
+ if (_scroller_click_timeout != 0) _scroller_click_timeout--;
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {