2022-05-23 00:24:35 +00:00
|
|
|
//
|
|
|
|
// SpectrumWindowController.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Christopher Snowhill on 5/22/22.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "SpectrumWindowController.h"
|
|
|
|
|
2022-06-18 05:14:32 +00:00
|
|
|
#import "SpectrumViewSK.h"
|
|
|
|
#import "SpectrumViewCG.h"
|
2022-05-23 00:24:35 +00:00
|
|
|
|
|
|
|
@interface SpectrumWindowController ()
|
2022-06-18 05:14:32 +00:00
|
|
|
@property SpectrumViewSK *spectrumViewSK;
|
|
|
|
@property SpectrumViewCG *spectrumViewCG;
|
2022-05-23 00:24:35 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SpectrumWindowController
|
|
|
|
|
|
|
|
- (id)init {
|
|
|
|
return [super initWithWindowNibName:@"SpectrumWindow"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)windowDidLoad {
|
|
|
|
[super windowDidLoad];
|
|
|
|
|
2022-05-23 01:39:32 +00:00
|
|
|
[self startRunning];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)startRunning {
|
2022-06-18 05:14:32 +00:00
|
|
|
if(!self.spectrumViewSK && !self.spectrumViewCG) {
|
2022-06-09 04:32:52 +00:00
|
|
|
NSRect frame = [[self window] frame];
|
2022-06-18 05:14:32 +00:00
|
|
|
self.spectrumViewSK = [SpectrumViewSK createGuardWithFrame:frame];
|
|
|
|
if(self.spectrumViewSK) {
|
|
|
|
[[self window] setContentView:self.spectrumViewSK];
|
2022-05-23 00:24:35 +00:00
|
|
|
|
2022-06-18 05:14:32 +00:00
|
|
|
[self.spectrumViewSK enableCameraControl];
|
2022-06-09 04:32:52 +00:00
|
|
|
} else {
|
2022-06-18 05:14:32 +00:00
|
|
|
self.spectrumViewCG = [[SpectrumViewCG alloc] initWithFrame:frame];
|
|
|
|
if(self.spectrumViewCG) {
|
|
|
|
[[self window] setContentView:self.spectrumViewCG];
|
2022-06-11 05:38:46 +00:00
|
|
|
|
2022-06-18 05:14:32 +00:00
|
|
|
[self.spectrumViewCG enableFullView];
|
2022-06-11 05:38:46 +00:00
|
|
|
}
|
2022-06-09 04:32:52 +00:00
|
|
|
}
|
2022-05-23 01:39:32 +00:00
|
|
|
}
|
2022-05-23 00:24:35 +00:00
|
|
|
|
2022-06-09 04:32:52 +00:00
|
|
|
if(playbackController.playbackStatus == CogStatusPlaying) {
|
2022-06-18 05:14:32 +00:00
|
|
|
if(self.spectrumViewSK)
|
|
|
|
[self.spectrumViewSK startPlayback];
|
|
|
|
else if(self.spectrumViewCG)
|
|
|
|
[self.spectrumViewCG startPlayback];
|
2022-06-09 04:32:52 +00:00
|
|
|
}
|
2022-05-23 00:24:35 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 01:39:32 +00:00
|
|
|
- (void)stopRunning {
|
|
|
|
[[self window] setContentView:nil];
|
2022-06-18 05:14:32 +00:00
|
|
|
self.spectrumViewSK = nil;
|
|
|
|
self.spectrumViewCG = nil;
|
2022-05-23 01:39:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)windowWillClose:(NSNotification *)notification {
|
|
|
|
NSWindow *currentWindow = notification.object;
|
|
|
|
if([currentWindow isEqualTo:self.window]) {
|
|
|
|
[self stopRunning];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-23 00:24:35 +00:00
|
|
|
- (IBAction)toggleWindow:(id)sender {
|
|
|
|
if([[self window] isVisible])
|
|
|
|
[[self window] orderOut:self];
|
|
|
|
else
|
|
|
|
[self showWindow:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)showWindow:(id)sender {
|
2022-05-23 01:39:32 +00:00
|
|
|
[self startRunning];
|
2022-05-23 00:24:35 +00:00
|
|
|
return [super showWindow:sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|