Rework ArtworkSelectorController to use a NSCollectionView instead of the deprecated IKImageBrowserView on 10.11+
This commit is contained in:
12 files changed
+771
-73
No files matched your search
@@ -9,7 +9,7 @@ import Cocoa
|
||||
import Quartz
|
||||
|
||||
private protocol ArtworkImageObjectDelegate: AnyObject {
|
||||
func reloadData()
|
||||
func reloadItem(_ item: ArtworkImageObject)
|
||||
}
|
||||
|
||||
private class ArtworkImageObject : NSObject {
|
||||
@@ -36,6 +36,14 @@ private class ArtworkImageObject : NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
func image() -> NSImage? {
|
||||
if let data = imageRepresentation() as? Data {
|
||||
return NSImage(data: data)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
override func imageRepresentation() -> Any! {
|
||||
// Get the data outside the main thread
|
||||
var startDownload: Bool = false
|
||||
@@ -60,7 +68,7 @@ private class ArtworkImageObject : NSObject {
|
||||
// We got the data, tell the controller to update the view
|
||||
if localCancelled == false {
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.reloadData()
|
||||
self.delegate?.reloadItem(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +114,7 @@ protocol ArtworkSelectorControllerDelegate: AnyObject {
|
||||
func didSelect(artworks: [Artwork])
|
||||
}
|
||||
|
||||
class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDelegate {
|
||||
class ArtworkSelectorControllerOldStyle: NSWindowController, ArtworkImageObjectDelegate {
|
||||
|
||||
@IBOutlet var imageBrowser: IKImageBrowserView!
|
||||
@IBOutlet var slider: NSSlider!
|
||||
@@ -144,7 +152,7 @@ class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDelegate
|
||||
}
|
||||
|
||||
override public var windowNibName: NSNib.Name? {
|
||||
return "ArtworkSelector"
|
||||
return "ArtworkSelectorOld"
|
||||
}
|
||||
|
||||
// MARK: - Load images
|
||||
@@ -175,7 +183,7 @@ class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDelegate
|
||||
imageBrowser.needsDisplay = true
|
||||
}
|
||||
|
||||
fileprivate func reloadData() {
|
||||
fileprivate func reloadItem(_ item: ArtworkImageObject) {
|
||||
imageBrowser.reloadData()
|
||||
}
|
||||
|
||||
@@ -249,3 +257,213 @@ class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDelegate
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@available(OSX 10.11, *)
|
||||
class CollectionView : NSCollectionView {
|
||||
override func keyDown(with event: NSEvent) {
|
||||
guard let key = event.charactersIgnoringModifiers?.utf16.first else { super.keyDown(with: event); return }
|
||||
|
||||
if key == NSEnterCharacter || key == NSCarriageReturnCharacter {
|
||||
nextResponder?.keyDown(with: event)
|
||||
} else if selectionIndexPaths.isEmpty {
|
||||
if key == NSRightArrowFunctionKey || key == NSDownArrowFunctionKey {
|
||||
animator().selectItems(at: Set([IndexPath(item: 0, section: 0)]), scrollPosition: .bottom)
|
||||
} else if key == NSLeftArrowFunctionKey || key == NSUpArrowFunctionKey {
|
||||
let numberOfItems = dataSource?.collectionView(self, numberOfItemsInSection: 0) ?? 1
|
||||
animator().selectItems(at: Set([IndexPath(item: numberOfItems - 1, section: 0)]), scrollPosition: .bottom)
|
||||
} else {
|
||||
super.keyDown(with: event)
|
||||
}
|
||||
} else {
|
||||
super.keyDown(with: event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@available(OSX 10.11, *)
|
||||
class ArtworkSelectorController: NSWindowController, NSCollectionViewDataSource, NSCollectionViewDelegate, ArtworkImageObjectDelegate {
|
||||
|
||||
@IBOutlet var imageBrowser: NSCollectionView!
|
||||
@IBOutlet var slider: NSSlider!
|
||||
@IBOutlet var addArtworkButton: NSButton!
|
||||
@IBOutlet var loadMoreArtworkButton: NSButton!
|
||||
|
||||
private var artworksUnloaded: [Artwork]
|
||||
private var artworks: [ArtworkImageObject]
|
||||
private let initialSize: CGSize?
|
||||
private let type: MetadataType
|
||||
|
||||
private weak var delegate: ArtworkSelectorControllerDelegate?
|
||||
|
||||
// MARK: - Init
|
||||
init(artworks: [Artwork], size: CGSize? = nil, type: MetadataType, delegate: ArtworkSelectorControllerDelegate) {
|
||||
self.delegate = delegate
|
||||
self.initialSize = size
|
||||
self.artworksUnloaded = artworks
|
||||
self.artworks = Array()
|
||||
self.type = type
|
||||
super.init(window: nil)
|
||||
}
|
||||
|
||||
required public init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
deinit {
|
||||
imageBrowser.delegate = nil
|
||||
imageBrowser.dataSource = nil
|
||||
|
||||
for artwork in artworks {
|
||||
artwork.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
override public var windowNibName: NSNib.Name? {
|
||||
return "ArtworkSelector"
|
||||
}
|
||||
|
||||
// MARK: - Load images
|
||||
override public func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
|
||||
window?.contentView?.wantsLayer = true
|
||||
|
||||
if let size = initialSize { window?.setContentSize(size) }
|
||||
|
||||
imageBrowser.register(ArtworkSelectorViewItem.self, forItemWithIdentifier: ArtworkSelectorController.itemView)
|
||||
loadMoreArtworks(count: 8)
|
||||
|
||||
if let defaultService = UserDefaults.standard.string(forKey: "SBArtworkSelectorDefaultService|\(type.description)"),
|
||||
let defaultType = ArtworkType(rawValue: UserDefaults.standard.integer(forKey: "SBArtworkSelectorDefaultType|\(type.description)")) {
|
||||
selectArtwork(type: defaultType, service: defaultService)
|
||||
}
|
||||
|
||||
if imageBrowser.selectionIndexPaths.count == 0 {
|
||||
let indexPath = IndexPath(item: 0, section: 0)
|
||||
imageBrowser.selectItems(at: [indexPath], scrollPosition: .top)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func loadMoreArtwork(_ sender: Any) {
|
||||
loadMoreArtworks(count: 8)
|
||||
}
|
||||
|
||||
// MARK: - User Interface
|
||||
|
||||
@IBAction func zoomSliderDidChange(_ sender: Any) {
|
||||
if let layout = imageBrowser.collectionViewLayout as? NSCollectionViewFlowLayout {
|
||||
layout.itemSize = NSSize(width: Int(slider.floatValue), height: Int(slider.floatValue * 1.25))
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func reloadItem(_ item: ArtworkImageObject) {
|
||||
let selectionIndexPaths = imageBrowser.selectionIndexPaths
|
||||
|
||||
if let index = artworks.firstIndex(of: item) {
|
||||
let indexPath = IndexPath(item: index, section: 0)
|
||||
imageBrowser.reloadItems(at: [indexPath])
|
||||
}
|
||||
|
||||
if imageBrowser.selectionIndexPaths.isEmpty {
|
||||
imageBrowser.selectionIndexPaths = selectionIndexPaths
|
||||
}
|
||||
}
|
||||
|
||||
private func selectArtwork(at index: Int) {
|
||||
let indexPath = IndexPath(item: 0, section: 0)
|
||||
imageBrowser.selectItems(at: [indexPath], scrollPosition: .top)
|
||||
addArtworkButton.isEnabled = imageBrowser.selectionIndexPaths.isEmpty == false
|
||||
}
|
||||
|
||||
private func loadMoreArtworks(count: Int) {
|
||||
let endIndex = artworksUnloaded.count < count ? artworksUnloaded.count : count
|
||||
let newArtworks = artworksUnloaded[0 ..< endIndex]
|
||||
|
||||
artworks.append(contentsOf: newArtworks.map { ArtworkImageObject(artwork: $0, delegate: self) })
|
||||
artworksUnloaded.removeFirst(endIndex)
|
||||
loadMoreArtworkButton.isEnabled = artworksUnloaded.isEmpty == false
|
||||
|
||||
let range = (artworks.count - endIndex ..< artworks.count)
|
||||
let indexes = range.map { IndexPath(item: $0, section: 0)}
|
||||
|
||||
imageBrowser.insertItems(at: Set(indexes))
|
||||
}
|
||||
|
||||
private func selectArtwork(type: ArtworkType, service: String) {
|
||||
if let artwork = (artworks.filter { $0.source.type == type && $0.source.service == service } as [ArtworkImageObject]).first,
|
||||
let index = artworks.index(of: artwork) {
|
||||
selectArtwork(at: index)
|
||||
}
|
||||
else if let artwork = (artworks.filter { $0.source.type == type } as [ArtworkImageObject]).first,
|
||||
let index = artworks.index(of: artwork) {
|
||||
selectArtwork(at: index)
|
||||
}
|
||||
else if artworksUnloaded.isEmpty == false {
|
||||
for (index, artwork) in artworksUnloaded.enumerated() {
|
||||
if artwork.type == type {
|
||||
let offset = artworks.count
|
||||
loadMoreArtworks(count: index + 1)
|
||||
selectArtwork(at: index + offset)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func selectedArtworks() -> [ArtworkImageObject] {
|
||||
return imageBrowser.selectionIndexes.map { artworks[$0] }
|
||||
}
|
||||
|
||||
// MARK: - Finishing Up
|
||||
@IBAction func addArtwork(_ sender: Any) {
|
||||
delegate?.didSelect(artworks:selectedArtworks().map { $0.source })
|
||||
}
|
||||
|
||||
@IBAction func addNoArtwork(_ sender: Any) {
|
||||
delegate?.didSelect(artworks: [])
|
||||
}
|
||||
|
||||
// MARK: - Data source
|
||||
|
||||
func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return artworks.count
|
||||
}
|
||||
|
||||
static let itemView = NSUserInterfaceItemIdentifier(rawValue: "ArtworkSelectorViewItem")
|
||||
|
||||
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
|
||||
let item = collectionView.makeItem(withIdentifier: ArtworkSelectorController.itemView, for: indexPath)
|
||||
guard let collectionViewItem = item as? ArtworkSelectorViewItem, let index = indexPath.last else { return item }
|
||||
|
||||
let artwork = artworks[index]
|
||||
|
||||
collectionViewItem.title = artwork.imageTitle()
|
||||
collectionViewItem.subtitle = artwork.imageSubtitle()
|
||||
collectionViewItem.image = artwork.image()
|
||||
|
||||
collectionViewItem.doubleAction = #selector(addArtwork)
|
||||
collectionViewItem.target = self
|
||||
|
||||
return collectionViewItem
|
||||
}
|
||||
|
||||
// MARK: - Delegate
|
||||
|
||||
private func updateSelection() {
|
||||
addArtworkButton.isEnabled = imageBrowser.selectionIndexes.isEmpty == false
|
||||
if let artwork = selectedArtworks().first {
|
||||
UserDefaults.standard.set(artwork.source.type.rawValue, forKey: "SBArtworkSelectorDefaultType|\(type.description)")
|
||||
UserDefaults.standard.set(artwork.source.service, forKey: "SBArtworkSelectorDefaultService|\(type.description)")
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
|
||||
updateSelection()
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: NSCollectionView, didDeselectItemsAt indexPaths: Set<IndexPath>) {
|
||||
updateSelection()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
//
|
||||
// ArtworkSelectorViewItem.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 13/06/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class ArtworkSelectorViewItemLabel : NSTextField {
|
||||
|
||||
@IBInspectable var highlightColor: NSColor = .alternateSelectedControlColor
|
||||
@IBInspectable var highlightTextColor: NSColor = .alternateSelectedControlTextColor
|
||||
@IBInspectable var cornerRadius: CGFloat = 3
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
var attributedString = attributedStringValue
|
||||
if isHighlighted {
|
||||
let mutableAttributedString = attributedString.mutableCopy() as! NSMutableAttributedString
|
||||
let range = NSRange(location: 0, length: mutableAttributedString.length)
|
||||
mutableAttributedString.removeAttribute(NSAttributedString.Key.foregroundColor, range: range)
|
||||
mutableAttributedString.addAttributes([NSAttributedString.Key.foregroundColor : highlightTextColor], range: range)
|
||||
attributedString = mutableAttributedString
|
||||
}
|
||||
let framesetter = CTFramesetterCreateWithAttributedString(attributedString)
|
||||
|
||||
let path = CGMutablePath()
|
||||
path.addRect(CGRect(x: 0, y: 0, width: bounds.size.width, height: bounds.size.height))
|
||||
|
||||
let totalFrame = CTFramesetterCreateFrame(framesetter, CFRange(), path, nil)
|
||||
|
||||
guard let context = NSGraphicsContext.current?.cgContext else { return }
|
||||
context.saveGState()
|
||||
context.textMatrix = .identity
|
||||
context.translateBy(x: 0, y: bounds.size.height)
|
||||
context.scaleBy(x: 1, y: -1)
|
||||
|
||||
// Highlight the text specified
|
||||
let lines = CTFrameGetLines(totalFrame) as! [CTLine]
|
||||
let lineCount = lines.count
|
||||
|
||||
var origins = [CGPoint](repeating: CGPoint.zero, count: lineCount)
|
||||
CTFrameGetLineOrigins(totalFrame, CFRange(), &origins)
|
||||
|
||||
if isHighlighted {
|
||||
for index in 0 ..< lineCount {
|
||||
let line = lines[index]
|
||||
let glyphRuns = CTLineGetGlyphRuns(line) as! [CTRun]
|
||||
let glyphCount = glyphRuns.count
|
||||
|
||||
let origin = origins[index]
|
||||
// context.textPosition = pos
|
||||
|
||||
for i in 0 ..< glyphCount {
|
||||
let run = glyphRuns[i]
|
||||
// let attributes = CTRunGetAttributes(run)
|
||||
|
||||
// if CFDictionaryGetValue(attributes, "HighlightText") {
|
||||
var runBounds = CGRect.zero
|
||||
var ascent: CGFloat = 0, descent: CGFloat = 0, leading: CGFloat = 0
|
||||
|
||||
runBounds.size.width = CGFloat(CTRunGetTypographicBounds(run, CFRange(), &ascent, &descent, &leading))
|
||||
runBounds.size.height = ascent + descent
|
||||
|
||||
runBounds.origin.x = CTLineGetOffsetForStringIndex(line, CTRunGetStringRange(run).location, nil) + origin.x
|
||||
runBounds.origin.y = origin.y - descent
|
||||
|
||||
let highlightCGColor = highlightColor.cgColor
|
||||
let roundeRect = runBounds.insetBy(dx: -4, dy: 0)
|
||||
let roundedPath = NSBezierPath(roundedRect: roundeRect.integral, xRadius: cornerRadius, yRadius: cornerRadius)
|
||||
context.setFillColor(highlightCGColor)
|
||||
roundedPath.fill()
|
||||
|
||||
// CTRunDraw(run, context, CFRange())
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
CTFrameDraw(totalFrame, context)
|
||||
context.restoreGState()
|
||||
}
|
||||
}
|
||||
|
||||
class ArtworkSelectorViewItemView: NSView {
|
||||
override func hitTest(_ point: NSPoint) -> NSView? {
|
||||
guard let superview = superview else { return nil }
|
||||
|
||||
if super.hitTest(point) != nil {
|
||||
let convertedPoint = superview.convert(point, to: self)
|
||||
if let layer = layer?.sublayers?.last {
|
||||
if layer.hitTest(convertedPoint) != nil {
|
||||
return self
|
||||
}
|
||||
}
|
||||
return superview
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(OSX 10.11, *)
|
||||
class ArtworkSelectorViewItem: NSCollectionViewItem {
|
||||
|
||||
@IBOutlet var subTextField: NSTextField!
|
||||
|
||||
private let imageLayer: CALayer = CALayer()
|
||||
private let backgroundLayer: CALayer = CALayer()
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
var doubleAction: Selector?
|
||||
weak var target: AnyObject?
|
||||
|
||||
override var title: String? {
|
||||
set (title) {
|
||||
textField?.stringValue = title ?? ""
|
||||
super.title = title
|
||||
}
|
||||
get {
|
||||
return super.title
|
||||
}
|
||||
}
|
||||
|
||||
var subtitle: String? {
|
||||
didSet {
|
||||
subTextField?.stringValue = subtitle ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
var image: NSImage? {
|
||||
didSet {
|
||||
if image != nil {
|
||||
imageLayer.contents = image
|
||||
imageLayer.shadowOpacity = 0.8
|
||||
} else {
|
||||
imageLayer.contents = NSImage(imageLiteralResourceName: "Placeholder")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override var highlightState: NSCollectionViewItem.HighlightState {
|
||||
set (value) {
|
||||
super.highlightState = value
|
||||
updateSelectionHighlight()
|
||||
}
|
||||
get {
|
||||
return super.highlightState
|
||||
}
|
||||
}
|
||||
|
||||
override var isSelected: Bool {
|
||||
set (value) {
|
||||
super.isSelected = value
|
||||
updateSelectionHighlight()
|
||||
}
|
||||
get {
|
||||
return super.isSelected
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: View Controller life cycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// self.view.layer?.shouldRasterize = true
|
||||
self.view.canDrawSubviewsIntoLayer = true
|
||||
|
||||
imageLayer.anchorPoint = CGPoint.zero
|
||||
imageLayer.position = CGPoint(x: 4, y: 40)
|
||||
imageLayer.contentsGravity = .resizeAspect
|
||||
imageLayer.shadowRadius = 1
|
||||
imageLayer.shadowColor = NSColor.labelColor.cgColor
|
||||
imageLayer.shadowOffset = CGSize.zero
|
||||
imageLayer.isOpaque = true
|
||||
backgroundLayer.anchorPoint = CGPoint.zero
|
||||
backgroundLayer.position = CGPoint(x: 0, y: 36)
|
||||
backgroundLayer.backgroundColor = NSColor.controlHighlightColor.cgColor
|
||||
backgroundLayer.cornerRadius = 8
|
||||
backgroundLayer.isHidden = true
|
||||
backgroundLayer.isOpaque = true
|
||||
|
||||
let actions: [String : CAAction] = ["contents": NSNull(),
|
||||
"hidden": NSNull(),
|
||||
"bounds": NSNull()]
|
||||
imageLayer.actions = actions
|
||||
backgroundLayer.actions = actions
|
||||
|
||||
view.layer?.addSublayer(backgroundLayer)
|
||||
view.layer?.addSublayer(imageLayer)
|
||||
}
|
||||
|
||||
override func viewDidLayout() {
|
||||
let bounds = self.view.bounds
|
||||
|
||||
imageLayer.bounds = CGRect(x: 0, y: 0, width: bounds.width - 8, height: bounds.height - 44)
|
||||
backgroundLayer.bounds = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height - 36)
|
||||
|
||||
super.viewDidLayout()
|
||||
}
|
||||
|
||||
static private let paragraph: NSParagraphStyle = {
|
||||
let paragraph = NSMutableParagraphStyle()
|
||||
paragraph.alignment = .center
|
||||
return paragraph
|
||||
}()
|
||||
|
||||
private func updateSelectionHighlight() {
|
||||
if highlightState == .forSelection || (isSelected && highlightState != .forDeselection) {
|
||||
backgroundLayer.isHidden = false
|
||||
textField?.isHighlighted = true
|
||||
} else {
|
||||
backgroundLayer.isHidden = true
|
||||
textField?.isHighlighted = false
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
override func mouseUp(with event: NSEvent) {
|
||||
if event.clickCount > 1, let action = doubleAction {
|
||||
target?.performSelector(onMainThread: action, with: nil, waitUntilDone: true)
|
||||
} else {
|
||||
super.mouseUp(with: event)
|
||||
}
|
||||
}
|
||||
|
||||
override func keyDown(with event: NSEvent) {
|
||||
if event.keyCode == NSEnterCharacter, let action = doubleAction {
|
||||
target?.performSelector(onMainThread: action, with: nil, waitUntilDone: true)
|
||||
} else {
|
||||
super.keyDown(with: event)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14269.14" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment version="101100" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14269.14"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ArtworkSelectorViewItem" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="subTextField" destination="fGU-Kh-WjD" id="NYJ-6o-hWO"/>
|
||||
<outlet property="textField" destination="Wkh-6c-0tU" id="Wbm-4M-W1L"/>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView wantsLayer="YES" misplaced="YES" id="Hz6-mo-xeY" customClass="ArtworkSelectorViewItemView" customModule="Subler" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="128" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" id="Wkh-6c-0tU" customClass="ArtworkSelectorViewItemLabel" customModule="Subler" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="17" width="128" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Label" id="TsL-Ak-xnf">
|
||||
<font key="font" metaFont="cellTitle"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" id="fGU-Kh-WjD">
|
||||
<rect key="frame" x="2" y="4" width="124" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Label" id="ggX-Q2-CZ0">
|
||||
<font key="font" metaFont="system" size="10"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="-39" y="112.5"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -191,7 +191,7 @@ class DocumentWindowController: NSWindowController, TracksViewControllerDelegate
|
||||
@IBOutlet var searchChapters: NSToolbarItem!
|
||||
@IBOutlet var sendToQueue: NSToolbarItem!
|
||||
|
||||
override func validateToolbarItem(_ item: NSToolbarItem) -> Bool {
|
||||
override func validate(_ item: NSToolbarItem) -> Bool {
|
||||
if item == addTracks ||
|
||||
item == searchMetadata ||
|
||||
item == searchChapters ||
|
||||
|
||||
@@ -61,7 +61,7 @@ class MetadataSearchController: NSWindowController, NSTableViewDataSource, NSTab
|
||||
private var tvShowService: MetadataService = MetadataSearch.defaultTVService
|
||||
|
||||
// MARK: Other
|
||||
private var artworkSelector: ArtworkSelectorController?
|
||||
private var artworkSelector: NSWindowController?
|
||||
private weak var delegate: MetadataSearchControllerDelegate?
|
||||
|
||||
private let terms: MetadataSearchTerms
|
||||
@@ -298,10 +298,17 @@ class MetadataSearchController: NSWindowController, NSTableViewDataSource, NSTab
|
||||
}
|
||||
|
||||
private func selectArtwork(artworks: [Artwork], type: MetadataType) {
|
||||
let artworkSelectorController = ArtworkSelectorController(artworks: artworks, size: window?.frame.size,
|
||||
type: type, delegate: self)
|
||||
window?.beginSheet(artworkSelectorController.window!, completionHandler: nil)
|
||||
artworkSelector = artworkSelectorController
|
||||
if #available(OSX 10.11, *) {
|
||||
let artworkSelectorController = ArtworkSelectorController(artworks: artworks, size: window?.frame.size,
|
||||
type: type, delegate: self)
|
||||
window?.beginSheet(artworkSelectorController.window!, completionHandler: nil)
|
||||
artworkSelector = artworkSelectorController
|
||||
} else {
|
||||
let artworkSelectorController = ArtworkSelectorControllerOldStyle(artworks: artworks, size: window?.frame.size,
|
||||
type: type, delegate: self)
|
||||
window?.beginSheet(artworkSelectorController.window!, completionHandler: nil)
|
||||
artworkSelector = artworkSelectorController
|
||||
}
|
||||
}
|
||||
|
||||
func didSelect(artworks: [Artwork]) {
|
||||
|
||||
Reference in new issue
Block a user