2022-05-23 00:24:35 +00:00
|
|
|
//
|
|
|
|
// SpectrumWindowController.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Christopher Snowhill on 5/22/22.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "SpectrumWindowController.h"
|
|
|
|
|
|
|
|
#import "SpectrumView.h"
|
2022-06-09 04:32:52 +00:00
|
|
|
#import "SpectrumViewLegacy.h"
|
2022-05-23 00:24:35 +00:00
|
|
|
|
|
|
|
@interface SpectrumWindowController ()
|
|
|
|
@property SpectrumView *spectrumView;
|
2022-06-09 04:32:52 +00:00
|
|
|
@property SpectrumViewLegacy *spectrumViewLegacy;
|
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-09 04:32:52 +00:00
|
|
|
if(!self.spectrumView && !self.spectrumViewLegacy) {
|
|
|
|
NSRect frame = [[self window] frame];
|
|
|
|
self.spectrumView = [[SpectrumView alloc] initWithFrame:frame];
|
|
|
|
if(self.spectrumView) {
|
|
|
|
[[self window] setContentView:self.spectrumView];
|
2022-05-23 00:24:35 +00:00
|
|
|
|
2022-06-09 04:32:52 +00:00
|
|
|
[self.spectrumView enableCameraControl];
|
|
|
|
} else {
|
|
|
|
self.spectrumViewLegacy = [[SpectrumViewLegacy alloc] initWithFrame:frame];
|
2022-06-11 05:38:46 +00:00
|
|
|
if(self.spectrumViewLegacy) {
|
|
|
|
[[self window] setContentView:self.spectrumViewLegacy];
|
|
|
|
|
|
|
|
[self.spectrumViewLegacy enableFullView];
|
|
|
|
}
|
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) {
|
|
|
|
if(self.spectrumView)
|
|
|
|
[self.spectrumView startPlayback];
|
|
|
|
else if(self.spectrumViewLegacy)
|
|
|
|
[self.spectrumViewLegacy startPlayback];
|
|
|
|
}
|
2022-05-23 00:24:35 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 01:39:32 +00:00
|
|
|
- (void)stopRunning {
|
|
|
|
[[self window] setContentView:nil];
|
|
|
|
self.spectrumView = nil;
|
2022-06-09 04:32:52 +00:00
|
|
|
self.spectrumViewLegacy = 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
|