For some reason, I never actually hooked up the field to actually disappear when loading successfully.
42 lines
1.5 KiB
Swift
42 lines
1.5 KiB
Swift
import Foundation
|
|
import Cocoa
|
|
import Quartz
|
|
|
|
class ViewController: NSViewController {
|
|
@IBOutlet weak var imageView: NSImageView!
|
|
@IBOutlet weak var loadingField: NSTextField!
|
|
|
|
override func viewDidLoad() {
|
|
imageView.setContentCompressionResistancePriority(
|
|
.defaultLow,
|
|
for: .horizontal)
|
|
|
|
imageView.setContentCompressionResistancePriority(
|
|
.defaultLow,
|
|
for: .vertical)
|
|
|
|
}
|
|
|
|
override func viewWillAppear() {
|
|
let document = self.view.window?.windowController?.document as? Document
|
|
|
|
DispatchQueue.main.async {
|
|
guard let image = document?.makeComposite() else {
|
|
self.loadingField.stringValue = "Failed to load."
|
|
return
|
|
}
|
|
|
|
self.imageView.image = image
|
|
self.loadingField.isHidden = true
|
|
}
|
|
}
|
|
|
|
override func prepare(for segue: NSStoryboardSegue, sender: Any?) {
|
|
if(segue.identifier == "showInfo") {
|
|
// TODO: there HAS to be a better way to pass the Document class along...
|
|
(segue.destinationController as! InfoViewController).document = self.view.window?.windowController?.document as? Document
|
|
} else if(segue.identifier == "showTimelapse") {
|
|
((segue.destinationController as! NSWindowController).contentViewController as! TimelapseViewController).document = self.view.window?.windowController?.document as? Document
|
|
}
|
|
}
|
|
}
|