Skip to content

Add live update of color-related options in Settings > Codec, enforce valid values #5204

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

Merged
merged 3 commits into from
Oct 26, 2024

Conversation

svobs
Copy link
Contributor

@svobs svobs commented Oct 10, 2024


Description:

  • Adds monitoring of the 4 color mapping related pref settings to PlayerWindowController and reloads them when changed, so the user doesn't have to quit & reopen IINA to guarantee they take effect.
  • Modifies VideoView.refreshEdrMode so it doesn't cancel other changes if colorspace is already set, so the above can take effect.
  • Add action to PrefCodecViewController to restrict Target peak user entry to valid values, instead of silently failing & using 400.

The affected settings:
Affected settings

@uiryuu uiryuu requested a review from low-batt October 10, 2024 05:13
Copy link
Contributor

@low-batt low-batt left a comment

Choose a reason for hiding this comment

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

Glad you are enhancing this setting.

I'm thinking this needs to put up an alert for invalid values similar to other settings.

@IBAction func toneMappingTargetPeakAction(_ sender: NSTextField) {
let newValue = sender.integerValue
// constrain to valid mpv values
let validValue = newValue == 0 ? 0 : newValue.clamped(to: 10...10000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Merely constraining the value is not the convention used when the user enters invalid values for other settings. Trying entering -1. Other settings pop-up an alert box.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kinda loathe the built-in modal popup. It's a really old paradigm, it's obtrusive, and not even very helpful. It doesn't tell the user what the valid values actually are, and if they choose the OK button the field is allowed to be left blank, which leaves them guessing about the current value. At least the clamped approach chooses the closest valid value, and doesn't even require reading.

Also...I actually don't know how to make the built-in popup work for 0 because it's outside the contiguous range of 10-10,000. As far as I can tell, the popup is provided via the text field cell's NumberFormatter, which checks against accepted min and max only. I don't see any places to hook into or override it to provide more complex validation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I didn't mean to imply we needed to use the alert provided by AppKit. I was expecting we would use Utility.showAlert to show our own alert with the appropriate information about what values are allowed.

I agree, the one provided by NumberFormatter can't be used due to the lack of a contiguous range. And yes, I too dislike the lack of info in the alert NumberFormatter provides.

Copy link
Contributor

Choose a reason for hiding this comment

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

@svobs Still waiting for an alert to be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed an update which uses an alert instead. I tried to mimic Apple's alert mostly, but it has only an OK button and resets the field to the current (valid) prefs value.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good:
alert

@svobs svobs force-pushed the pr-live-update-codec-color-settings branch from 6274213 to cbd0c0c Compare October 23, 2024 09:54
Copy link
Contributor

@low-batt low-batt left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@uiryuu uiryuu merged commit 9f2c6ee into iina:develop Oct 26, 2024
2 checks passed
@@ -245,6 +245,8 @@
"alert.error_saving_file" = "Error occurred when saving %@: %@";
"alert.error_deleting_file" = "Cannot delete the file.";

"alert.target_peak.bad_value" = "The value \"%@\" is invalid.\nPlease provide a value betwen 10 and 10000, or 0.";
Copy link
Member

Choose a reason for hiding this comment

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

Between. Not sure why we have a typos CI job if it can’t catch these…

Copy link
Member

Choose a reason for hiding this comment

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

I think that only checks for typos in code and comments

MouJieQin pushed a commit to MouJieQin/iina-for-varchive that referenced this pull request Oct 27, 2024
… valid values (iina#5204)

* Add live update of ICC profile, tone mapping, target peak, algorithm options in Settings > Codec
* Display alert when Target Peak is invalid instead of auto correcting
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.

4 participants