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

Fix #9743: Rework macOS Touchbar. #9776

Merged
merged 5 commits into from Jan 1, 2022
Merged

Conversation

michicc
Copy link
Member

@michicc michicc commented Dec 31, 2021

Motivation / Problem

The current touch bar implementation has several problems, see #9743, and is also needlessly limited to macOS 10.15+.

Description

Touchbar sprites are now (re-)created by using the existing PopulateSystemSprites/ClearSystemSprites functionality which ensures sprites are only accessed when loaded and are re-created on graphics changes.
Sprites are created using the highest available zoom level, which should avoid crashes on reduced zoom ranges but still provide the best possible image resolution.

While at it, do some code cleanup and extend DrawSpriteToRgbaBuffer to work for 8bpp blitters as well.

(Side note: The first commit is mainly so I could even test this.)

Limitations

The button texts for no/invalid sprites are not translated, but as they should never be shown with an intact baseset, I consider translating them just busywork. If requested, changing this would not be too difficult, though.

Only tested using the Xcode touchbar simulator on 10.14, not with any real hardware. As the original implementation was 10.15+ only, I can't compare if my changes introduce any graphical or functional differences.

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 touches english.txt or translations? Check the guidelines
  • 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')

Touchbar support was introduced in 10.12.2. There's no need to limit
support to 10.15+, as the convenience class NSButtonTouchBarItem is
easily replicated.
@michicc michicc added OS: MacOS This issue is related to a Mac OS problem backport requested This PR should be backport to current release (RC / stable) labels Dec 31, 2021
src/gfx.cpp Outdated Show resolved Hide resolved
src/gfx.cpp Outdated Show resolved Hide resolved
src/video/cocoa/cocoa_wnd.mm Outdated Show resolved Hide resolved
@michicc michicc merged commit 57b9927 into OpenTTD:master Jan 1, 2022
@michicc michicc deleted the pr/fix_9743 branch January 1, 2022 11:19
@TrueBrain TrueBrain added backported This PR is backported to a current release (RC / stable) and removed backport requested This PR should be backport to current release (RC / stable) labels Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR is backported to a current release (RC / stable) OS: MacOS This issue is related to a Mac OS problem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants