From c59d4d0215506f7234fdccbc3be9e5adea058aa1 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 22 May 2022 18:39:32 -0700 Subject: [PATCH] [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 --- SpectrumWindowController.h | 2 +- SpectrumWindowController.m | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/SpectrumWindowController.h b/SpectrumWindowController.h index 621fce94c..218a0a09c 100644 --- a/SpectrumWindowController.h +++ b/SpectrumWindowController.h @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface SpectrumWindowController : NSWindowController { +@interface SpectrumWindowController : NSWindowController { IBOutlet PlaybackController *playbackController; } diff --git a/SpectrumWindowController.m b/SpectrumWindowController.m index fb180fbf6..6fd4e5beb 100644 --- a/SpectrumWindowController.m +++ b/SpectrumWindowController.m @@ -22,15 +22,33 @@ - (void)windowDidLoad { [super windowDidLoad]; - self.spectrumView = [[SpectrumView alloc] initWithFrame:[[self window] frame]]; - [[self window] setContentView:self.spectrumView]; + [self startRunning]; +} - [self.spectrumView enableCameraControl]; +- (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]; @@ -39,8 +57,7 @@ } - (IBAction)showWindow:(id)sender { - if(self.spectrumView && playbackController.playbackStatus == CogStatusPlaying) - [self.spectrumView startPlayback]; + [self startRunning]; return [super showWindow:sender]; }