Remember artworks size in the artwork selector view

This commit is contained in:
Damiano Galassi committed 2024-11-29 13:24:24 +01:00
1 parent 2d0cb8b827
commit b022bb460d
3 files changed
+22 -13

No files matched your search

+13 -8
View File
@@ -205,9 +205,9 @@ final class ArtworkSelectorController: NSViewController, NSCollectionViewDataSou
} }
override func viewWillAppear() { override func viewWillAppear() {
if let layout = imageBrowser.collectionViewLayout as? NSCollectionViewFlowLayout { let zoomValue = Prefs.artworkSelectorZoomLevel
layout.itemSize = standardSize setZoomValue(zoomValue)
} slider.floatValue = zoomValue
} }
@IBAction func loadMoreArtwork(_ sender: Any) { @IBAction func loadMoreArtwork(_ sender: Any) {
@@ -216,23 +216,28 @@ final class ArtworkSelectorController: NSViewController, NSCollectionViewDataSou
// MARK: - User Interface // MARK: - User Interface
@IBAction func zoomSliderDidChange(_ sender: Any) { func setZoomValue(_ newZoomValue: Float) {
if let layout = imageBrowser.collectionViewLayout as? NSCollectionViewFlowLayout { if let layout = imageBrowser.collectionViewLayout as? NSCollectionViewFlowLayout {
if slider.floatValue == 50 { if newZoomValue == 50 {
layout.itemSize = standardSize layout.itemSize = standardSize
} else if slider.floatValue < 50 { } else if newZoomValue < 50 {
let zoomValue = (CGFloat(slider.floatValue) + 50) / 100 let zoomValue = (CGFloat(newZoomValue) + 50) / 100
layout.itemSize = NSSize(width: Int(standardSize.width * zoomValue), layout.itemSize = NSSize(width: Int(standardSize.width * zoomValue),
height: Int((standardSize.height - 32) * zoomValue + 32)) height: Int((standardSize.height - 32) * zoomValue + 32))
} else { } else {
let zoomValue = pow((CGFloat(slider.floatValue) + 50) / 100, 2.4) let zoomValue = pow((CGFloat(newZoomValue) + 50) / 100, 2.4)
layout.itemSize = NSSize(width: Int(standardSize.width * zoomValue), layout.itemSize = NSSize(width: Int(standardSize.width * zoomValue),
height: Int((standardSize.height - 32) * zoomValue + 32)) height: Int((standardSize.height - 32) * zoomValue + 32))
} }
} }
} }
@IBAction func zoomSliderDidChange(_ sender: Any) {
setZoomValue(slider.floatValue)
Prefs.artworkSelectorZoomLevel = slider.floatValue
}
fileprivate func reloadItem(_ item: ArtworkImageObject) { fileprivate func reloadItem(_ item: ArtworkImageObject) {
let selectionIndexPaths = imageBrowser.selectionIndexPaths let selectionIndexPaths = imageBrowser.selectionIndexPaths
+4 -4
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@@ -19,7 +19,7 @@
<rect key="frame" x="0.0" y="0.0" width="128" height="171"/> <rect key="frame" x="0.0" y="0.0" width="128" height="171"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<textField wantsLayer="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wkh-6c-0tU" customClass="ArtworkSelectorViewItemLabel" customModule="Subler" customModuleProvider="target"> <textField wantsLayer="YES" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wkh-6c-0tU" customClass="ArtworkSelectorViewItemLabel" customModule="Subler" customModuleProvider="target">
<rect key="frame" x="-4" y="17" width="136" height="15"/> <rect key="frame" x="-4" y="17" width="136" height="15"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" alignment="center" title="Label" usesSingleLineMode="YES" id="TsL-Ak-xnf"> <textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" alignment="center" title="Label" usesSingleLineMode="YES" id="TsL-Ak-xnf">
<font key="font" metaFont="cellTitle"/> <font key="font" metaFont="cellTitle"/>
@@ -27,7 +27,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField wantsLayer="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fGU-Kh-WjD"> <textField wantsLayer="YES" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fGU-Kh-WjD">
<rect key="frame" x="-4" y="4" width="136" height="13"/> <rect key="frame" x="-4" y="4" width="136" height="13"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" alignment="center" title="Label" usesSingleLineMode="YES" id="ggX-Q2-CZ0"> <textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" alignment="center" title="Label" usesSingleLineMode="YES" id="ggX-Q2-CZ0">
<font key="font" metaFont="system" size="10"/> <font key="font" metaFont="system" size="10"/>
+5 -1
View File
@@ -151,6 +151,9 @@ enum Prefs {
@Stored(key: "SBForceHvc1", defaultValue: true) @Stored(key: "SBForceHvc1", defaultValue: true)
static var forceHvc1: Bool static var forceHvc1: Bool
@Stored(key: "SBArtworkSelectorZoomLevel", defaultValue: 50)
static var artworkSelectorZoomLevel: Float
} }
enum MetadataPrefs { enum MetadataPrefs {
@@ -158,7 +161,8 @@ enum MetadataPrefs {
static func register() { static func register() {
ud.register(defaults: [_setMovieFormat, _setTVShowFormat, ud.register(defaults: [_setMovieFormat, _setTVShowFormat,
_movieImporter, _movieiTunesStoreLanguage, _movieImporter, _movieiTunesStoreLanguage,
_tvShowImporter, _tvShowiTunesStoreLanguage, _tvShowTheTVDBLanguage, _tvShowTheMovieDBLanguage, _tvShowImporter, _tvShowiTunesStoreLanguage,
_tvShowTheTVDBLanguage, _tvShowTheMovieDBLanguage,
_keepEmptyAnnotations, _keepImportedFilesMetadata]) _keepEmptyAnnotations, _keepImportedFilesMetadata])
} }