From 2f14be73f38bfd113e1940e7df5c63d47f578084 Mon Sep 17 00:00:00 2001 From: TechGeekNZ Date: Thu, 2 Jul 2020 14:21:05 +1200 Subject: [PATCH] Remove: Redundant single-member enum for WidgetBaseFlags --- src/network/network_gui.cpp | 2 +- src/newgrf_gui.cpp | 2 +- src/smallmap_gui.cpp | 2 +- src/toolbar_gui.cpp | 2 +- src/widget.cpp | 26 +++++++++++++------------- src/widget_type.h | 10 +--------- 6 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 58b882b9cd905..818fd5e7c4fff 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -206,7 +206,7 @@ class NWidgetServerListHeader : public NWidgetContainer { void FillDirtyWidgets(std::vector &dirty_widgets) override { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } else { int i = 0; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 88897d6a530fa..f5b481019e956 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1781,7 +1781,7 @@ class NWidgetNewGRFDisplay : public NWidgetContainer { void FillDirtyWidgets(std::vector &dirty_widgets) override { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } else { if (this->editable) this->avs->FillDirtyWidgets(dirty_widgets); diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index b2dca03dac741..093278cf2d84c 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1754,7 +1754,7 @@ class NWidgetSmallmapDisplay : public NWidgetContainer { void FillDirtyWidgets(std::vector &dirty_widgets) override { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } else { for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) child_wid->FillDirtyWidgets(dirty_widgets); diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index bac9328f097e4..8d9b9114f5c33 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1470,7 +1470,7 @@ class NWidgetToolbarContainer : public NWidgetContainer { void FillDirtyWidgets(std::vector &dirty_widgets) override { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } else { for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { diff --git a/src/widget.cpp b/src/widget.cpp index 92f70246b3852..527d4068067d1 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -772,7 +772,7 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator() */ void NWidgetBase::SetDirty(Window *w) { - this->base_flags |= WBF_DIRTY; + this->is_dirty = true; w->flags |= WF_DIRTY; } @@ -906,7 +906,7 @@ NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y) void NWidgetCore::FillDirtyWidgets(std::vector &dirty_widgets) { - if (this->base_flags & WBF_DIRTY) dirty_widgets.push_back(this); + if (this->is_dirty) dirty_widgets.push_back(this); } /** @@ -1053,7 +1053,7 @@ void NWidgetStacked::FillNestedArray(NWidgetBase **array, uint length) void NWidgetStacked::Draw(const Window *w) { if (this->IsOutsideDrawArea()) return; - this->base_flags &= ~WBF_DIRTY; + this->is_dirty = false; if (this->shown_plane >= SZSP_BEGIN) return; int plane = 0; @@ -1083,7 +1083,7 @@ NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y) void NWidgetStacked::FillDirtyWidgets(std::vector &dirty_widgets) { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } else { int plane = 0; @@ -1129,7 +1129,7 @@ void NWidgetPIPContainer::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post) void NWidgetPIPContainer::Draw(const Window *w) { if (this->IsOutsideDrawArea()) return; - this->base_flags &= ~WBF_DIRTY; + this->is_dirty = false; for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { child_wid->Draw(w); } @@ -1148,7 +1148,7 @@ NWidgetCore *NWidgetPIPContainer::GetWidgetFromPos(int x, int y) void NWidgetPIPContainer::FillDirtyWidgets(std::vector &dirty_widgets) { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } else { for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { @@ -1662,7 +1662,7 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) void NWidgetMatrix::FillDirtyWidgets(std::vector &dirty_widgets) { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } } @@ -1670,7 +1670,7 @@ void NWidgetMatrix::FillDirtyWidgets(std::vector &dirty_widgets) /* virtual */ void NWidgetMatrix::Draw(const Window *w) { if (this->IsOutsideDrawArea()) return; - this->base_flags &= ~WBF_DIRTY; + this->is_dirty = false; /* Fill the background. */ GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, _colour_gradient[this->colour & 0xF][5]); @@ -1876,7 +1876,7 @@ void NWidgetBackground::FillNestedArray(NWidgetBase **array, uint length) void NWidgetBackground::Draw(const Window *w) { if (this->IsOutsideDrawArea()) return; - this->base_flags &= ~WBF_DIRTY; + this->is_dirty = false; if (this->current_x == 0 || this->current_y == 0) return; @@ -1929,7 +1929,7 @@ NWidgetCore *NWidgetBackground::GetWidgetFromPos(int x, int y) void NWidgetBackground::FillDirtyWidgets(std::vector &dirty_widgets) { - if (this->base_flags & WBF_DIRTY) { + if (this->is_dirty) { dirty_widgets.push_back(this); } else { if (this->child != nullptr) this->child->FillDirtyWidgets(dirty_widgets); @@ -1962,7 +1962,7 @@ void NWidgetViewport::SetupSmallestSize(Window *w, bool init_array) void NWidgetViewport::Draw(const Window *w) { if (this->IsOutsideDrawArea()) return; - this->base_flags &= ~WBF_DIRTY; + this->is_dirty = false; if (this->disp_flags & ND_NO_TRANSPARENCY) { TransparencyOptionBits to_backup = _transparency_opt; @@ -2090,7 +2090,7 @@ void NWidgetScrollbar::SetupSmallestSize(Window *w, bool init_array) void NWidgetScrollbar::Draw(const Window *w) { if (this->IsOutsideDrawArea()) return; - this->base_flags &= ~WBF_DIRTY; + this->is_dirty = false; if (this->current_x == 0 || this->current_y == 0) return; @@ -2460,7 +2460,7 @@ void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array) void NWidgetLeaf::Draw(const Window *w) { if (this->IsOutsideDrawArea()) return; - this->base_flags &= ~WBF_DIRTY; + this->is_dirty = false; if (this->current_x == 0 || this->current_y == 0) return; diff --git a/src/widget_type.h b/src/widget_type.h index 4d9247f7f4264..c2aabd28a8e6a 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -108,14 +108,6 @@ enum WidgetType : uint8 { NWID_PUSHBUTTON_DROPDOWN = NWID_BUTTON_DROPDOWN | WWB_PUSHBUTTON, }; -/** - * Base widget flags. - */ -enum WidgetBaseFlags : uint8 { - WBF_DIRTY = 1 << 0, ///< Widget is dirty. -}; -DECLARE_ENUM_AS_BIT_SET(WidgetBaseFlags) - /** Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition() */ enum SizingType { ST_SMALLEST, ///< Initialize nested widget tree to smallest size. Also updates \e current_x and \e current_y. @@ -171,7 +163,7 @@ class NWidgetBase : public ZeroedMemoryAllocator { virtual void SetDirty(Window *w); WidgetType type; ///< Type of the widget / nested widget. - WidgetBaseFlags base_flags; ///< Widget base flags + bool is_dirty; ///< Widget is dirty (in need of a repaint). uint fill_x; ///< Horizontal fill stepsize (from initial size, \c 0 means not resizable). uint fill_y; ///< Vertical fill stepsize (from initial size, \c 0 means not resizable). uint resize_x; ///< Horizontal resize step (\c 0 means not resizable).