Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codechange: Use maxdim instead of setting width/height separately. #11535

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/company_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,12 +1466,9 @@ class SelectCompanyManagerFaceWindow : public Window
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE));
break;

case WID_SCMF_FACE: {
Dimension face_size = GetScaledSpriteSize(SPR_GRADIENT);
size->width = std::max(size->width, face_size.width);
size->height = std::max(size->height, face_size.height);
case WID_SCMF_FACE:
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT));
break;
}

case WID_SCMF_HAS_MOUSTACHE_EARRING:
case WID_SCMF_HAS_GLASSES:
Expand Down Expand Up @@ -2323,12 +2320,9 @@ struct CompanyWindow : Window
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
{
switch (widget) {
case WID_C_FACE: {
Dimension face_size = GetScaledSpriteSize(SPR_GRADIENT);
size->width = std::max(size->width, face_size.width);
size->height = std::max(size->height, face_size.height);
case WID_C_FACE:
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT));
break;
}

case WID_C_DESC_COLOUR_SCHEME_EXAMPLE: {
Point offset;
Expand Down
8 changes: 3 additions & 5 deletions src/error_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/** @file error_gui.cpp GUI related to errors. */

#include "stdafx.h"
#include "core/geometry_func.hpp"
#include "core/mem_func.hpp"
#include "landscape.h"
#include "newgrf_text.h"
Expand Down Expand Up @@ -208,12 +209,9 @@ struct ErrmsgWindow : public Window, ErrorMessageData {
size->height = std::max(size->height, panel_height);
break;
}
case WID_EM_FACE: {
Dimension face_size = GetScaledSpriteSize(SPR_GRADIENT);
size->width = std::max(size->width, face_size.width);
size->height = std::max(size->height, face_size.height);
case WID_EM_FACE:
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT));
break;
}
}
}

Expand Down