mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for WindowFlags.
parent
248f369e86
commit
efb05396a7
|
@ -53,7 +53,7 @@ public:
|
|||
BootstrapBackground() : Window(_background_desc)
|
||||
{
|
||||
this->InitNested(0);
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
ResizeWindow(this, _screen.width, _screen.height);
|
||||
}
|
||||
|
||||
|
|
|
@ -536,7 +536,7 @@ struct CheatWindow : Window {
|
|||
value ^= 1;
|
||||
} else {
|
||||
/* don't allow too fast scrolling */
|
||||
if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
|
||||
if (this->flags.Test(WindowFlag::Timeout) && this->timeout_timer > 1) {
|
||||
_left_button_clicked = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ struct DropdownWindow : Window {
|
|||
this->UpdateSizeAndPosition();
|
||||
|
||||
this->FinishInitNested(0);
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
}
|
||||
|
||||
void Close([[maybe_unused]] int data = 0) override
|
||||
|
|
|
@ -75,7 +75,7 @@ struct EnginePreviewWindow : Window {
|
|||
this->InitNested(window_number);
|
||||
|
||||
/* There is no way to recover the window; so disallow closure via DEL; unless SHIFT+DEL */
|
||||
this->flags |= WF_STICKY;
|
||||
this->flags.Set(WindowFlag::Sticky);
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
|
|
|
@ -726,7 +726,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
case WID_GL_HEIGHTMAP_HEIGHT_DOWN:
|
||||
case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
|
||||
/* Don't allow too fast scrolling */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
|
||||
_settings_newgame.game_creation.heightmap_height = Clamp(_settings_newgame.game_creation.heightmap_height + widget - WID_GL_HEIGHTMAP_HEIGHT_TEXT, MIN_HEIGHTMAP_HEIGHT, GetMapHeightLimit());
|
||||
|
@ -745,7 +745,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
case WID_GL_START_DATE_DOWN:
|
||||
case WID_GL_START_DATE_UP: // Year buttons
|
||||
/* Don't allow too fast scrolling */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
|
||||
_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_GL_START_DATE_TEXT, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
|
||||
|
@ -763,7 +763,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
case WID_GL_SNOW_COVERAGE_DOWN:
|
||||
case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
|
||||
/* Don't allow too fast scrolling */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
|
||||
_settings_newgame.game_creation.snow_coverage = Clamp(_settings_newgame.game_creation.snow_coverage + (widget - WID_GL_SNOW_COVERAGE_TEXT) * 10, 0, 100);
|
||||
|
@ -781,7 +781,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
case WID_GL_DESERT_COVERAGE_DOWN:
|
||||
case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
|
||||
/* Don't allow too fast scrolling */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
|
||||
_settings_newgame.game_creation.desert_coverage = Clamp(_settings_newgame.game_creation.desert_coverage + (widget - WID_GL_DESERT_COVERAGE_TEXT) * 10, 0, 100);
|
||||
|
@ -1180,7 +1180,7 @@ struct CreateScenarioWindow : public Window
|
|||
case WID_CS_START_DATE_DOWN:
|
||||
case WID_CS_START_DATE_UP: // Year buttons
|
||||
/* Don't allow too fast scrolling */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
this->SetDirty();
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ struct CreateScenarioWindow : public Window
|
|||
case WID_CS_FLAT_LAND_HEIGHT_DOWN:
|
||||
case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
|
||||
/* Don't allow too fast scrolling */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
this->SetDirty();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct EndGameHighScoreBaseWindow : Window {
|
|||
EndGameHighScoreBaseWindow(WindowDesc &desc) : Window(desc)
|
||||
{
|
||||
this->InitNested();
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
ResizeWindow(this, _screen.width - this->width, _screen.height - this->height);
|
||||
}
|
||||
|
||||
|
|
|
@ -815,7 +815,7 @@ class IndustryViewWindow : public Window
|
|||
public:
|
||||
IndustryViewWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->flags |= WF_DISABLE_VP_SCROLL;
|
||||
this->flags.Set(WindowFlag::DisableVpScroll);
|
||||
this->editbox_line = IL_NONE;
|
||||
this->clicked_line = IL_NONE;
|
||||
this->clicked_button = 0;
|
||||
|
|
|
@ -322,7 +322,7 @@ struct SelectGameWindow : public Window {
|
|||
changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION), 3);
|
||||
}
|
||||
|
||||
if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED);
|
||||
if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred));
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
|
|
|
@ -212,7 +212,7 @@ struct MainWindow : Window
|
|||
MainWindow(WindowDesc &desc) : Window(desc)
|
||||
{
|
||||
this->InitNested(0);
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
ResizeWindow(this, _screen.width, _screen.height);
|
||||
|
||||
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT);
|
||||
|
|
|
@ -660,7 +660,7 @@ struct TooltipsWindow : public Window
|
|||
|
||||
this->InitNested();
|
||||
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
}
|
||||
|
||||
Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
|
||||
|
|
|
@ -1056,7 +1056,7 @@ struct NetworkStartServerWindow : public Window {
|
|||
case WID_NSS_CLIENTS_BTND: case WID_NSS_CLIENTS_BTNU: // Click on up/down button for number of clients
|
||||
case WID_NSS_COMPANIES_BTND: case WID_NSS_COMPANIES_BTNU: // Click on up/down button for number of companies
|
||||
/* Don't allow too fast scrolling. */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
this->SetDirty();
|
||||
switch (widget) {
|
||||
|
|
|
@ -358,7 +358,7 @@ struct NewsWindow : Window {
|
|||
this->chat_height = (w != nullptr) ? w->height : 0;
|
||||
this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height;
|
||||
|
||||
this->flags |= WF_DISABLE_VP_SCROLL;
|
||||
this->flags.Set(WindowFlag::DisableVpScroll);
|
||||
|
||||
this->CreateNestedTree();
|
||||
|
||||
|
|
|
@ -634,7 +634,7 @@ struct GameOptionsWindow : Window {
|
|||
y = GetStringHeight(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, wid->current_x);
|
||||
changed |= wid->UpdateVerticalSize(y);
|
||||
|
||||
if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED);
|
||||
if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred));
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
|
@ -2664,7 +2664,7 @@ struct GameSettingsWindow : Window {
|
|||
if (step == 0) step = 1;
|
||||
|
||||
/* don't allow too fast scrolling */
|
||||
if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
|
||||
if (this->flags.Test(WindowFlag::Timeout) && this->timeout_timer > 1) {
|
||||
_left_button_clicked = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ struct StatusBarWindow : Window {
|
|||
this->ticker_scroll = TICKER_STOP;
|
||||
|
||||
this->InitNested();
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
PositionStatusbar(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1211,7 +1211,7 @@ static CallBackFunction ToolbarScenDatePanel(Window *w)
|
|||
static CallBackFunction ToolbarScenDateBackward(Window *w)
|
||||
{
|
||||
/* don't allow too fast scrolling */
|
||||
if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
|
||||
if (!w->flags.Test(WindowFlag::Timeout) || w->timeout_timer <= 1) {
|
||||
w->HandleButtonClick(WID_TE_DATE_BACKWARD);
|
||||
w->SetDirty();
|
||||
|
||||
|
@ -1224,7 +1224,7 @@ static CallBackFunction ToolbarScenDateBackward(Window *w)
|
|||
static CallBackFunction ToolbarScenDateForward(Window *w)
|
||||
{
|
||||
/* don't allow too fast scrolling */
|
||||
if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
|
||||
if (!w->flags.Test(WindowFlag::Timeout) || w->timeout_timer <= 1) {
|
||||
w->HandleButtonClick(WID_TE_DATE_FORWARD);
|
||||
w->SetDirty();
|
||||
|
||||
|
@ -1991,7 +1991,7 @@ struct MainToolbarWindow : Window {
|
|||
this->InitNested(0);
|
||||
|
||||
_last_started_action = CBF_NONE;
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
|
||||
this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
|
||||
PositionMainToolbar(this);
|
||||
|
@ -2332,7 +2332,7 @@ struct ScenarioEditorToolbarWindow : Window {
|
|||
this->InitNested(0);
|
||||
|
||||
_last_started_action = CBF_NONE;
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
this->flags.Reset(WindowFlag::WhiteBorder);
|
||||
PositionMainToolbar(this);
|
||||
DoZoomInOutWindow(ZOOM_NONE, this);
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ public:
|
|||
|
||||
this->FinishInitNested(window_number);
|
||||
|
||||
this->flags |= WF_DISABLE_VP_SCROLL;
|
||||
this->flags.Set(WindowFlag::DisableVpScroll);
|
||||
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_TV_VIEWPORT);
|
||||
nvp->InitializeViewport(this, this->town->xy, ScaleZoomGUI(ZOOM_LVL_TOWN));
|
||||
|
||||
|
|
|
@ -3070,7 +3070,7 @@ private:
|
|||
public:
|
||||
VehicleViewWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->flags |= WF_DISABLE_VP_SCROLL;
|
||||
this->flags.Set(WindowFlag::DisableVpScroll);
|
||||
this->CreateNestedTree();
|
||||
|
||||
/* Sprites for the 'send to depot' button indexed by vehicle type. */
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
this->FinishInitNested(window_number);
|
||||
|
||||
this->owner = this->wp->owner;
|
||||
this->flags |= WF_DISABLE_VP_SCROLL;
|
||||
this->flags.Set(WindowFlag::DisableVpScroll);
|
||||
|
||||
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_W_VIEWPORT);
|
||||
nvp->InitializeViewport(this, this->GetCenterTile(), ScaleZoomGUI(ZOOM_LVL_VIEWPORT));
|
||||
|
|
|
@ -732,11 +732,11 @@ void Window::DrawWidgets() const
|
|||
{
|
||||
this->nested_root->Draw(this);
|
||||
|
||||
if (this->flags & WF_WHITE_BORDER) {
|
||||
if (this->flags.Test(WindowFlag::WhiteBorder)) {
|
||||
DrawFrameRect(0, 0, this->width - 1, this->height - 1, COLOUR_WHITE, FR_BORDERONLY);
|
||||
}
|
||||
|
||||
if (this->flags & WF_HIGHLIGHTED) {
|
||||
if (this->flags.Test(WindowFlag::Highlighted)) {
|
||||
extern bool _window_highlight_colour;
|
||||
for (const auto &pair : this->widget_lookup) {
|
||||
const NWidgetBase *widget = pair.second;
|
||||
|
@ -3068,7 +3068,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
|||
break;
|
||||
|
||||
case WWT_STICKYBOX:
|
||||
DrawStickyBox(r, this->colour, !!(w->flags & WF_STICKY));
|
||||
DrawStickyBox(r, this->colour, w->flags.Test(WindowFlag::Sticky));
|
||||
break;
|
||||
|
||||
case WWT_DEFSIZEBOX:
|
||||
|
@ -3076,7 +3076,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
|||
break;
|
||||
|
||||
case WWT_RESIZEBOX:
|
||||
DrawResizeBox(r, this->colour, this->pos_x < (w->width / 2), !!(w->flags & WF_SIZING), this->widget_data.resize_widget_type == RWV_SHOW_BEVEL);
|
||||
DrawResizeBox(r, this->colour, this->pos_x < (w->width / 2), w->flags.Test(WindowFlag::SizingLeft) || w->flags.Test(WindowFlag::SizingRight), this->widget_data.resize_widget_type == RWV_SHOW_BEVEL);
|
||||
break;
|
||||
|
||||
case WWT_CLOSEBOX:
|
||||
|
|
|
@ -191,7 +191,7 @@ void WindowDesc::SaveToConfig()
|
|||
void Window::ApplyDefaults()
|
||||
{
|
||||
if (this->nested_root != nullptr && this->nested_root->GetWidgetOfType(WWT_STICKYBOX) != nullptr) {
|
||||
if (this->window_desc.pref_sticky) this->flags |= WF_STICKY;
|
||||
if (this->window_desc.pref_sticky) this->flags.Set(WindowFlag::Sticky);
|
||||
} else {
|
||||
/* There is no stickybox; clear the preference in case someone tried to be funny */
|
||||
this->window_desc.pref_sticky = false;
|
||||
|
@ -228,7 +228,7 @@ void Window::DisableAllWidgetHighlight()
|
|||
}
|
||||
}
|
||||
|
||||
CLRBITS(this->flags, WF_HIGHLIGHTED);
|
||||
this->flags.Reset(WindowFlag::Highlighted);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,7 +246,7 @@ void Window::SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_co
|
|||
|
||||
if (highlighted_colour != TC_INVALID) {
|
||||
/* If we set a highlight, the window has a highlight */
|
||||
this->flags |= WF_HIGHLIGHTED;
|
||||
this->flags.Set(WindowFlag::Highlighted);
|
||||
} else {
|
||||
/* If we disable a highlight, check all widgets if anyone still has a highlight */
|
||||
bool valid = false;
|
||||
|
@ -257,7 +257,7 @@ void Window::SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_co
|
|||
valid = true;
|
||||
}
|
||||
/* If nobody has a highlight, disable the flag on the window */
|
||||
if (!valid) CLRBITS(this->flags, WF_HIGHLIGHTED);
|
||||
if (!valid) this->flags.Reset(WindowFlag::Highlighted);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,9 +708,9 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
|
|||
return;
|
||||
|
||||
case WWT_STICKYBOX:
|
||||
w->flags ^= WF_STICKY;
|
||||
w->flags.Flip(WindowFlag::Sticky);
|
||||
nw->SetDirty(w);
|
||||
if (_ctrl_pressed) w->window_desc.pref_sticky = (w->flags & WF_STICKY) != 0;
|
||||
if (_ctrl_pressed) w->window_desc.pref_sticky = w->flags.Test(WindowFlag::Sticky);
|
||||
return;
|
||||
|
||||
default:
|
||||
|
@ -750,7 +750,7 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
|
|||
/* Right-click close is enabled and there is a closebox. */
|
||||
if (_settings_client.gui.right_click_wnd_close == RCC_YES && (w->window_desc.flags & WDF_NO_CLOSE) == 0) {
|
||||
w->Close();
|
||||
} else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && (w->flags & WF_STICKY) == 0 && (w->window_desc.flags & WDF_NO_CLOSE) == 0) {
|
||||
} else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && !w->flags.Test(WindowFlag::Sticky) && (w->window_desc.flags & WDF_NO_CLOSE) == 0) {
|
||||
/* Right-click close is enabled, but excluding sticky windows. */
|
||||
w->Close();
|
||||
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->GetIndex(), TCC_RIGHT_CLICK) && wid->GetToolTip() != STR_NULL) {
|
||||
|
@ -1137,7 +1137,7 @@ Window *GetMainWindow()
|
|||
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
|
||||
{
|
||||
Window *w = FindWindowById(cls, number);
|
||||
if (w != nullptr && (force || (w->flags & WF_STICKY) == 0)) {
|
||||
if (w != nullptr && (force || !w->flags.Test(WindowFlag::Sticky))) {
|
||||
w->Close(data);
|
||||
}
|
||||
}
|
||||
|
@ -1363,7 +1363,7 @@ void Window::InitializeData(WindowNumber window_number)
|
|||
/* Set up window properties; some of them are needed to set up smallest size below */
|
||||
this->window_class = this->window_desc.cls;
|
||||
this->SetWhiteBorder();
|
||||
if (this->window_desc.default_pos == WDP_CENTER) this->flags |= WF_CENTERED;
|
||||
if (this->window_desc.default_pos == WDP_CENTER) this->flags.Set(WindowFlag::Centred);
|
||||
this->owner = INVALID_OWNER;
|
||||
this->nested_focus = nullptr;
|
||||
this->window_number = window_number;
|
||||
|
@ -1848,8 +1848,8 @@ static void DecreaseWindowCounters()
|
|||
}
|
||||
|
||||
for (Window *w : Window::Iterate()) {
|
||||
if ((w->flags & WF_TIMEOUT) && --w->timeout_timer == 0) {
|
||||
CLRBITS(w->flags, WF_TIMEOUT);
|
||||
if (w->flags.Test(WindowFlag::Timeout) && --w->timeout_timer == 0) {
|
||||
w->flags.Reset(WindowFlag::Timeout);
|
||||
|
||||
w->OnTimeout();
|
||||
w->RaiseButtons(true);
|
||||
|
@ -2089,10 +2089,10 @@ static EventState HandleWindowDragging()
|
|||
|
||||
/* Otherwise find the window... */
|
||||
for (Window *w : Window::Iterate()) {
|
||||
if (w->flags & WF_DRAGGING) {
|
||||
if (w->flags.Test(WindowFlag::Dragging)) {
|
||||
/* Stop the dragging if the left mouse button was released */
|
||||
if (!_left_button_down) {
|
||||
w->flags &= ~WF_DRAGGING;
|
||||
w->flags.Reset(WindowFlag::Dragging);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2181,10 +2181,11 @@ static EventState HandleWindowDragging()
|
|||
|
||||
w->SetDirty();
|
||||
return ES_HANDLED;
|
||||
} else if (w->flags & WF_SIZING) {
|
||||
} else if (w->flags.Test(WindowFlag::SizingLeft) || w->flags.Test(WindowFlag::SizingRight)) {
|
||||
/* Stop the sizing if the left mouse button was released */
|
||||
if (!_left_button_down) {
|
||||
w->flags &= ~WF_SIZING;
|
||||
w->flags.Reset(WindowFlag::SizingLeft);
|
||||
w->flags.Reset(WindowFlag::SizingRight);
|
||||
w->SetDirty();
|
||||
break;
|
||||
}
|
||||
|
@ -2193,7 +2194,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->flags & WF_SIZING_LEFT) {
|
||||
if (w->flags.Test(WindowFlag::SizingLeft)) {
|
||||
x = _drag_delta.x - _cursor.pos.x;
|
||||
} else {
|
||||
x = _cursor.pos.x - _drag_delta.x;
|
||||
|
@ -2227,7 +2228,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->flags & WF_SIZING_LEFT) && x != 0) {
|
||||
if (w->flags.Test(WindowFlag::SizingLeft) && 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.
|
||||
|
@ -2252,8 +2253,8 @@ static EventState HandleWindowDragging()
|
|||
*/
|
||||
static void StartWindowDrag(Window *w)
|
||||
{
|
||||
w->flags |= WF_DRAGGING;
|
||||
w->flags &= ~WF_CENTERED;
|
||||
w->flags.Set(WindowFlag::Dragging);
|
||||
w->flags.Reset(WindowFlag::Centred);
|
||||
_dragging_window = true;
|
||||
|
||||
_drag_delta.x = w->left - _cursor.pos.x;
|
||||
|
@ -2269,8 +2270,8 @@ static void StartWindowDrag(Window *w)
|
|||
*/
|
||||
static void StartWindowSizing(Window *w, bool to_left)
|
||||
{
|
||||
w->flags |= to_left ? WF_SIZING_LEFT : WF_SIZING_RIGHT;
|
||||
w->flags &= ~WF_CENTERED;
|
||||
w->flags.Set(to_left ? WindowFlag::SizingLeft : WindowFlag::SizingRight);
|
||||
w->flags.Reset(WindowFlag::Centred);
|
||||
_dragging_window = true;
|
||||
|
||||
_drag_delta.x = _cursor.pos.x;
|
||||
|
@ -2677,7 +2678,7 @@ static void HandleAutoscroll()
|
|||
int x = _cursor.pos.x;
|
||||
int y = _cursor.pos.y;
|
||||
Window *w = FindWindowFromPt(x, y);
|
||||
if (w == nullptr || w->flags & WF_DISABLE_VP_SCROLL) return;
|
||||
if (w == nullptr || w->flags.Test(WindowFlag::DisableVpScroll)) return;
|
||||
if (_settings_client.gui.auto_scrolling != VA_EVERY_VIEWPORT && w->window_class != WC_MAIN_WINDOW) return;
|
||||
|
||||
Viewport *vp = IsPtInWindowViewport(w, x, y);
|
||||
|
@ -2815,7 +2816,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
|
|||
}
|
||||
|
||||
if (vp != nullptr) {
|
||||
if (scrollwheel_scrolling && !(w->flags & WF_DISABLE_VP_SCROLL)) {
|
||||
if (scrollwheel_scrolling && !w->flags.Test(WindowFlag::DisableVpScroll)) {
|
||||
_scrolling_viewport = true;
|
||||
_cursor.fix_at = true;
|
||||
return;
|
||||
|
@ -2825,7 +2826,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
|
|||
case MC_DOUBLE_LEFT:
|
||||
case MC_LEFT:
|
||||
if (HandleViewportClicked(vp, x, y)) return;
|
||||
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
|
||||
if (!w->flags.Test(WindowFlag::DisableVpScroll) &&
|
||||
_settings_client.gui.scroll_mode == VSM_MAP_LMB) {
|
||||
_scrolling_viewport = true;
|
||||
_cursor.fix_at = false;
|
||||
|
@ -2834,7 +2835,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
|
|||
break;
|
||||
|
||||
case MC_RIGHT:
|
||||
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
|
||||
if (!w->flags.Test(WindowFlag::DisableVpScroll) &&
|
||||
_settings_client.gui.scroll_mode != VSM_MAP_LMB) {
|
||||
_scrolling_viewport = true;
|
||||
_cursor.fix_at = (_settings_client.gui.scroll_mode == VSM_VIEWPORT_RMB_FIXED ||
|
||||
|
@ -2970,7 +2971,7 @@ static void CheckSoftLimit()
|
|||
uint deletable_count = 0;
|
||||
Window *last_deletable = nullptr;
|
||||
for (Window *w : Window::IterateFromFront()) {
|
||||
if (w->window_class == WC_MAIN_WINDOW || IsVitalWindow(w) || (w->flags & WF_STICKY)) continue;
|
||||
if (w->window_class == WC_MAIN_WINDOW || IsVitalWindow(w) || w->flags.Test(WindowFlag::Sticky)) continue;
|
||||
|
||||
last_deletable = w;
|
||||
deletable_count++;
|
||||
|
@ -3040,8 +3041,8 @@ static IntervalTimer<TimerWindow> white_border_interval(std::chrono::millisecond
|
|||
if (_network_dedicated) return;
|
||||
|
||||
for (Window *w : Window::Iterate()) {
|
||||
if ((w->flags & WF_WHITE_BORDER) && --w->white_border_timer == 0) {
|
||||
CLRBITS(w->flags, WF_WHITE_BORDER);
|
||||
if (w->flags.Test(WindowFlag::WhiteBorder) && --w->white_border_timer == 0) {
|
||||
w->flags.Reset(WindowFlag::WhiteBorder);
|
||||
w->SetDirty();
|
||||
}
|
||||
}
|
||||
|
@ -3180,7 +3181,7 @@ void Window::ProcessScheduledInvalidations()
|
|||
*/
|
||||
void Window::ProcessHighlightedInvalidations()
|
||||
{
|
||||
if ((this->flags & WF_HIGHLIGHTED) == 0) return;
|
||||
if (!this->flags.Test(WindowFlag::Highlighted)) return;
|
||||
|
||||
for (const auto &pair : this->widget_lookup) {
|
||||
if (pair.second->IsHighlighted()) pair.second->SetDirty(this);
|
||||
|
@ -3260,7 +3261,7 @@ void CloseNonVitalWindows()
|
|||
/* Note: the container remains stable, even when deleting windows. */
|
||||
for (Window *w : Window::Iterate()) {
|
||||
if ((w->window_desc.flags & WDF_NO_CLOSE) == 0 &&
|
||||
(w->flags & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
|
||||
!w->flags.Test(WindowFlag::Sticky)) { // do not delete windows which are 'pinned'
|
||||
|
||||
w->Close();
|
||||
}
|
||||
|
@ -3494,7 +3495,7 @@ void RelocateAllWindows(int neww, int newh)
|
|||
continue;
|
||||
|
||||
default: {
|
||||
if (w->flags & WF_CENTERED) {
|
||||
if (w->flags.Test(WindowFlag::Centred)) {
|
||||
top = (newh - w->height) >> 1;
|
||||
left = (neww - w->width) >> 1;
|
||||
break;
|
||||
|
|
|
@ -224,23 +224,23 @@ enum SortButtonState : uint8_t {
|
|||
/**
|
||||
* Window flags.
|
||||
*/
|
||||
enum WindowFlags : uint16_t {
|
||||
WF_TIMEOUT = 1 << 0, ///< Window timeout counter.
|
||||
enum class WindowFlag : uint8_t {
|
||||
Timeout, ///< 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_HIGHLIGHTED = 1 << 9, ///< Window has a widget that has a highlight.
|
||||
WF_CENTERED = 1 << 10, ///< Window is centered and shall stay centered after ReInit.
|
||||
Dragging, ///< Window is being dragged.
|
||||
SizingRight, ///< Window is being resized towards the right.
|
||||
SizingLeft, ///< Window is being resized towards the left.
|
||||
|
||||
Sticky, ///< Window is made sticky by user
|
||||
DisableVpScroll, ///< Window does not do autoscroll, @see HandleAutoscroll().
|
||||
WhiteBorder, ///< Window white border counter bit mask.
|
||||
Highlighted, ///< Window has a widget that has a highlight.
|
||||
Centred, ///< Window is centered and shall stay centered after ReInit.
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(WindowFlags)
|
||||
using WindowFlags = EnumBitSet<WindowFlag, uint16_t>;
|
||||
|
||||
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.
|
||||
static const int TIMEOUT_DURATION = 7; ///< The initial timeout value for WindowFlag::Timeout.
|
||||
static const int WHITE_BORDER_DURATION = 3; ///< The initial timeout value for WindowFlag::WhiteBorder.
|
||||
|
||||
/**
|
||||
* Data structure for a window viewport.
|
||||
|
@ -303,8 +303,8 @@ public:
|
|||
|
||||
int scale; ///< Scale of this window -- used to determine how to resize.
|
||||
|
||||
uint8_t timeout_timer; ///< Timer value of the WF_TIMEOUT for flags.
|
||||
uint8_t white_border_timer; ///< Timer value of the WF_WHITE_BORDER for flags.
|
||||
uint8_t timeout_timer; ///< Timer value of the WindowFlag::Timeout for flags.
|
||||
uint8_t white_border_timer; ///< Timer value of the WindowFlag::WhiteBorder for flags.
|
||||
|
||||
int left; ///< x position of left edge of the window
|
||||
int top; ///< y position of top edge of the window
|
||||
|
@ -360,7 +360,7 @@ public:
|
|||
*/
|
||||
inline void SetTimeout()
|
||||
{
|
||||
this->flags |= WF_TIMEOUT;
|
||||
this->flags.Set(WindowFlag::Timeout);
|
||||
this->timeout_timer = TIMEOUT_DURATION;
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ public:
|
|||
*/
|
||||
inline void SetWhiteBorder()
|
||||
{
|
||||
this->flags |= WF_WHITE_BORDER;
|
||||
this->flags.Set(WindowFlag::WhiteBorder);
|
||||
this->white_border_timer = WHITE_BORDER_DURATION;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue