[#4808] Fix screenshot OSD layout issue #4897
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
IINA resizes screenshot
NSImage
before passing it to OSD for previewing with a fixed expectation size[300, 200]
. The resizing strategy is implemented inNSSize#shrink
, which guarantees the shrunken width or height to be given value, and decreasing the other side while keeping the image aspect.This works in most cases except the reported one which has a
1:1
ratio. So by the shrinking rule, it will be resized to[200, 200]
, which breaks the layout rule since OSD View expects a minimum width to place action buttons.Replacing the strategy to
NSSize#grow
ensures the resizedwidth >= 300
and resolves layout warnings.Grow strategy for
1:1
ratio image:Shrink strategy for
1:1
ratio image:For those normal images close to
3:2
ratio, this fix shouldn't cause any significant visual changes.Off topic: I noticed that there's a typo in ScreenshootOSDView class name. Wanted to fix it but I'm a little worried that it might break the localization.