Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 0cae124

Browse files
committed
HDR: Add Enable HDR mode by default preference checkbox
Ref: iina#3808
1 parent f14fe33 commit 0cae124

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

iina/Base.lproj/PrefCodecViewController.xib

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@
2727
</customView>
2828
<userDefaultsController representsSharedInstance="YES" id="pxc-7C-SGP"/>
2929
<customView id="gZf-gF-XoY">
30-
<rect key="frame" x="0.0" y="0.0" width="444" height="202"/>
30+
<rect key="frame" x="0.0" y="0.0" width="444" height="254"/>
3131
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
3232
<subviews>
3333
<textField identifier="SectionTitleVideo" horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2BH-mP-kfr">
34-
<rect key="frame" x="-2" y="178" width="46" height="16"/>
34+
<rect key="frame" x="-2" y="230" width="46" height="16"/>
3535
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Video:" id="m5P-5f-5uo">
3636
<font key="font" metaFont="systemBold"/>
3737
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
3838
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
3939
</textFieldCell>
4040
</textField>
4141
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="paR-ax-h5M">
42-
<rect key="frame" x="118" y="178" width="122" height="16"/>
42+
<rect key="frame" x="118" y="230" width="122" height="16"/>
4343
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Number of threads:" id="50C-1R-wlJ">
4444
<font key="font" metaFont="system"/>
4545
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
4646
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
4747
</textFieldCell>
4848
</textField>
4949
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NZA-64-tXh">
50-
<rect key="frame" x="246" y="175" width="58" height="21"/>
50+
<rect key="frame" x="246" y="227" width="58" height="21"/>
5151
<constraints>
5252
<constraint firstAttribute="width" constant="58" id="GLI-3U-bmm"/>
5353
</constraints>
@@ -68,15 +68,15 @@
6868
</connections>
6969
</textField>
7070
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kas-7q-TbK">
71-
<rect key="frame" x="312" y="178" width="92" height="14"/>
71+
<rect key="frame" x="312" y="230" width="92" height="14"/>
7272
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Default: 0 (Auto)" id="bxW-np-SGm">
7373
<font key="font" metaFont="label" size="11"/>
7474
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
7575
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
7676
</textFieldCell>
7777
</textField>
7878
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EWs-Ib-pVZ">
79-
<rect key="frame" x="243" y="139" width="127" height="25"/>
79+
<rect key="frame" x="243" y="191" width="127" height="25"/>
8080
<constraints>
8181
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="120" id="P27-F4-Ogg"/>
8282
</constraints>
@@ -97,23 +97,23 @@
9797
</connections>
9898
</popUpButton>
9999
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="0Re-PY-hmC">
100-
<rect key="frame" x="118" y="128" width="328" height="14"/>
100+
<rect key="frame" x="118" y="180" width="328" height="14"/>
101101
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="Label" id="n3r-mP-f8V">
102102
<font key="font" metaFont="label" size="11"/>
103103
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
104104
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
105105
</textFieldCell>
106106
</textField>
107107
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4rB-d2-drE">
108-
<rect key="frame" x="118" y="146" width="122" height="16"/>
108+
<rect key="frame" x="118" y="198" width="122" height="16"/>
109109
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Hardware decoder:" id="nwg-2K-G2G">
110110
<font key="font" metaFont="system"/>
111111
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
112112
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
113113
</textFieldCell>
114114
</textField>
115115
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xXS-nP-Chk">
116-
<rect key="frame" x="118" y="99" width="156" height="18"/>
116+
<rect key="frame" x="118" y="151" width="156" height="18"/>
117117
<buttonCell key="cell" type="check" title="Force dedicated GPU" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="YUr-aJ-xfC">
118118
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
119119
<font key="font" metaFont="system"/>
@@ -123,15 +123,15 @@
123123
</connections>
124124
</button>
125125
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="40Z-9R-jw0">
126-
<rect key="frame" x="118" y="68" width="328" height="28"/>
126+
<rect key="frame" x="118" y="120" width="328" height="28"/>
127127
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="Always use the dedicated GPU for rendering (if it exists). This can improve performance but may reduce battery life." id="gCv-sJ-uQJ">
128128
<font key="font" metaFont="label" size="11"/>
129129
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
130130
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
131131
</textFieldCell>
132132
</textField>
133133
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="H9a-N4-xDt">
134-
<rect key="frame" x="118" y="43" width="124" height="18"/>
134+
<rect key="frame" x="118" y="95" width="124" height="18"/>
135135
<buttonCell key="cell" type="check" title="Load ICC profile" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="3g4-jW-uJd">
136136
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
137137
<font key="font" metaFont="system"/>
@@ -141,28 +141,50 @@
141141
</connections>
142142
</button>
143143
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="IQ8-K4-5CX">
144-
<rect key="frame" x="118" y="12" width="328" height="28"/>
144+
<rect key="frame" x="118" y="64" width="328" height="28"/>
145145
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="Load the ICC profile for current display and use it to transform video RGB to screen output. (Only for SDR mode)" id="M2M-of-gjd">
146146
<font key="font" metaFont="label" size="11"/>
147147
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
148148
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
149149
</textFieldCell>
150150
</textField>
151+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="VBh-HJ-Hsl">
152+
<rect key="frame" x="118" y="8" width="328" height="28"/>
153+
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="Enable HDR mode when playing HDR videos. Uncheck this button if you encounter any issues." id="AF3-Hf-nll">
154+
<font key="font" metaFont="label" size="11"/>
155+
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
156+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
157+
</textFieldCell>
158+
</textField>
159+
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jf6-xG-UF1">
160+
<rect key="frame" x="118" y="39" width="200" height="18"/>
161+
<buttonCell key="cell" type="check" title="Enable HDR mode by default" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="oMN-7X-c5d">
162+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
163+
<font key="font" metaFont="system"/>
164+
</buttonCell>
165+
<connections>
166+
<binding destination="pxc-7C-SGP" name="value" keyPath="values.enableHdrModeByDefault" id="f2o-kZ-XHF"/>
167+
</connections>
168+
</button>
151169
</subviews>
152170
<constraints>
153171
<constraint firstItem="4rB-d2-drE" firstAttribute="baseline" secondItem="EWs-Ib-pVZ" secondAttribute="baseline" id="0Wl-YU-BME"/>
154172
<constraint firstItem="2BH-mP-kfr" firstAttribute="top" secondItem="gZf-gF-XoY" secondAttribute="top" constant="8" id="0jh-iZ-prT"/>
155173
<constraint firstItem="40Z-9R-jw0" firstAttribute="leading" secondItem="xXS-nP-Chk" secondAttribute="leading" id="1of-sZ-BN6"/>
156174
<constraint firstItem="0Re-PY-hmC" firstAttribute="top" secondItem="4rB-d2-drE" secondAttribute="bottom" constant="4" id="5Mm-wm-VFG"/>
157-
<constraint firstAttribute="bottom" secondItem="IQ8-K4-5CX" secondAttribute="bottom" constant="12" id="6dx-e8-7Ck"/>
175+
<constraint firstItem="VBh-HJ-Hsl" firstAttribute="leading" secondItem="jf6-xG-UF1" secondAttribute="leading" id="6Rg-Ag-e6J"/>
176+
<constraint firstItem="jf6-xG-UF1" firstAttribute="top" secondItem="IQ8-K4-5CX" secondAttribute="bottom" constant="8" id="6dx-e8-7Ck"/>
158177
<constraint firstItem="40Z-9R-jw0" firstAttribute="top" secondItem="xXS-nP-Chk" secondAttribute="bottom" constant="4" id="87O-GK-HSl"/>
159178
<constraint firstAttribute="trailing" secondItem="IQ8-K4-5CX" secondAttribute="trailing" id="ASv-Wn-ieW"/>
160179
<constraint firstItem="4rB-d2-drE" firstAttribute="leading" secondItem="paR-ax-h5M" secondAttribute="leading" id="Can-oM-yLm"/>
161180
<constraint firstItem="EWs-Ib-pVZ" firstAttribute="leading" secondItem="4rB-d2-drE" secondAttribute="trailing" constant="8" id="Fj7-lr-KGg"/>
181+
<constraint firstItem="jf6-xG-UF1" firstAttribute="leading" secondItem="IQ8-K4-5CX" secondAttribute="leading" id="Fs9-LQ-Ic9"/>
162182
<constraint firstAttribute="trailing" secondItem="0Re-PY-hmC" secondAttribute="trailing" id="HJH-5L-Dd4"/>
163183
<constraint firstItem="2BH-mP-kfr" firstAttribute="trailing" relation="lessThanOrEqual" secondItem="gZf-gF-XoY" secondAttribute="leading" constant="120" id="KBf-6v-pL9"/>
164184
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xXS-nP-Chk" secondAttribute="trailing" constant="12" id="QNu-hr-TdO"/>
165185
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="H9a-N4-xDt" secondAttribute="trailing" constant="12" id="TxZ-c7-rVn"/>
186+
<constraint firstAttribute="bottom" secondItem="VBh-HJ-Hsl" secondAttribute="bottom" constant="8" id="TzG-w4-Xy4"/>
187+
<constraint firstItem="VBh-HJ-Hsl" firstAttribute="top" secondItem="jf6-xG-UF1" secondAttribute="bottom" constant="4" id="Unp-3s-Prn"/>
166188
<constraint firstItem="IQ8-K4-5CX" firstAttribute="top" secondItem="H9a-N4-xDt" secondAttribute="bottom" constant="4" id="W29-Gj-v7X"/>
167189
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="kas-7q-TbK" secondAttribute="trailing" constant="20" symbolic="YES" id="XnT-jM-uWw"/>
168190
<constraint firstItem="paR-ax-h5M" firstAttribute="top" secondItem="2BH-mP-kfr" secondAttribute="top" id="ZwF-7T-SvE"/>
@@ -171,19 +193,21 @@
171193
<constraint firstItem="IQ8-K4-5CX" firstAttribute="leading" secondItem="H9a-N4-xDt" secondAttribute="leading" id="cpx-2e-hcB"/>
172194
<constraint firstItem="xXS-nP-Chk" firstAttribute="top" secondItem="0Re-PY-hmC" secondAttribute="bottom" constant="12" id="fO3-5j-FCq"/>
173195
<constraint firstItem="paR-ax-h5M" firstAttribute="leading" secondItem="gZf-gF-XoY" secondAttribute="leading" constant="120" id="fWo-4I-DAC"/>
196+
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="jf6-xG-UF1" secondAttribute="trailing" constant="12" id="fvX-Px-0Pz"/>
174197
<constraint firstItem="NZA-64-tXh" firstAttribute="baseline" secondItem="paR-ax-h5M" secondAttribute="baseline" id="hly-ga-NBA"/>
175198
<constraint firstItem="EWs-Ib-pVZ" firstAttribute="leading" secondItem="NZA-64-tXh" secondAttribute="leading" id="k0a-vZ-1e2"/>
176199
<constraint firstItem="NZA-64-tXh" firstAttribute="leading" secondItem="paR-ax-h5M" secondAttribute="trailing" constant="8" id="mRg-ce-YRy"/>
177200
<constraint firstItem="2BH-mP-kfr" firstAttribute="leading" secondItem="gZf-gF-XoY" secondAttribute="leading" id="pDP-Rm-tDg"/>
178201
<constraint firstItem="0Re-PY-hmC" firstAttribute="leading" secondItem="4rB-d2-drE" secondAttribute="leading" id="q9a-bj-3IP"/>
179202
<constraint firstItem="4rB-d2-drE" firstAttribute="top" secondItem="paR-ax-h5M" secondAttribute="bottom" constant="16" id="rCv-37-pHD"/>
180203
<constraint firstItem="kas-7q-TbK" firstAttribute="baseline" secondItem="paR-ax-h5M" secondAttribute="baseline" id="rWF-ZF-Tlb"/>
204+
<constraint firstAttribute="trailing" secondItem="VBh-HJ-Hsl" secondAttribute="trailing" id="sqM-h5-Xgo"/>
181205
<constraint firstAttribute="trailing" secondItem="40Z-9R-jw0" secondAttribute="trailing" id="u8t-cI-LR5"/>
182206
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="EWs-Ib-pVZ" secondAttribute="trailing" constant="20" symbolic="YES" id="uSA-lp-egl"/>
183207
<constraint firstItem="H9a-N4-xDt" firstAttribute="top" secondItem="40Z-9R-jw0" secondAttribute="bottom" constant="8" id="w3M-iD-Ho3"/>
184208
<constraint firstItem="H9a-N4-xDt" firstAttribute="leading" secondItem="40Z-9R-jw0" secondAttribute="leading" id="ybt-SY-BgR"/>
185209
</constraints>
186-
<point key="canvasLocation" x="783" y="394.5"/>
210+
<point key="canvasLocation" x="783" y="439.5"/>
187211
</customView>
188212
<customView id="bsP-Kc-xXR">
189213
<rect key="frame" x="0.0" y="0.0" width="480" height="192"/>

