Codechange: Use unified NWidgetContainer methods instead of duplicating.
Most NWidgetContainer derivatives implemented Draw() and GetWidgetFromPos() the same way. Move this these to NWidgetContainer itself to avoid repeating.
This commit is contained in:

committed by
Peter Nelson

parent
af41c5cb4e
commit
59a2abd298
@@ -1477,21 +1477,7 @@ public:
|
||||
GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_VERY_DARK_RED);
|
||||
GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_DARK_RED, FILLRECT_CHECKER);
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != nullptr; child_wid = rtl ? child_wid->prev : child_wid->next) {
|
||||
child_wid->Draw(w);
|
||||
}
|
||||
}
|
||||
|
||||
NWidgetCore *GetWidgetFromPos(int x, int y) override
|
||||
{
|
||||
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
|
||||
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
||||
NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
|
||||
if (nwid != nullptr) return nwid;
|
||||
}
|
||||
return nullptr;
|
||||
this->NWidgetContainer::Draw(w);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user