summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-08-12 09:14:34 +0000
committerfrosch <frosch@openttd.org>2010-08-12 09:14:34 +0000
commitb37be47f162a614ddfb0a777331d7c402930aec5 (patch)
treeba7909ff163a1b023bc4f69ba3c424684813d49b /src/window.cpp
parent6e9c9c28d950a822beb0fb4e76d5ba40a247085c (diff)
downloadopenttd-b37be47f162a614ddfb0a777331d7c402930aec5.tar.xz
(svn r20460) -Codechange: Remove WF_SCROLL window flags and store the state directly in the scrollbar widget instead.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 09134b270..5539dae04 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1380,9 +1380,15 @@ static void DecreaseWindowCounters()
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
/* Unclick scrollbar buttons if they are pressed. */
- if (w->flags4 & (WF_SCROLL_DOWN | WF_SCROLL_UP)) {
- w->flags4 &= ~(WF_SCROLL_DOWN | WF_SCROLL_UP);
- w->SetDirty();
+ for (uint i = 0; i < w->nested_array_size; i++) {
+ NWidgetBase *nwid = w->nested_array[i];
+ if (nwid != NULL && (nwid->type == WWT_HSCROLLBAR || nwid->type == WWT_SCROLLBAR || nwid->type == WWT_SCROLL2BAR)) {
+ 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);
+ }
+ }
}
w->OnMouseLoop();
}
@@ -1831,14 +1837,12 @@ static EventState HandleScrollbarScrolling()
}
int i;
- Scrollbar *sb = w->GetScrollbar(w->scrolling_scrollbar);
+ NWidgetScrollbar *sb = w->GetWidget<NWidgetScrollbar>(w->scrolling_scrollbar);
bool rtl = false;
- if (w->flags4 & WF_HSCROLL) {
+ if (sb->type == WWT_HSCROLLBAR) {
i = _cursor.pos.x - _cursorpos_drag_start.x;
rtl = _dynlang.text_dir == TD_RTL;
- } else if (w->flags4 & WF_SCROLL2) {
- i = _cursor.pos.y - _cursorpos_drag_start.y;
} else {
i = _cursor.pos.y - _cursorpos_drag_start.y;
}