summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-15 19:54:23 +0000
committertruebrain <truebrain@openttd.org>2011-12-15 19:54:23 +0000
commitdf0afdf0dca6b3d4f621248ada2aed73d7481c66 (patch)
treefe5b1ab9e0e996c53e17d2eb82442b1829e89cbc /src
parent2ecbe895093f91bfdecbd8ab29d0641c2fd9a0f3 (diff)
downloadopenttd-df0afdf0dca6b3d4f621248ada2aed73d7481c66.tar.xz
(svn r23525) -Codechange: make Window::flags4 WindowFlags instead of uint16, with only values known in WindowFlags (and move out 2 timers to their own variable)
-Codechange: rename Window::flags4 to Window::flags -Codechange: move some non-inline functions from .hpp to .cpp
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap_gui.cpp2
-rw-r--r--src/cheat_gui.cpp2
-rw-r--r--src/genworld_gui.cpp8
-rw-r--r--src/highscore_gui.cpp2
-rw-r--r--src/industry_gui.cpp4
-rw-r--r--src/main_gui.cpp2
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/network/network_gui.cpp4
-rw-r--r--src/news_gui.cpp2
-rw-r--r--src/settings_gui.cpp6
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/statusbar_gui.cpp2
-rw-r--r--src/toolbar_gui.cpp8
-rw-r--r--src/town_gui.cpp2
-rw-r--r--src/tree_gui.cpp2
-rw-r--r--src/waypoint_gui.cpp2
-rw-r--r--src/widget.cpp6
-rw-r--r--src/widgets/dropdown.cpp2
-rw-r--r--src/window.cpp85
-rw-r--r--src/window_gui.h94
20 files changed, 132 insertions, 107 deletions
diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp
index 6c3b98144..646439db5 100644
--- a/src/bootstrap_gui.cpp
+++ b/src/bootstrap_gui.cpp
@@ -50,7 +50,7 @@ public:
BootstrapBackground() : Window()
{
this->InitNested(&_background_desc, 0);
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
ResizeWindow(this, _screen.width, _screen.height);
}
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index b88a9355c..73d19a131 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -360,7 +360,7 @@ struct CheatWindow : Window {
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
- this->flags4 |= WF_TIMEOUT_BEGIN;
+ this->SetTimeout();
this->SetDirty();
}
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 455d1ae6f..645dc0b1c 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -639,7 +639,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case GLAND_START_DATE_DOWN:
case GLAND_START_DATE_UP: // Year buttons
/* Don't allow too fast scrolling */
- if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
+ if ((this->flags & WF_TIMEOUT) && this->timeout_timer <= 1) {
this->HandleButtonClick(widget);
_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
@@ -657,7 +657,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case GLAND_SNOW_LEVEL_DOWN:
case GLAND_SNOW_LEVEL_UP: // Snow line buttons
/* Don't allow too fast scrolling */
- if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
+ if ((this->flags & WF_TIMEOUT) && this->timeout_timer <= 1) {
this->HandleButtonClick(widget);
_settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT);
@@ -1049,7 +1049,7 @@ struct CreateScenarioWindow : public Window
case CSCEN_START_DATE_DOWN:
case CSCEN_START_DATE_UP: // Year buttons
/* Don't allow too fast scrolling */
- if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
+ if ((this->flags & WF_TIMEOUT) && this->timeout_timer <= 1) {
this->HandleButtonClick(widget);
this->SetDirty();
@@ -1067,7 +1067,7 @@ struct CreateScenarioWindow : public Window
case CSCEN_FLAT_LAND_HEIGHT_DOWN:
case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
/* Don't allow too fast scrolling */
- if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
+ if ((this->flags & WF_TIMEOUT) && this->timeout_timer <= 1) {
this->HandleButtonClick(widget);
this->SetDirty();
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp
index 7c87143d2..0cd355c12 100644
--- a/src/highscore_gui.cpp
+++ b/src/highscore_gui.cpp
@@ -34,7 +34,7 @@ struct EndGameHighScoreBaseWindow : Window {
EndGameHighScoreBaseWindow(const WindowDesc *desc) : Window()
{
this->InitNested(desc);
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
ResizeWindow(this, _screen.width - this->width, _screen.height - this->height);
}
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 7a5a58863..7ce40ea42 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -673,7 +673,7 @@ class IndustryViewWindow : public Window
public:
IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
{
- this->flags4 |= WF_DISABLE_VP_SCROLL;
+ this->flags |= WF_DISABLE_VP_SCROLL;
this->editbox_line = IL_NONE;
this->clicked_line = IL_NONE;
this->clicked_button = 0;
@@ -886,7 +886,7 @@ public:
UpdateIndustryProduction(i);
this->SetDirty();
- this->flags4 |= WF_TIMEOUT_BEGIN;
+ this->SetTimeout();
this->clicked_line = line;
this->clicked_button = button;
} else if (IsInsideMM(pt.x, left + 30, right)) {
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 1d57f51aa..a7de4069d 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -244,7 +244,7 @@ struct MainWindow : Window
MainWindow() : Window()
{
this->InitNested(&_main_window_desc, 0);
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
ResizeWindow(this, _screen.width, _screen.height);
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(MW_VIEWPORT);
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 3ea9dff0f..7c06261a7 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -643,7 +643,7 @@ struct TooltipsWindow : public Window
this->InitNested(&_tool_tips_desc);
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK); // remove white-border from tooltip
+ CLRBITS(this->flags, WF_WHITE_BORDER);
}
virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index ed6ef2178..f860d3a79 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1156,7 +1156,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU: // Click on up/down button for number of companies
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
/* Don't allow too fast scrolling */
- if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
+ if ((this->flags & WF_TIMEOUT) && this->timeout_timer <= 1) {
this->HandleButtonClick(widget);
this->SetDirty();
switch (widget) {
@@ -1822,7 +1822,7 @@ struct NetworkClientListPopupWindow : Window {
}
this->InitNested(desc, client_id);
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
}
virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 07a82c82d..3820fe125 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -293,7 +293,7 @@ struct NewsWindow : Window {
this->chat_height = (w != NULL) ? w->height : 0;
this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height;
- this->flags4 |= WF_DISABLE_VP_SCROLL;
+ this->flags |= WF_DISABLE_VP_SCROLL;
this->CreateNestedTree(desc);
switch (this->ni->subtype) {
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index e0fca2afc..47bb9a4d3 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1708,7 +1708,7 @@ struct GameSettingsWindow : Window {
if (step == 0) step = 1;
/* don't allow too fast scrolling */
- if ((this->flags4 & WF_TIMEOUT_MASK) > WF_TIMEOUT_TRIGGER) {
+ if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
_left_button_clicked = false;
return;
}
@@ -1735,7 +1735,7 @@ struct GameSettingsWindow : Window {
}
this->clicked_entry = pe;
this->clicked_entry->SetButtons((x >= 10) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
- this->flags4 |= WF_TIMEOUT_BEGIN;
+ this->SetTimeout();
_left_button_clicked = false;
}
break;
@@ -2016,7 +2016,7 @@ struct CustomCurrencyWindow : Window {
ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, this, afilter, QSF_NONE);
}
- this->flags4 |= WF_TIMEOUT_BEGIN;
+ this->SetTimeout();
this->SetDirty();
}
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index dda06ee7a..a0c100342 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -596,7 +596,7 @@ public:
case SLW_SORTBY: // flip sorting method asc/desc
this->stations.ToggleSortOrder();
- this->flags4 |= WF_TIMEOUT_BEGIN;
+ this->SetTimeout();
this->LowerWidget(SLW_SORTBY);
this->SetDirty();
break;
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index 0dea9dd8b..ed9822eee 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -93,7 +93,7 @@ struct StatusBarWindow : Window {
this->reminder_timeout = REMINDER_STOP;
this->InitNested(desc);
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
PositionStatusbar(this);
}
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 60c239525..d349e4c3a 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1094,7 +1094,7 @@ static CallBackFunction ToolbarScenDatePanel(Window *w)
static CallBackFunction ToolbarScenDateBackward(Window *w)
{
/* don't allow too fast scrolling */
- if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
+ if ((w->flags & WF_TIMEOUT) && w->timeout_timer <= 1) {
w->HandleButtonClick(TBSE_DATEBACKWARD);
w->SetDirty();
@@ -1108,7 +1108,7 @@ static CallBackFunction ToolbarScenDateBackward(Window *w)
static CallBackFunction ToolbarScenDateForward(Window *w)
{
/* don't allow too fast scrolling */
- if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
+ if ((w->flags & WF_TIMEOUT) && w->timeout_timer <= 1) {
w->HandleButtonClick(TBSE_DATEFORWARD);
w->SetDirty();
@@ -1566,7 +1566,7 @@ struct MainToolbarWindow : Window {
this->InitNested(desc, 0);
this->last_started_action = CBF_NONE;
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
this->SetWidgetDisabledState(TBN_PAUSE, _networking && !_network_server); // if not server, disable pause button
this->SetWidgetDisabledState(TBN_FASTFORWARD, _networking); // if networking, disable fast-forward button
PositionMainToolbar(this);
@@ -1868,7 +1868,7 @@ struct ScenarioEditorToolbarWindow : Window {
this->InitNested(desc, 0);
this->last_started_action = CBF_NONE;
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
PositionMainToolbar(this);
DoZoomInOutWindow(ZOOM_NONE, this);
}
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index e6a95fdfa..8bdc5a79b 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -332,7 +332,7 @@ public:
this->FinishInitNested(desc, window_number);
- this->flags4 |= WF_DISABLE_VP_SCROLL;
+ this->flags|= WF_DISABLE_VP_SCROLL;
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(TVW_VIEWPORT);
nvp->InitializeViewport(this, this->town->xy, ZOOM_LVL_NEWS);
diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp
index e91675ae5..76f254dda 100644
--- a/src/tree_gui.cpp
+++ b/src/tree_gui.cpp
@@ -151,7 +151,7 @@ public:
case BTW_MANY_RANDOM: // place trees randomly over the landscape
this->LowerWidget(BTW_MANY_RANDOM);
- this->flags4 |= WF_TIMEOUT_BEGIN;
+ this->SetTimeout();
SndPlayFx(SND_15_BEEP);
PlaceTreesRandomly();
MarkWholeScreenDirty();
diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp
index e3bb01ae8..673ddfd3b 100644
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -73,7 +73,7 @@ public:
this->FinishInitNested(desc, window_number);
if (this->wp->owner != OWNER_NONE) this->owner = this->wp->owner;
- this->flags4 |= WF_DISABLE_VP_SCROLL;
+ this->flags |= WF_DISABLE_VP_SCROLL;
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WAYPVW_VIEWPORT);
nvp->InitializeViewport(this, this->GetCenterTile(), ZOOM_LVL_VIEWPORT);
diff --git a/src/widget.cpp b/src/widget.cpp
index ba8c7ebf3..ad8b18064 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -567,7 +567,7 @@ void Window::DrawWidgets() const
{
this->nested_root->Draw(this);
- if (this->flags4 & WF_WHITE_BORDER_MASK) {
+ if (this->flags & WF_WHITE_BORDER) {
DrawFrameRect(0, 0, this->width - 1, this->height - 1, COLOUR_WHITE, FR_BORDERONLY);
}
}
@@ -2341,12 +2341,12 @@ void NWidgetLeaf::Draw(const Window *w)
case WWT_STICKYBOX:
assert(this->widget_data == 0);
- DrawStickyBox(r, this->colour, !!(w->flags4 & WF_STICKY));
+ DrawStickyBox(r, this->colour, !!(w->flags & WF_STICKY));
break;
case WWT_RESIZEBOX:
assert(this->widget_data == 0);
- DrawResizeBox(r, this->colour, this->pos_x < (uint)(w->width / 2), !!(w->flags4 & WF_SIZING));
+ DrawResizeBox(r, this->colour, this->pos_x < (uint)(w->width / 2), !!(w->flags & WF_SIZING));
break;
case WWT_CLOSEBOX:
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index d3dbd3bd8..b57ea0c35 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -148,7 +148,7 @@ struct DropdownWindow : Window {
this->GetWidget<NWidgetStacked>(DDM_SHOW_SCROLL)->SetDisplayedPlane(scroll ? 0 : SZSP_NONE);
this->FinishInitNested(&_dropdown_desc, 0);
- CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
+ CLRBITS(this->flags, WF_WHITE_BORDER);
/* Total length of list */
int list_height = 0;
diff --git a/src/window.cpp b/src/window.cpp
index abef420b6..a00bb0649 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -264,7 +264,7 @@ void Window::SetWidgetDirty(byte widget_index) const
void Window::HandleButtonClick(byte widget)
{
this->LowerWidget(widget);
- this->flags4 |= WF_TIMEOUT_BEGIN;
+ this->SetTimeout();
this->SetWidgetDirty(widget);
}
@@ -373,7 +373,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
return;
case WWT_STICKYBOX:
- w->flags4 ^= WF_STICKY;
+ w->flags ^= WF_STICKY;
nw->SetDirty(w);
return;
@@ -753,7 +753,7 @@ void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
{
Window *w = FindWindowById(cls, number);
if (force || w == NULL ||
- (w->flags4 & WF_STICKY) == 0) {
+ (w->flags & WF_STICKY) == 0) {
delete w;
}
}
@@ -852,7 +852,7 @@ Window *BringWindowToFrontById(WindowClass cls, WindowNumber number)
if (w != NULL) {
if (w->IsShaded()) w->SetShaded(false); // Restore original window size if it was shaded.
- w->flags4 |= WF_WHITE_BORDER_MASK;
+ w->SetWhiteBorder();
BringWindowToFront(w);
w->SetDirty();
}
@@ -1037,8 +1037,8 @@ void Window::InitializeData(const WindowDesc *desc, WindowNumber window_number)
{
/* Set up window properties; some of them are needed to set up smallest size below */
this->window_class = desc->cls;
- this->flags4 |= WF_WHITE_BORDER_MASK; // just opened windows have a white border
- if (desc->default_pos == WDP_CENTER) this->flags4 |= WF_CENTERED;
+ this->SetWhiteBorder();
+ if (desc->default_pos == WDP_CENTER) this->flags |= WF_CENTERED;
this->owner = INVALID_OWNER;
this->nested_focus = NULL;
this->window_number = window_number;
@@ -1506,7 +1506,9 @@ static void DecreaseWindowCounters()
}
FOR_ALL_WINDOWS_FROM_FRONT(w) {
- if ((w->flags4 & WF_TIMEOUT_MASK) && !(--w->flags4 & WF_TIMEOUT_MASK)) {
+ if ((w->flags & WF_TIMEOUT) && --w->timeout_timer == 0) {
+ CLRBITS(w->flags, WF_TIMEOUT);
+
w->OnTimeout();
if (w->desc_flags & WDF_UNCLICK_BUTTONS) w->RaiseButtons(true);
}
@@ -1742,10 +1744,10 @@ static EventState HandleWindowDragging()
/* Otherwise find the window... */
Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) {
- if (w->flags4 & WF_DRAGGING) {
+ if (w->flags & WF_DRAGGING) {
/* Stop the dragging if the left mouse button was released */
if (!_left_button_down) {
- w->flags4 &= ~WF_DRAGGING;
+ w->flags &= ~WF_DRAGGING;
break;
}
@@ -1836,10 +1838,10 @@ static EventState HandleWindowDragging()
w->SetDirty();
return ES_HANDLED;
- } else if (w->flags4 & WF_SIZING) {
+ } else if (w->flags & WF_SIZING) {
/* Stop the sizing if the left mouse button was released */
if (!_left_button_down) {
- w->flags4 &= ~WF_SIZING;
+ w->flags &= ~WF_SIZING;
w->SetDirty();
break;
}
@@ -1848,7 +1850,7 @@ static EventState HandleWindowDragging()
* If resizing the left edge of the window, moving to the left makes the window bigger not smaller.
*/
int x, y = _cursor.pos.y - _drag_delta.y;
- if (w->flags4 & WF_SIZING_LEFT) {
+ if (w->flags & WF_SIZING_LEFT) {
x = _drag_delta.x - _cursor.pos.x;
} else {
x = _cursor.pos.x - _drag_delta.x;
@@ -1882,7 +1884,7 @@ static EventState HandleWindowDragging()
/* Now find the new cursor pos.. this is NOT _cursor, because we move in steps. */
_drag_delta.y += y;
- if ((w->flags4 & WF_SIZING_LEFT) && x != 0) {
+ if ((w->flags & WF_SIZING_LEFT) && x != 0) {
_drag_delta.x -= x; // x > 0 -> window gets longer -> left-edge moves to left -> subtract x to get new position.
w->SetDirty();
w->left -= x; // If dragging left edge, move left window edge in opposite direction by the same amount.
@@ -1907,8 +1909,8 @@ static EventState HandleWindowDragging()
*/
static void StartWindowDrag(Window *w)
{
- w->flags4 |= WF_DRAGGING;
- w->flags4 &= ~WF_CENTERED;
+ w->flags |= WF_DRAGGING;
+ w->flags &= ~WF_CENTERED;
_dragging_window = true;
_drag_delta.x = w->left - _cursor.pos.x;
@@ -1925,8 +1927,8 @@ static void StartWindowDrag(Window *w)
*/
static void StartWindowSizing(Window *w, bool to_left)
{
- w->flags4 |= to_left ? WF_SIZING_LEFT : WF_SIZING_RIGHT;
- w->flags4 &= ~WF_CENTERED;
+ w->flags |= to_left ? WF_SIZING_LEFT : WF_SIZING_RIGHT;
+ w->flags &= ~WF_CENTERED;
_dragging_window = true;
_drag_delta.x = _cursor.pos.x;
@@ -2073,7 +2075,7 @@ static bool MaybeBringWindowToFront(Window *w)
FOR_ALL_WINDOWS_FROM_BACK_FROM(u, w->z_front) {
/* A modal child will prevent the activation of the parent window */
if (u->parent == w && (u->desc_flags & WDF_MODAL)) {
- u->flags4 |= WF_WHITE_BORDER_MASK;
+ u->SetWhiteBorder();
u->SetDirty();
return false;
}
@@ -2178,7 +2180,7 @@ static void HandleAutoscroll()
int x = _cursor.pos.x;
int y = _cursor.pos.y;
Window *w = FindWindowFromPt(x, y);
- if (w == NULL || w->flags4 & WF_DISABLE_VP_SCROLL) return;
+ if (w == NULL || w->flags & WF_DISABLE_VP_SCROLL) return;
ViewPort *vp = IsPtInWindowViewport(w, x, y);
if (vp != NULL) {
x -= vp->left;
@@ -2311,7 +2313,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
case MC_LEFT:
DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
if (!HandleViewportClicked(vp, x, y) &&
- !(w->flags4 & WF_DISABLE_VP_SCROLL) &&
+ !(w->flags & WF_DISABLE_VP_SCROLL) &&
_settings_client.gui.left_mouse_btn_scrolling) {
_scrolling_viewport = true;
_cursor.fix_at = false;
@@ -2319,7 +2321,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
break;
case MC_RIGHT:
- if (!(w->flags4 & WF_DISABLE_VP_SCROLL)) {
+ if (!(w->flags & WF_DISABLE_VP_SCROLL)) {
_scrolling_viewport = true;
_cursor.fix_at = true;
@@ -2445,7 +2447,7 @@ static void CheckSoftLimit()
uint deletable_count = 0;
Window *w, *last_deletable = NULL;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
- if (w->window_class == WC_MAIN_WINDOW || IsVitalWindow(w) || (w->flags4 & WF_STICKY)) continue;
+ if (w->window_class == WC_MAIN_WINDOW || IsVitalWindow(w) || (w->flags & WF_STICKY)) continue;
last_deletable = w;
deletable_count++;
@@ -2520,10 +2522,9 @@ void UpdateWindows()
we4_timer = t;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
- if (w->flags4 & WF_WHITE_BORDER_MASK) {
- w->flags4 -= WF_WHITE_BORDER_ONE;
-
- if (!(w->flags4 & WF_WHITE_BORDER_MASK)) w->SetDirty();
+ if ((w->flags & WF_WHITE_BORDER) && --w->white_border_timer == 0) {
+ CLRBITS(w->flags, WF_WHITE_BORDER);
+ w->SetDirty();
}
}
@@ -2580,6 +2581,32 @@ void SetWindowClassesDirty(WindowClass cls)
}
/**
+ * Mark this window's data as invalid (in need of re-computing)
+ * @param data The data to invalidate with
+ * @param gui_scope Whether the funtion is called from GUI scope.
+ */
+void Window::InvalidateData(int data, bool gui_scope)
+{
+ this->SetDirty();
+ if (!gui_scope) {
+ /* Schedule GUI-scope invalidation for next redraw. */
+ *this->scheduled_invalidation_data.Append() = data;
+ }
+ this->OnInvalidateData(data, gui_scope);
+}
+
+/**
+ * Process all scheduled invalidations.
+ */
+void Window::ProcessScheduledInvalidations()
+{
+ for (int *data = this->scheduled_invalidation_data.Begin(); this->window_class != WC_INVALID && data != this->scheduled_invalidation_data.End(); data++) {
+ this->OnInvalidateData(*data, true);
+ }
+ this->scheduled_invalidation_data.Clear();
+}
+
+/**
* Mark window data of the window of a given class and specific window number as invalid (in need of re-computing)
*
* Note that by default the invalidation is not considered to be called from GUI scope.
@@ -2665,7 +2692,7 @@ restart_search:
w->window_class != WC_MAIN_TOOLBAR &&
w->window_class != WC_STATUS_BAR &&
w->window_class != WC_TOOLTIPS &&
- (w->flags4 & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
+ (w->flags & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
delete w;
goto restart_search;
@@ -2692,7 +2719,7 @@ restart_search:
* as deleting this window could cascade in deleting (many) others
* anywhere in the z-array */
FOR_ALL_WINDOWS_FROM_BACK(w) {
- if (w->flags4 & WF_STICKY) {
+ if (w->flags & WF_STICKY) {
delete w;
goto restart_search;
}
@@ -2893,7 +2920,7 @@ void RelocateAllWindows(int neww, int newh)
continue;
default: {
- if (w->flags4 & WF_CENTERED) {
+ if (w->flags & WF_CENTERED) {
top = (newh - w->height) >> 1;
left = (neww - w->width) >> 1;
break;
diff --git a/src/window_gui.h b/src/window_gui.h
index 461d6652b..f60b39d01 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -206,6 +206,27 @@ enum SortButtonState {
};
/**
+ * Window flags.
+ */
+enum WindowFlags {
+ WF_TIMEOUT = 1 << 0, ///< Window timeout counter.
+
+ WF_DRAGGING = 1 << 3, ///< Window is being dragged.
+ WF_SIZING_RIGHT = 1 << 4, ///< Window is being resized towards the right.
+ WF_SIZING_LEFT = 1 << 5, ///< Window is being resized towards the left.
+ WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT, ///< Window is being resized.
+ WF_STICKY = 1 << 6, ///< Window is made sticky by user
+ WF_DISABLE_VP_SCROLL = 1 << 7, ///< Window does not do autoscroll, @see HandleAutoscroll().
+ WF_WHITE_BORDER = 1 << 8, ///< Window white border counter bit mask.
+
+ WF_CENTERED = 1 << 10, ///< Window is centered and shall stay centered after ReInit.
+};
+DECLARE_ENUM_AS_BIT_SET(WindowFlags)
+
+static const int TIMEOUT_DURATION = 7; ///< The initial timeout value for WF_TIMEOUT.
+static const int WHITE_BORDER_DURATION = 3; ///< The initial timeout value for WF_WHITE_BORDER.
+
+/**
* Data structure for a window viewport.
* A viewport is either following a vehicle (its id in then in #follow_vehicle), or it aims to display a specific
* location #dest_scrollpos_x, #dest_scrollpos_y (#follow_vehicle is then #INVALID_VEHICLE).
@@ -256,10 +277,13 @@ public:
{
}
- uint16 flags4; ///< Window flags, @see WindowFlags
+ WindowFlags flags; ///< Window flags
WindowClass window_class; ///< Window class
WindowNumber window_number; ///< Window number within the window class
+ uint8 timeout_timer; ///< Timer value of the WF_TIMEOUT for flags.
+ uint8 white_border_timer; ///< Timervalue of the WF_WHITE_BORDER for flags.
+
int left; ///< x position of left edge of the window
int top; ///< y position of top edge of the window
int width; ///< width of the window (number of pixels to the right in x direction)
@@ -278,7 +302,7 @@ public:
NWidgetStacked *shade_select; ///< Selection widget (#NWID_SELECTION) to use for shading the window. If \c NULL, window cannot shade.
Dimension unshaded_size; ///< Last known unshaded size (only valid while shaded).
- int scrolling_scrollbar; ///< Widgetindex of just being dragged scrollbar. -1 of none is active.
+ int scrolling_scrollbar; ///< Widgetindex of just being dragged scrollbar. -1 if none is active.
Window *parent; ///< Parent window.
Window *z_front; ///< The window in front of us in z-order.
@@ -297,6 +321,24 @@ public:
void FinishInitNested(const WindowDesc *desc, WindowNumber window_number = 0);
/**
+ * Set the timeout flag of the window and initiate the timer.
+ */
+ inline void SetTimeout()
+ {
+ this->flags |= WF_TIMEOUT;
+ this->timeout_timer = TIMEOUT_DURATION;
+ }
+
+ /**
+ * Set the timeout flag of the window and initiate the timer.
+ */
+ inline void SetWhiteBorder()
+ {
+ this->flags |= WF_WHITE_BORDER;
+ this->white_border_timer = WHITE_BORDER_DURATION;
+ }
+
+ /**
* Sets the enabled/disabled status of a widget.
* By default, widgets are enabled.
* On certain conditions, they have to be disabled.
@@ -438,31 +480,8 @@ public:
void SetShaded(bool make_shaded);
- /**
- * Mark this window's data as invalid (in need of re-computing)
- * @param data The data to invalidate with
- * @param gui_scope Whether the funtion is called from GUI scope.
- */
- void InvalidateData(int data = 0, bool gui_scope = true)
- {
- this->SetDirty();
- if (!gui_scope) {
- /* Schedule GUI-scope invalidation for next redraw. */
- *this->scheduled_invalidation_data.Append() = data;
- }
- this->OnInvalidateData(data, gui_scope);
- }
-
- /**
- * Process all scheduled invalidations.
- */
- void ProcessScheduledInvalidations()
- {
- for (int *data = this->scheduled_invalidation_data.Begin(); this->window_class != WC_INVALID && data != this->scheduled_invalidation_data.End(); data++) {
- this->OnInvalidateData(*data, true);
- }
- this->scheduled_invalidation_data.Clear();
- }
+ void InvalidateData(int data = 0, bool gui_scope = true);
+ void ProcessScheduledInvalidations();
/*** Event handling ***/
@@ -773,27 +792,6 @@ public:
virtual ~PickerWindowBase();
};
-/**
- * Window flags
- */
-enum WindowFlags {
- WF_TIMEOUT_TRIGGER = 1, ///< When the timeout should start triggering
- WF_TIMEOUT_BEGIN = 7, ///< The initial value for the timeout
- WF_TIMEOUT_MASK = 7, ///< Window timeout counter bit mask (3 bits)
- WF_DRAGGING = 1 << 3, ///< Window is being dragged
- WF_SIZING_RIGHT = 1 << 4, ///< Window is being resized towards the right.
- WF_SIZING_LEFT = 1 << 5, ///< Window is being resized towards the left.
- WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT, ///< Window is being resized.
- WF_STICKY = 1 << 6, ///< Window is made sticky by user
-
- WF_DISABLE_VP_SCROLL = 1 << 7, ///< Window does not do autoscroll, @see HandleAutoscroll()
-
- WF_WHITE_BORDER_ONE = 1 << 8,
- WF_WHITE_BORDER_MASK = 1 << 9 | WF_WHITE_BORDER_ONE,
-
- WF_CENTERED = 1 << 10, ///< Window is centered and shall stay centered after ReInit
-};
-
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
Window *FindWindowFromPt(int x, int y);