iina/PlayerCore.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class PlayerCore: NSObject {
221221
if shouldAutoLoad {
222222
info.shouldAutoLoadFiles = true
223223
}
224+
info.hdrEnabled = Preference.bool(for: .enableHdrModeByDefault)
224225
let path = isNetwork ? url.absoluteString : url.path
225226
openMainWindow(path: path, url: url, isNetwork: isNetwork)
226227
}

iina/Preference.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct Preference {
150150
static let hardwareDecoder = Key("hardwareDecoder")
151151
static let forceDedicatedGPU = Key("forceDedicatedGPU")
152152
static let loadIccProfile = Key("loadIccProfile")
153+
static let enableHdrModeByDefault = Key("enableHdrModeByDefault")
153154

154155
static let audioThreads = Key("audioThreads")
155156
static let audioLanguage = Key("audioLanguage")
@@ -728,6 +729,7 @@ struct Preference {
728729
.hardwareDecoder: HardwareDecoderOption.auto.rawValue,
729730
.forceDedicatedGPU: false,
730731
.loadIccProfile: true,
732+
.enableHdrModeByDefault: true,
731733
.audioThreads: 0,
732734
.audioLanguage: "",
733735
.maxVolume: 100,

iina/zh-Hans.lproj/PrefCodecViewController.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@
5454

5555
/* Class = "NSButtonCell"; title = "Load ICC profile"; ObjectID = "3g4-jW-uJd"; */
5656
"3g4-jW-uJd.title" = "加载ICC色彩特性文件";
57+
58+
/* Class = "NSButtonCell"; title = "Enable HDR mode by default"; ObjectID = "oMN-7X-c5d"; */
59+
"oMN-7X-c5d.title" = "默认启用HDR模式";

0 commit comments

Comments
 (0)