diff --git a/Cocoa/Document.h b/Cocoa/Document.h index 412e6ff..0a7f7e8 100644 --- a/Cocoa/Document.h +++ b/Cocoa/Document.h @@ -1,8 +1,9 @@ #import #include "GBView.h" #include "GBImageView.h" +#include "GBSplitView.h" -@interface Document : NSDocument +@interface Document : NSDocument @property (strong) IBOutlet GBView *view; @property (strong) IBOutlet NSTextView *consoleOutput; @property (strong) IBOutlet NSPanel *consoleWindow; @@ -30,6 +31,8 @@ @property (strong) IBOutlet NSButton *feedSaveButton; @property (strong) IBOutlet NSTextView *debuggerSideViewInput; @property (strong) IBOutlet NSTextView *debuggerSideView; +@property (strong) IBOutlet GBSplitView *debuggerSplitView; +@property (strong) IBOutlet NSBox *debuggerVerticalLine; -(uint8_t) readMemory:(uint16_t) addr; -(void) writeMemory:(uint16_t) addr value:(uint8_t)value; diff --git a/Cocoa/Document.m b/Cocoa/Document.m index 92d5f97..b7b56cf 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -505,6 +505,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) [self.feedSaveButton removeFromSuperview]; self.consoleWindow.title = [NSString stringWithFormat:@"Debug Console – %@", [[self.fileURL path] lastPathComponent]]; + self.debuggerSplitView.dividerColor = [NSColor clearColor]; /* contentView.superview.subviews.lastObject is the titlebar view */ NSView *titleView = self.printerFeedWindow.contentView.superview.subviews.lastObject; @@ -1661,4 +1662,41 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) } +- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview; +{ + if ([[splitView arrangedSubviews] lastObject] == subview) { + return YES; + } + return NO; +} + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex +{ + return 600; +} + +- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex { + return splitView.frame.size.width - 321; +} + +- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view { + if ([[splitView arrangedSubviews] lastObject] == view) { + return NO; + } + return YES; +} + +- (void)splitViewDidResizeSubviews:(NSNotification *)notification +{ + NSSplitView *splitview = notification.object; + if ([[[splitview arrangedSubviews] firstObject] frame].size.width < 600) { + [splitview setPosition:600 ofDividerAtIndex:0]; + } + /* NSSplitView renders its separator without the proper vibrancy, so we made it transparent and move an + NSBox-based separator that renders properly so it acts like the split view's separator. */ + NSRect rect = self.debuggerVerticalLine.frame; + rect.origin.x = [[[splitview arrangedSubviews] firstObject] frame].size.width - 1; + self.debuggerVerticalLine.frame = rect; +} + @end diff --git a/Cocoa/Document.xib b/Cocoa/Document.xib index ae9cf90..c680df5 100644 --- a/Cocoa/Document.xib +++ b/Cocoa/Document.xib @@ -1,8 +1,8 @@ - + - + @@ -14,6 +14,8 @@ + + @@ -39,7 +41,7 @@ - + @@ -50,11 +52,11 @@ - + - + @@ -67,7 +69,7 @@ - + @@ -78,38 +80,7 @@ - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - + @@ -124,83 +95,140 @@ - + - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + - + @@ -208,7 +236,7 @@ - + @@ -248,7 +276,7 @@ - + @@ -265,7 +293,7 @@ - + @@ -284,7 +312,7 @@ - + @@ -292,13 +320,13 @@ - + - + - + @@ -307,17 +335,17 @@ - + - + - + @@ -326,7 +354,7 @@ - + @@ -358,7 +386,7 @@ - - + @@ -397,7 +425,7 @@ - + @@ -430,7 +458,7 @@ - + @@ -448,7 +476,7 @@ - + @@ -474,10 +502,10 @@ - + - + @@ -597,11 +625,11 @@ - - + @@ -765,7 +793,7 @@ - + diff --git a/Cocoa/GBSplitView.h b/Cocoa/GBSplitView.h new file mode 100644 index 0000000..143b8f6 --- /dev/null +++ b/Cocoa/GBSplitView.h @@ -0,0 +1,15 @@ +// +// GBSplitView.h +// SameBoySDL +// +// Created by Lior Halphon on 9/4/20. +// Copyright © 2020 Lior Halphon. All rights reserved. +// + +#import + +@interface GBSplitView : NSSplitView + +-(void) setDividerColor:(NSColor *)color; + +@end diff --git a/Cocoa/GBSplitView.m b/Cocoa/GBSplitView.m new file mode 100644 index 0000000..425d965 --- /dev/null +++ b/Cocoa/GBSplitView.m @@ -0,0 +1,28 @@ +// +// GBSplitView.m +// SameBoySDL +// +// Created by Lior Halphon on 9/4/20. +// Copyright © 2020 Lior Halphon. All rights reserved. +// + +#import "GBSplitView.h" + +@implementation GBSplitView +{ + NSColor *_dividerColor; +} + +- (void)setDividerColor:(NSColor *)color { + _dividerColor = color; + [self setNeedsDisplay:YES]; +} + +- (NSColor *)dividerColor { + if (_dividerColor) { + return _dividerColor; + } + return [super dividerColor]; +} + +@end