Add preference to choose between SceneKit and DDB spectrum.

lastfm
Dzmitry Neviadomski 2022-07-05 13:12:34 +03:00 committed by Christopher Snowhill
parent 45ec7b6263
commit 0dc31808e7
3 changed files with 33 additions and 17 deletions

View File

@ -555,6 +555,7 @@ static AppController *kAppController = nil;
NSData *barColor = [colorToValueTransformer reverseTransformedValue:[NSColor colorWithSRGBRed:1.0 green:0.5 blue:0 alpha:1.0]];
NSData *dotColor = [colorToValueTransformer reverseTransformedValue:[NSColor systemRedColor]];
[userDefaultsValuesDict setObject:@(YES) forKey:@"spectrumSceneKit"];
[userDefaultsValuesDict setObject:barColor forKey:@"spectrumBarColor"];
[userDefaultsValuesDict setObject:dotColor forKey:@"spectrumDotColor"];

View File

@ -363,7 +363,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" id="gUE-Yu-LLA">
<rect key="frame" x="1" y="1" width="488" height="113"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="automatic" headerView="9rQ-Rq-K6J" viewBased="YES" id="gHG-xw-OyR">
<rect key="frame" x="0.0" y="0.0" width="488" height="85"/>
@ -385,7 +385,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="EEt-uJ-j6o">
<rect key="frame" x="8" y="0.0" width="386" height="24"/>
<rect key="frame" x="18" y="0.0" width="386" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7l9-R2-FVF">
@ -420,7 +420,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="EDi-gi-Vg9">
<rect key="frame" x="411" y="0.0" width="38" height="24"/>
<rect key="frame" x="421" y="0.0" width="38" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0TJ-dK-Rfk">
@ -510,12 +510,12 @@
<point key="canvasLocation" x="450" y="-52.5"/>
</customView>
<customView id="CgN-sy-RmM" userLabel="AppearanceView">
<rect key="frame" x="0.0" y="0.0" width="530" height="162"/>
<rect key="frame" x="0.0" y="0.0" width="530" height="193"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="haX-dq-OIe">
<rect key="frame" x="18" y="125" width="492" height="18"/>
<autoresizingMask key="autoresizingMask"/>
<rect key="frame" x="18" y="156" width="492" height="18"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Colorful dock icons" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="GdX-5e-NeU">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -525,8 +525,8 @@
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AA7-fr-NOk">
<rect key="frame" x="18" y="98" width="492" height="18"/>
<autoresizingMask key="autoresizingMask"/>
<rect key="frame" x="18" y="130" width="492" height="18"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Show stop button" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="vMI-lj-Lrz">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -536,18 +536,30 @@
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4xb-C2-wmz">
<rect key="frame" x="18" y="70" width="492" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<rect key="frame" x="40" y="78" width="470" height="18"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Spectrum 2D view" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="gXL-j6-df0">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="enabled" keyPath="values.spectrumSceneKit" id="frQ-l7-tCE"/>
<binding destination="52" name="value" keyPath="values.spectrumProjectionMode" id="UGh-1j-iFC"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="t6C-Va-hmO" userLabel="Use SceneKit">
<rect key="frame" x="18" y="104" width="108" height="18"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Use SceneKit" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="NMg-TO-amV">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.spectrumSceneKit" id="BDn-Jh-OUt"/>
</connections>
</button>
<colorWell fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7hw-NI-bF1">
<rect key="frame" x="20" y="40" width="44" height="23"/>
<rect key="frame" x="20" y="48" width="44" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="color" red="0.05813049898" green="0.055541899059999997" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
@ -559,8 +571,8 @@
</connections>
</colorWell>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1Xc-Cr-icC">
<rect key="frame" x="70" y="43" width="442" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<rect key="frame" x="70" y="51" width="442" height="16"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Spectrum bars" id="Bll-IJ-lje">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -568,7 +580,7 @@
</textFieldCell>
</textField>
<colorWell fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WjH-M4-Gqf">
<rect key="frame" x="20" y="12" width="44" height="23"/>
<rect key="frame" x="20" y="20" width="44" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="color" red="0.05813049898" green="0.055541899059999997" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<connections>
@ -580,8 +592,8 @@
</connections>
</colorWell>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ahQ-bv-j9g">
<rect key="frame" x="70" y="15" width="442" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<rect key="frame" x="70" y="23" width="442" height="16"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Spectrum peaks" id="CQI-YZ-B3V">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -589,7 +601,7 @@
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="450" y="183"/>
<point key="canvasLocation" x="450" y="198.5"/>
</customView>
<customView wantsLayer="YES" id="JXu-ar-J3Y" userLabel="MIDIView">
<rect key="frame" x="0.0" y="0.0" width="530" height="244"/>

View File

@ -48,6 +48,9 @@ extern NSString *CogPlaybackDidStopNotficiation;
@implementation SpectrumViewSK
+ (SpectrumViewSK *)createGuardWithFrame:(NSRect)frame {
if (![NSUserDefaults.standardUserDefaults boolForKey:@"spectrumSceneKit"])
return nil;
do {
if(@available(macOS 11.0, *)) {
// macOS 11 and newer seems to be safe