mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-20 19:02:41 +01:00
Fix: Mis-sized widgets due to missing widget fill. (#14370)
In most places where we calculate and set widget resize step we neglect to set widget fill step to match. Initial widget sizing uses fill step instead of resize step, which means the initial size may not be a multiple of the resize step as intended. In particular this will cause WWT_MATRIX to be misrendered. Whether or not this matters depends on the widget type being resized and the window layout, however for consistency always set fill step to the same as resize step when calculating.
This commit is contained in:
@@ -224,7 +224,7 @@ struct NewGRFParametersWindow : public Window {
|
||||
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
|
||||
resize.width = 1;
|
||||
resize.height = this->line_height;
|
||||
fill.height = resize.height = this->line_height;
|
||||
size.height = 5 * this->line_height;
|
||||
break;
|
||||
|
||||
@@ -730,7 +730,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
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));
|
||||
fill.height = resize.height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
|
||||
size.height = std::max(size.height, padding.height + 6 * resize.height);
|
||||
break;
|
||||
}
|
||||
@@ -738,7 +738,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
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));
|
||||
fill.height = resize.height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
|
||||
size.height = std::max(size.height, padding.height + 8 * resize.height);
|
||||
break;
|
||||
}
|
||||
@@ -2041,12 +2041,11 @@ struct SavePresetWindow : public Window {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SVP_PRESET_LIST: {
|
||||
resize.height = GetCharacterHeight(FS_NORMAL);
|
||||
fill.height = 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.height = ClampU((uint)this->presets.size(), 5, 20) * resize.height + padding.height;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user