Previous 199869 Revisions Next

r36058 Sunday 22nd February, 2015 at 17:23:12 UTC by Vasantha Crabb
More intelligible auto window position code
[/branches/kale/src/osd/modules/debugger/osx]debugwindowhandler.m

branches/kale/src/osd/modules/debugger/osx/debugwindowhandler.m
r244569r244570
316316}
317317
318318- (void)cascadeWindowWithDesiredSize:(NSSize)desired forView:(NSView *)view {
319   NSRect   available = [[NSScreen mainScreen] visibleFrame];
320   NSRect   windowFrame = [window frame];
321   NSSize   current = [view frame].size;
322
319   // convert desired size to an adjustment and apply it to the current window frame
320   NSSize const current = [view frame].size;
323321   desired.width -= current.width;
324322   desired.height -= current.height;
323   NSRect windowFrame = [window frame];
324   windowFrame.size.width += desired.width;
325   windowFrame.size.height += desired.height;
325326
326   windowFrame.size.width += desired.width;
327   // limit the size to the minimum size
328   NSSize const minimum = [window minSize];
329   windowFrame.size.width = MAX(windowFrame.size.width, minimum.width);
330   windowFrame.size.height = MAX(windowFrame.size.height, minimum.height);
331
332   // limit the size to the main screen size
333   NSRect const available = [[NSScreen mainScreen] visibleFrame];
327334   windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
328   windowFrame.size.height += desired.height;
329   windowFrame.size.height = MIN(MIN(MAX(windowFrame.size.height, 120), 320), available.size.height);
335   windowFrame.size.height = MIN(windowFrame.size.height, available.size.height);
336
337   // arbitrary additional height limit
338   windowFrame.size.height = MIN(windowFrame.size.height, 320);
339
340   // place it in the bottom right corner and apply
330341   windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
331342   windowFrame.origin.y = available.origin.y;
332343   [window setFrame:windowFrame display:YES];
333344   [[self class] cascadeWindow:window];
334
335   windowFrame = [[window contentView] frame];
336   desired = [window contentMinSize];
337   [window setContentMinSize:NSMakeSize(MIN(windowFrame.size.width, desired.width),
338                               MIN(windowFrame.size.height, desired.height))];
339345}
340346
341347@end


Previous 199869 Revisions Next


© 1997-2024 The MAME Team