Codechange: Make GetCurrentRect() conform to usual Rect bounds, and reuse it.
Similar code is already repeated in other locations.
This commit is contained in:
@@ -2097,10 +2097,7 @@ static void EnsureVisibleCaption(Window *w, int nx, int ny)
|
||||
Rect caption_rect;
|
||||
const NWidgetBase *caption = w->nested_root->GetWidgetOfType(WWT_CAPTION);
|
||||
if (caption != nullptr) {
|
||||
caption_rect.left = caption->pos_x;
|
||||
caption_rect.right = caption->pos_x + caption->current_x;
|
||||
caption_rect.top = caption->pos_y;
|
||||
caption_rect.bottom = caption->pos_y + caption->current_y;
|
||||
caption_rect = caption->GetCurrentRect();
|
||||
|
||||
/* Make sure the window doesn't leave the screen */
|
||||
nx = Clamp(nx, MIN_VISIBLE_TITLE_BAR - caption_rect.right, _screen.width - MIN_VISIBLE_TITLE_BAR - caption_rect.left);
|
||||
|
Reference in New Issue
Block a user