Skip to content

Commit

Permalink
Remove: Redundant single-member enum for WidgetBaseFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
techgeeknz committed Jul 2, 2020
1 parent b6814df commit 2f14be7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/network/network_gui.cpp
Expand Up @@ -206,7 +206,7 @@ class NWidgetServerListHeader : public NWidgetContainer {

void FillDirtyWidgets(std::vector<NWidgetBase *> &dirty_widgets) override
{
if (this->base_flags & WBF_DIRTY) {
if (this->is_dirty) {
dirty_widgets.push_back(this);
} else {
int i = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/newgrf_gui.cpp
Expand Up @@ -1781,7 +1781,7 @@ class NWidgetNewGRFDisplay : public NWidgetContainer {

void FillDirtyWidgets(std::vector<NWidgetBase *> &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);
Expand Down
2 changes: 1 addition & 1 deletion src/smallmap_gui.cpp
Expand Up @@ -1754,7 +1754,7 @@ class NWidgetSmallmapDisplay : public NWidgetContainer {

void FillDirtyWidgets(std::vector<NWidgetBase *> &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);
Expand Down
2 changes: 1 addition & 1 deletion src/toolbar_gui.cpp
Expand Up @@ -1470,7 +1470,7 @@ class NWidgetToolbarContainer : public NWidgetContainer {

void FillDirtyWidgets(std::vector<NWidgetBase *> &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) {
Expand Down
26 changes: 13 additions & 13 deletions src/widget.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -906,7 +906,7 @@ NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y)

void NWidgetCore::FillDirtyWidgets(std::vector<NWidgetBase *> &dirty_widgets)
{
if (this->base_flags & WBF_DIRTY) dirty_widgets.push_back(this);
if (this->is_dirty) dirty_widgets.push_back(this);
}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1083,7 +1083,7 @@ NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y)

void NWidgetStacked::FillDirtyWidgets(std::vector<NWidgetBase *> &dirty_widgets)
{
if (this->base_flags & WBF_DIRTY) {
if (this->is_dirty) {
dirty_widgets.push_back(this);
} else {
int plane = 0;
Expand Down Expand Up @@ -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);
}
Expand All @@ -1148,7 +1148,7 @@ NWidgetCore *NWidgetPIPContainer::GetWidgetFromPos(int x, int y)

void NWidgetPIPContainer::FillDirtyWidgets(std::vector<NWidgetBase *> &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) {
Expand Down Expand Up @@ -1662,15 +1662,15 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y)

void NWidgetMatrix::FillDirtyWidgets(std::vector<NWidgetBase *> &dirty_widgets)
{
if (this->base_flags & WBF_DIRTY) {
if (this->is_dirty) {
dirty_widgets.push_back(this);
}
}

/* 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]);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -1929,7 +1929,7 @@ NWidgetCore *NWidgetBackground::GetWidgetFromPos(int x, int y)

void NWidgetBackground::FillDirtyWidgets(std::vector<NWidgetBase *> &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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
10 changes: 1 addition & 9 deletions src/widget_type.h
Expand Up @@ -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.
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 2f14be7

Please sign in to comment.