diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-05-07 12:36:08 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2021-05-08 09:52:54 +0100 |
commit | 52b16237ad863ce30746ac7efc46a9ece7e3bdd2 (patch) | |
tree | 4cd5c83fb53da9c89219c7d0eba636d04b5d3634 /src/widget.cpp | |
parent | 8321ef0061fa898cfb215e57c67aebd7411475e1 (diff) | |
download | openttd-52b16237ad863ce30746ac7efc46a9ece7e3bdd2.tar.xz |
Codechange: Don't update window contents if scrollbar position has not moved.
Diffstat (limited to 'src/widget.cpp')
-rw-r--r-- | src/widget.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/widget.cpp b/src/widget.cpp index 5c1c0ae8f..93a5afe95 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -108,6 +108,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in int pos; int button_size; bool rtl = false; + bool changed = false; if (sb->type == NWID_HSCROLLBAR) { pos = x; @@ -122,7 +123,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in SetBit(sb->disp_flags, NDB_SCROLLBAR_UP); if (_scroller_click_timeout <= 1) { _scroller_click_timeout = 3; - sb->UpdatePosition(rtl ? 1 : -1); + changed = sb->UpdatePosition(rtl ? 1 : -1); } w->mouse_capture_widget = sb->index; } else if (pos >= ma - button_size) { @@ -131,16 +132,16 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in if (_scroller_click_timeout <= 1) { _scroller_click_timeout = 3; - sb->UpdatePosition(rtl ? -1 : 1); + changed = sb->UpdatePosition(rtl ? -1 : 1); } w->mouse_capture_widget = sb->index; } else { Point pt = HandleScrollbarHittest(sb, mi, ma, sb->type == NWID_HSCROLLBAR); if (pos < pt.x) { - sb->UpdatePosition(rtl ? 1 : -1, Scrollbar::SS_BIG); + changed = sb->UpdatePosition(rtl ? 1 : -1, Scrollbar::SS_BIG); } else if (pos > pt.y) { - sb->UpdatePosition(rtl ? -1 : 1, Scrollbar::SS_BIG); + changed = sb->UpdatePosition(rtl ? -1 : 1, Scrollbar::SS_BIG); } else { _scrollbar_start_pos = pt.x - mi - button_size; _scrollbar_size = ma - mi - button_size * 2; @@ -149,7 +150,13 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *sb, int x, in } } - w->SetDirty(); + if (changed) { + /* Position changed so refresh the window */ + w->SetDirty(); + } else { + /* No change so only refresh this scrollbar */ + sb->SetDirty(w); + } } /** |