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

Update window scaling #9087

Merged
merged 20 commits into from Apr 30, 2021
Merged

Update window scaling #9087

merged 20 commits into from Apr 30, 2021

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Apr 23, 2021

Motivation / Problem

Many windows do not resize properly, either they use hardcoded pixel sizes which do not scale, or they are set up once when opening and not when if the (admittedly rarely) GUI/Font zoom options are changed.

This is a set of patches that... escalated from trying to fix the issue of padding size not being adjusted, and may perhaps need splitting up.

Description

The core functionality is achieved by the parameters to SetPIP/SetPadding/SetMinimalSize/SetMinimalTextLines methods (and therefore from NWidgetParts) is stored within the runtime widget data, allowing it to be reprocessed and adjusted for the current gui/font size setting. This is done rather than reprocessing the NWidgetParts because that would not work for dynamically created widgets.

Because these calls now expect unscaled values, some calls where sprite sizes are used had to be adjusted to get the unzoomed (OUT_4X) sprite size instead.

Additional numerous fixes to layout and padding is also included as separate changes, some of these are independent of this core change, but a few others are dependent on it.

Limitations

Currently vertical scrollbar width varies depending on which widgets they are arranged with. This should probably be fixed by forcing the largest size for all.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@glx22 glx22 added the preview This PR is receiving preview builds label Apr 23, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 April 23, 2021 22:54 Inactive
@glx22
Copy link
Contributor

glx22 commented Apr 23, 2021

Many warnings reported in last commit.

I also enabled preview for this PR.

@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 April 24, 2021 07:51 Inactive
@PeterN
Copy link
Member Author

PeterN commented Apr 24, 2021

Many warnings reported in last commit.

Ah, adding override specifier when it's missing from existing overrides. For some reason MSVC isn't warning.

@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 April 24, 2021 16:29 Inactive
src/network/network_gui.cpp Outdated Show resolved Hide resolved
src/window_func.h Show resolved Hide resolved
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 April 24, 2021 18:40 Inactive
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 April 25, 2021 12:48 Inactive
src/widget_type.h Outdated Show resolved Hide resolved
Replaces constant pixel values with values scaled based on font size.
This allows the industry chain to maintain a consistent look across
different sizes. Previously all except cargo line height were fixed.
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 April 29, 2021 21:31 Inactive
@PeterN PeterN merged commit 49aa392 into OpenTTD:master Apr 30, 2021
@PeterN PeterN deleted the update-scaling branch April 30, 2021 16:08
PeterN added a commit to PeterN/OpenTTD that referenced this pull request Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview This PR is receiving preview builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants