diff options
author | 2015-02-23 00:29:03 +1100 | |
---|---|---|
committer | 2015-02-23 04:23:12 +1100 | |
commit | deaf2eef30dd8e15f8d54ab92d876fa1238c4a11 (patch) | |
tree | cb7a6806882815d39515bf680376353f3e59b803 | |
parent | 01ec6458ff508d568815db3de8a2eb7e07d45ed0 (diff) |
More intelligible auto window position code
-rw-r--r-- | src/osd/modules/debugger/osx/debugwindowhandler.m | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.m b/src/osd/modules/debugger/osx/debugwindowhandler.m index 65ef6d5b7ba..9d1e6d5f949 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.m +++ b/src/osd/modules/debugger/osx/debugwindowhandler.m @@ -316,26 +316,32 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD } - (void)cascadeWindowWithDesiredSize:(NSSize)desired forView:(NSView *)view { - NSRect available = [[NSScreen mainScreen] visibleFrame]; - NSRect windowFrame = [window frame]; - NSSize current = [view frame].size; - + // convert desired size to an adjustment and apply it to the current window frame + NSSize const current = [view frame].size; desired.width -= current.width; desired.height -= current.height; - + NSRect windowFrame = [window frame]; windowFrame.size.width += desired.width; - windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); windowFrame.size.height += desired.height; - windowFrame.size.height = MIN(MIN(MAX(windowFrame.size.height, 120), 320), available.size.height); + + // limit the size to the minimum size + NSSize const minimum = [window minSize]; + windowFrame.size.width = MAX(windowFrame.size.width, minimum.width); + windowFrame.size.height = MAX(windowFrame.size.height, minimum.height); + + // limit the size to the main screen size + NSRect const available = [[NSScreen mainScreen] visibleFrame]; + windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); + windowFrame.size.height = MIN(windowFrame.size.height, available.size.height); + + // arbitrary additional height limit + windowFrame.size.height = MIN(windowFrame.size.height, 320); + + // place it in the bottom right corner and apply windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; windowFrame.origin.y = available.origin.y; [window setFrame:windowFrame display:YES]; [[self class] cascadeWindow:window]; - - windowFrame = [[window contentView] frame]; - desired = [window contentMinSize]; - [window setContentMinSize:NSMakeSize(MIN(windowFrame.size.width, desired.width), - MIN(windowFrame.size.height, desired.height))]; } @end |