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 label Apr 23, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 Apr 23, 2021 Inactive
@glx22
Copy link
Contributor

@glx22 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 Apr 24, 2021 Inactive
@PeterN
Copy link
Member Author

@PeterN 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.

@PeterN PeterN force-pushed the update-scaling branch from 039685c to 42d0b22 Apr 24, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 Apr 24, 2021 Inactive
src/network/network_gui.cpp Outdated Show resolved Hide resolved
src/window_func.h Show resolved Hide resolved
@PeterN PeterN force-pushed the update-scaling branch from 42d0b22 to 0052535 Apr 24, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 Apr 24, 2021 Inactive
@DorpsGek DorpsGek temporarily deployed to preview-pr-9087 Apr 25, 2021 Inactive
src/widget_type.h Outdated Show resolved Hide resolved
PeterN added 2 commits Apr 29, 2021
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.
@PeterN PeterN merged commit 49aa392 into OpenTTD:master Apr 30, 2021
12 checks passed
@PeterN PeterN deleted the update-scaling branch Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants