Codechange: Make GetCurrentRect() conform to usual Rect bounds, and reuse it.
Similar code is already repeated in other locations.
(cherry picked from commit d8e06e590a
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
065ae3964a
commit
b414060f7c
@@ -2016,11 +2016,7 @@ void NWidgetBackground::Draw(const Window *w)
|
||||
|
||||
if (this->current_x == 0 || this->current_y == 0) return;
|
||||
|
||||
Rect r;
|
||||
r.left = this->pos_x;
|
||||
r.right = this->pos_x + this->current_x - 1;
|
||||
r.top = this->pos_y;
|
||||
r.bottom = this->pos_y + this->current_y - 1;
|
||||
Rect r = this->GetCurrentRect();
|
||||
|
||||
const DrawPixelInfo *dpi = _cur_dpi;
|
||||
if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top) return;
|
||||
@@ -2299,11 +2295,7 @@ void NWidgetScrollbar::Draw(const Window *w)
|
||||
|
||||
if (this->current_x == 0 || this->current_y == 0) return;
|
||||
|
||||
Rect r;
|
||||
r.left = this->pos_x;
|
||||
r.right = this->pos_x + this->current_x - 1;
|
||||
r.top = this->pos_y;
|
||||
r.bottom = this->pos_y + this->current_y - 1;
|
||||
Rect r = this->GetCurrentRect();
|
||||
|
||||
const DrawPixelInfo *dpi = _cur_dpi;
|
||||
if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top) return;
|
||||
@@ -2685,11 +2677,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
||||
DrawPixelInfo *old_dpi = _cur_dpi;
|
||||
_cur_dpi = &new_dpi;
|
||||
|
||||
Rect r;
|
||||
r.left = this->pos_x;
|
||||
r.right = this->pos_x + this->current_x - 1;
|
||||
r.top = this->pos_y;
|
||||
r.bottom = this->pos_y + this->current_y - 1;
|
||||
Rect r = this->GetCurrentRect();
|
||||
|
||||
bool clicked = this->IsLowered();
|
||||
switch (this->type) {
|
||||
|
Reference in New Issue
Block a user