Cog/SpectrumWindowController.m
Christopher Snowhill c59d4d0215 [Visualization] Tear down window vis when not open
When the visualization window is not open, it should not continue to run
the scene until the app is quit. Apparently, the windowed mode is really
slow on old Intel machines, too. Full screening it is enough to bodge
the entire system session until the machine is remotely rebooted.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2022-05-22 18:39:32 -07:00

64 lines
1.2 KiB
Objective-C

//
// 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];
[self startRunning];
}
- (void)startRunning {
if(!self.spectrumView) {
self.spectrumView = [[SpectrumView alloc] initWithFrame:[[self window] frame]];
[[self window] setContentView:self.spectrumView];
[self.spectrumView enableCameraControl];
}
if(playbackController.playbackStatus == CogStatusPlaying)
[self.spectrumView startPlayback];
}
- (void)stopRunning {
[[self window] setContentView:nil];
self.spectrumView = nil;
}
- (void)windowWillClose:(NSNotification *)notification {
NSWindow *currentWindow = notification.object;
if([currentWindow isEqualTo:self.window]) {
[self stopRunning];
}
}
- (IBAction)toggleWindow:(id)sender {
if([[self window] isVisible])
[[self window] orderOut:self];
else
[self showWindow:self];
}
- (IBAction)showWindow:(id)sender {
[self startRunning];
return [super showWindow:sender];
}
@end