Codechange: Pass by reference to UpdateWidgetSize. (#12457)
These parameters are always provided and not optional.
This commit is contained in:
@@ -210,13 +210,13 @@ struct NewGRFParametersWindow : public Window {
|
||||
return this->HasParameterInfo(nr) ? this->grf_config->param_info[nr].value() : GetDummyParameterInfo(nr);
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_NP_NUMPAR_DEC:
|
||||
case WID_NP_NUMPAR_INC: {
|
||||
size->width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL));
|
||||
size->height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL));
|
||||
size.width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL));
|
||||
size.height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -225,16 +225,16 @@ struct NewGRFParametersWindow : public Window {
|
||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_NP_BACKGROUND:
|
||||
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
|
||||
resize->width = 1;
|
||||
resize->height = this->line_height;
|
||||
size->height = 5 * this->line_height;
|
||||
resize.width = 1;
|
||||
resize.height = this->line_height;
|
||||
size.height = 5 * this->line_height;
|
||||
break;
|
||||
|
||||
case WID_NP_DESCRIPTION:
|
||||
@@ -248,7 +248,7 @@ struct NewGRFParametersWindow : public Window {
|
||||
d.height += WidgetDimensions::scaled.frametext.Vertical();
|
||||
suggestion = maxdim(d, suggestion);
|
||||
}
|
||||
size->height = suggestion.height;
|
||||
size.height = suggestion.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -743,34 +743,34 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_NS_FILE_LIST:
|
||||
{
|
||||
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
|
||||
resize->height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
|
||||
size->height = std::max(size->height, padding.height + 6 * resize->height);
|
||||
resize.height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
|
||||
size.height = std::max(size.height, padding.height + 6 * resize.height);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_NS_AVAIL_LIST:
|
||||
{
|
||||
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
|
||||
resize->height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
|
||||
size->height = std::max(size->height, padding.height + 8 * resize->height);
|
||||
resize.height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
|
||||
size.height = std::max(size.height, padding.height + 8 * resize.height);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_NS_NEWGRF_INFO_TITLE: {
|
||||
Dimension dim = GetStringBoundingBox(STR_NEWGRF_SETTINGS_INFO_TITLE);
|
||||
size->height = std::max(size->height, dim.height + WidgetDimensions::scaled.frametext.Vertical());
|
||||
size->width = std::max(size->width, dim.width + WidgetDimensions::scaled.frametext.Horizontal());
|
||||
size.height = std::max(size.height, dim.height + WidgetDimensions::scaled.frametext.Vertical());
|
||||
size.width = std::max(size.width, dim.width + WidgetDimensions::scaled.frametext.Horizontal());
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_NS_NEWGRF_INFO:
|
||||
size->height = std::max<uint>(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL));
|
||||
size.height = std::max<uint>(size.height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL));
|
||||
break;
|
||||
|
||||
case WID_NS_PRESET_LIST: {
|
||||
@@ -780,16 +780,16 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING));
|
||||
}
|
||||
d.width += padding.width;
|
||||
*size = maxdim(d, *size);
|
||||
size = maxdim(d, size);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_NS_CONTENT_DOWNLOAD:
|
||||
case WID_NS_CONTENT_DOWNLOAD2: {
|
||||
Dimension d = GetStringBoundingBox(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON);
|
||||
*size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT));
|
||||
size->width += padding.width;
|
||||
size->height += padding.height;
|
||||
size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT));
|
||||
size.width += padding.width;
|
||||
size.height += padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2099,18 +2099,18 @@ struct SavePresetWindow : public Window {
|
||||
{
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SVP_PRESET_LIST: {
|
||||
resize->height = GetCharacterHeight(FS_NORMAL);
|
||||
size->height = 0;
|
||||
resize.height = GetCharacterHeight(FS_NORMAL);
|
||||
size.height = 0;
|
||||
for (uint i = 0; i < this->presets.size(); i++) {
|
||||
Dimension d = GetStringBoundingBox(this->presets[i]);
|
||||
size->width = std::max(size->width, d.width + padding.width);
|
||||
resize->height = std::max(resize->height, d.height);
|
||||
size.width = std::max(size.width, d.width + padding.width);
|
||||
resize.height = std::max(resize.height, d.height);
|
||||
}
|
||||
size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + padding.height;
|
||||
size.height = ClampU((uint)this->presets.size(), 5, 20) * resize.height + padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2214,15 +2214,15 @@ struct ScanProgressWindow : public Window {
|
||||
this->InitNested(1);
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SP_PROGRESS_BAR: {
|
||||
SetDParamMaxValue(0, 100);
|
||||
*size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
|
||||
size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
|
||||
/* We need some spacing for the 'border' */
|
||||
size->height += WidgetDimensions::scaled.frametext.Horizontal();
|
||||
size->width += WidgetDimensions::scaled.frametext.Vertical();
|
||||
size.height += WidgetDimensions::scaled.frametext.Horizontal();
|
||||
size.width += WidgetDimensions::scaled.frametext.Vertical();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2231,8 +2231,8 @@ struct ScanProgressWindow : public Window {
|
||||
SetDParamMaxDigits(1, 4);
|
||||
/* We really don't know the width. We could determine it by scanning the NewGRFs,
|
||||
* but this is the status window for scanning them... */
|
||||
size->width = std::max<uint>(size->width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width);
|
||||
size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
|
||||
size.width = std::max<uint>(size.width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width);
|
||||
size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user