Stuff…
This commit is contained in:
63
TagTunes/SaveTableCellView.swift
Executable file
63
TagTunes/SaveTableCellView.swift
Executable file
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// SaveTableCellView.swift
|
||||
// TagTunes
|
||||
//
|
||||
// Created by Kim Wittenburg on 08.04.16.
|
||||
// Copyright © 2016 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
import AppKitPlus
|
||||
|
||||
// TODO: Generalize for AppKitPlus
|
||||
|
||||
class SaveTableCellView: AdvancedTableCellView {
|
||||
|
||||
let progressIndicator: NSProgressIndicator = {
|
||||
let indicator = NSProgressIndicator()
|
||||
indicator.style = .SpinningStyle
|
||||
indicator.controlSize = .SmallControlSize
|
||||
indicator.minValue = 0
|
||||
indicator.maxValue = 1
|
||||
indicator.translatesAutoresizingMaskIntoConstraints = false
|
||||
return indicator
|
||||
}()
|
||||
|
||||
let cancelButton: NSButton = {
|
||||
let button = NSButton()
|
||||
button.setButtonType(.MomentaryChangeButton)
|
||||
button.bezelStyle = .ShadowlessSquareBezelStyle
|
||||
button.bordered = false
|
||||
button.imagePosition = .ImageOnly
|
||||
button.image = NSImage(named: NSImageNameStopProgressFreestandingTemplate)
|
||||
button.translatesAutoresizingMaskIntoConstraints = false
|
||||
return button
|
||||
}()
|
||||
|
||||
dynamic var progress: NSProgress?
|
||||
|
||||
override func setupView() {
|
||||
style = .Subtitle
|
||||
|
||||
cancelButton.target = self
|
||||
cancelButton.action = #selector(SaveTableCellView.cancel(_:))
|
||||
let stackView = NSStackView(views: [progressIndicator, cancelButton])
|
||||
stackView.orientation = .Horizontal
|
||||
|
||||
rightAccessoryView = stackView
|
||||
|
||||
// Setup bindings
|
||||
primaryTextField?.bind(NSValueBinding, toObject: self, withKeyPath: "progress.localizedDescription", options: nil)
|
||||
secondaryTextField?.bind(NSValueBinding, toObject: self, withKeyPath: "progress.localizedAdditionalDescription", options: nil)
|
||||
cancelButton.bind(NSEnabledBinding, toObject: self, withKeyPath: "progress.cancellable", options: nil)
|
||||
progressIndicator.bind(NSValueBinding, toObject: self, withKeyPath: "progress.fractionCompleted", options: nil)
|
||||
progressIndicator.bind(NSIsIndeterminateBinding, toObject: self, withKeyPath: "progress.indeterminate", options: nil)
|
||||
progressIndicator.bind(NSAnimateBinding, toObject: self, withKeyPath: "progress.indeterminate", options: nil)
|
||||
|
||||
super.setupView()
|
||||
}
|
||||
|
||||
func cancel(sender: AnyObject?) {
|
||||
progress?.cancel()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user