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"
|
|
|
|
|
|
|
|
@interface SpectrumWindowController ()
|
|
|
|
@property SpectrumView *spectrumView;
|
|
|
|
@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 {
|
|
|
|
if(!self.spectrumView) {
|
|
|
|
self.spectrumView = [[SpectrumView alloc] initWithFrame:[[self window] frame]];
|
|
|
|
[[self window] setContentView:self.spectrumView];
|
2022-05-23 00:24:35 +00:00
|
|
|
|
2022-05-23 01:39:32 +00:00
|
|
|
[self.spectrumView enableCameraControl];
|
|
|
|
}
|
2022-05-23 00:24:35 +00:00
|
|
|
|
|
|
|
if(playbackController.playbackStatus == CogStatusPlaying)
|
|
|
|
[self.spectrumView startPlayback];
|
|
|
|
}
|
|
|
|
|
2022-05-23 01:39:32 +00:00
|
|
|
- (void)stopRunning {
|
|
|
|
[[self window] setContentView:nil];
|
|
|
|
self.spectrumView = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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
|