Remember artworks size in the movie view

This commit is contained in:
Damiano Galassi committed 2024-11-29 13:32:36 +01:00
1 parent b022bb460d
commit 8bbb34298a
4 files changed
+36 -21

No files matched your search

+1 -1
View File
@@ -216,7 +216,7 @@ final class ArtworkSelectorController: NSViewController, NSCollectionViewDataSou
// MARK: - User Interface
func setZoomValue(_ newZoomValue: Float) {
private func setZoomValue(_ newZoomValue: Float) {
if let layout = imageBrowser.collectionViewLayout as? NSCollectionViewFlowLayout {
if newZoomValue == 50 {
layout.itemSize = standardSize
+3
View File
@@ -154,6 +154,9 @@ enum Prefs {
@Stored(key: "SBArtworkSelectorZoomLevel", defaultValue: 50)
static var artworkSelectorZoomLevel: Float
@Stored(key: "SBMoviewArtworkSelectorZoomLevel", defaultValue: 50)
static var movieArtworkSelectorZoomLevel: Float
}
enum MetadataPrefs {
+15 -14
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -20,20 +20,21 @@
<outlet property="tabView" destination="10" id="nrf-df-lqq"/>
<outlet property="tagsPopUp" destination="30" id="1v4-T2-oDW"/>
<outlet property="view" destination="1" id="2"/>
<outlet property="zoomSlider" destination="235" id="Lbq-eP-7Mp"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView misplaced="YES" id="1">
<customView id="1">
<rect key="frame" x="0.0" y="0.0" width="769" height="256"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<tabView controlSize="small" translatesAutoresizingMaskIntoConstraints="NO" id="10">
<rect key="frame" x="-11" y="-12" width="791" height="240"/>
<rect key="frame" x="-11" y="-12" width="791" height="263"/>
<tabViewItems>
<tabViewItem label="Metadata" identifier="1" id="11">
<view key="view" id="12">
<rect key="frame" x="10" y="25" width="771" height="202"/>
<rect key="frame" x="10" y="25" width="771" height="156"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<popUpButton toolTip="Add a new metadata item" translatesAutoresizingMaskIntoConstraints="NO" id="30">
@@ -90,13 +91,13 @@
<accessibility description="Sets"/>
</popUpButton>
<scrollView autohidesScrollers="YES" horizontalLineScroll="16" horizontalPageScroll="10" verticalLineScroll="16" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="r4i-wT-qDC">
<rect key="frame" x="17" y="36" width="737" height="160"/>
<rect key="frame" x="17" y="36" width="737" height="114"/>
<clipView key="contentView" id="cQT-bX-0YB">
<rect key="frame" x="1" y="1" width="735" height="158"/>
<rect key="frame" x="1" y="1" width="735" height="112"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="plain" columnReordering="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="14" rowSizeStyle="automatic" headerView="qXU-xB-xRF" viewBased="YES" floatsGroupRows="NO" id="qg5-r0-E4V" customClass="ExpandedTableView" customModule="Subler" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="735" height="135"/>
<rect key="frame" x="0.0" y="0.0" width="735" height="89"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -325,7 +326,7 @@
</tabViewItem>
<tabViewItem label="Artwork" identifier="Item 1" id="15">
<view key="view" id="16">
<rect key="frame" x="10" y="25" width="771" height="248"/>
<rect key="frame" x="10" y="25" width="771" height="225"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="223">
@@ -366,13 +367,13 @@
</connections>
</slider>
<scrollView wantsLayer="YES" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WUe-C3-hRA">
<rect key="frame" x="17" y="36" width="737" height="206"/>
<rect key="frame" x="17" y="36" width="737" height="183"/>
<clipView key="contentView" id="jau-dn-6LI">
<rect key="frame" x="1" y="1" width="735" height="204"/>
<autoresizingMask key="autoresizingMask"/>
<rect key="frame" x="1" y="1" width="735" height="181"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView selectable="YES" allowsMultipleSelection="YES" id="HHe-zs-flI" customClass="CollectionView" customModule="Subler" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="735" height="204"/>
<rect key="frame" x="0.0" y="0.0" width="735" height="181"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" id="ofy-8i-tTx">
<size key="itemSize" width="280" height="224"/>
@@ -391,7 +392,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="bD2-5M-Iiz">
<rect key="frame" x="720" y="1" width="16" height="204"/>
<rect key="frame" x="720" y="1" width="16" height="181"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
+17 -6
View File
@@ -62,6 +62,7 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
private let standardSize = NSSize(width: 280, height: 224)
@IBOutlet var removeArtworkButton: NSButton!
@IBOutlet var zoomSlider: NSSlider!
@IBOutlet var artworksView: CollectionView!
override var nibName: NSNib.Name? {
@@ -135,6 +136,12 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
reloadData()
}
override func viewWillAppear() {
let zoomValue = Prefs.movieArtworkSelectorZoomLevel
setZoomValue(zoomValue)
zoomSlider.floatValue = zoomValue
}
private func reloadData() {
rowHeights.removeAll(keepingCapacity: true)
updateMetadataArray()
@@ -1255,24 +1262,28 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
}
}
@IBAction func zoomSliderDidChange(_ sender: NSControl) {
let floatValue = CGFloat(sender.floatValue)
private func setZoomValue(_ newZoomValue: Float) {
if let layout = artworksView.collectionViewLayout as? NSCollectionViewFlowLayout {
if floatValue == 50 {
if newZoomValue == 50 {
layout.itemSize = standardSize
} else if floatValue < 50 {
let zoomValue = (floatValue + 50) / 100
} else if newZoomValue < 50 {
let zoomValue = (CGFloat(newZoomValue) + 50) / 100
layout.itemSize = NSSize(width: Int(standardSize.width * zoomValue),
height: Int(standardSize.height * zoomValue))
} else {
let zoomValue = pow((floatValue + 50) / 100, 2.4)
let zoomValue = pow((CGFloat(newZoomValue) + 50) / 100, 2.4)
layout.itemSize = NSSize(width: Int(standardSize.width * zoomValue),
height: Int(standardSize.height * zoomValue))
}
}
}
@IBAction func zoomSliderDidChange(_ sender: NSControl) {
setZoomValue(sender.floatValue)
Prefs.movieArtworkSelectorZoomLevel = sender.floatValue
}
func collectionViewDelete(in collectionView: NSCollectionView) {
removeArtwork(self)
}