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

[#4808] Fix screenshot OSD layout issue #4897

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

yuxiqian
Copy link
Contributor

@yuxiqian yuxiqian commented Apr 27, 2024


IINA resizes screenshot NSImage before passing it to OSD for previewing with a fixed expectation size [300, 200]. The resizing strategy is implemented in NSSize#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 resized width >= 300 and resolves layout warnings.

Grow strategy for 1:1 ratio image:

grow

Shrink strategy for 1:1 ratio image:
shrink

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.

@low-batt low-batt linked an issue Apr 27, 2024 that may be closed by this pull request
1 task
Copy link
Member

@uiryuu uiryuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using shrink here is to ensure that the image displayed in the accessoryView is constrained by the size [200, 300]. When the aspect ratio of the video is very unbalanced, the accessoryView could be very large if using grow. An extreme example:

Using grow:
image

Using shrink:
image

I suggest find a different approach to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conflicting constraints detected when taking a screenshot
2 participants