1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
silica-viewer/SilicaViewer/ViewController.swift
Joshua Goins eeba7bba02 Actually update loading label
For some reason, I never actually hooked up the field to actually disappear when
loading successfully.
2022-06-15 11:01:20 -04:00

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
}
}
}