diff options
author | Sven Weidauer <sven.weidauer@gmail.com> | 2011-02-17 17:23:58 +0000 |
---|---|---|
committer | Sven Weidauer <sven.weidauer@gmail.com> | 2011-02-17 17:23:58 +0000 |
commit | d092b9ca354f07a78f0e540ce7da00026f0e534a (patch) | |
tree | 4491f04cfae1fb29ac5443162be8e34b5062a801 /cocoa/LocalHistoryController.m | |
parent | 2beda0fc07e860b6bd8c7b68ac61de8d821cb580 (diff) | |
download | netsurf-d092b9ca354f07a78f0e540ce7da00026f0e534a.tar.gz netsurf-d092b9ca354f07a78f0e540ce7da00026f0e534a.tar.bz2 |
Making sure history popup stays on screen.
svn path=/trunk/netsurf/; revision=11708
Diffstat (limited to 'cocoa/LocalHistoryController.m')
-rw-r--r-- | cocoa/LocalHistoryController.m | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/cocoa/LocalHistoryController.m b/cocoa/LocalHistoryController.m index 79f842b11..0e90b92c0 100644 --- a/cocoa/LocalHistoryController.m +++ b/cocoa/LocalHistoryController.m @@ -37,8 +37,59 @@ - (void) attachToView: (NSView *) view; { + const CGFloat ScrollerSpace = [NSScroller scrollerWidthForControlSize: NSSmallControlSize];; + + NSDisableScreenUpdates(); + + ArrowWindow *box = (ArrowWindow *)[self window]; + + NSSize newSize = [history size]; + newSize.width += ScrollerSpace; + newSize.height += ScrollerSpace; + + [box setContentSize: newSize]; + [box setArrowPosition: 50]; [history updateHistory]; - [(ArrowWindow *)[self window] attachToView: view]; + [box attachToView: view]; + + NSRect frame = [box frame]; + NSRect screenFrame = [[box screen] visibleFrame]; + + const CGFloat arrowSize = [box arrowSize]; + frame.origin.x += arrowSize; + frame.origin.y += arrowSize; + frame.size.width -= 2 * arrowSize; + frame.size.height -= 2 * arrowSize; + + if (NSMinY( frame ) < NSMinY( screenFrame )) { + const CGFloat delta = NSMinY( screenFrame ) - NSMinY( frame ); + frame.size.height -= delta; + frame.origin.y += delta; + } + + CGFloat arrowPositionChange = 50; + if (NSMaxX( frame ) > NSMaxX( screenFrame )) { + const CGFloat delta = NSMaxX( frame ) - NSMaxX( screenFrame ); + arrowPositionChange += delta; + frame.origin.x -= delta; + } + + if (NSMinX( frame ) < NSMinX( screenFrame )) { + const CGFloat delta = NSMinX( screenFrame ) - NSMinX( frame ); + arrowPositionChange -= delta; + frame.origin.x += delta; + frame.size.width -= delta; + } + + frame.origin.x -= arrowSize; + frame.origin.y -= arrowSize; + frame.size.width += 2 * arrowSize; + frame.size.height += 2 * arrowSize; + + [box setArrowPosition: arrowPositionChange]; + [box setFrame: frame display: YES]; + + NSEnableScreenUpdates(); } - (void) detach; |