diff options
-rw-r--r-- | cocoa/HistoryView.h | 1 | ||||
-rw-r--r-- | cocoa/HistoryView.m | 19 | ||||
-rw-r--r-- | cocoa/LocalHistoryController.m | 53 | ||||
-rw-r--r-- | cocoa/res/LocalHistoryPanel.xib | 8 |
4 files changed, 68 insertions, 13 deletions
diff --git a/cocoa/HistoryView.h b/cocoa/HistoryView.h index 33eb1b52d..20806363f 100644 --- a/cocoa/HistoryView.h +++ b/cocoa/HistoryView.h @@ -27,5 +27,6 @@ @property (readwrite, assign, nonatomic) struct browser_window *browser; - (void) updateHistory; +- (NSSize) size; @end diff --git a/cocoa/HistoryView.m b/cocoa/HistoryView.m index d18f1eb50..49982b393 100644 --- a/cocoa/HistoryView.m +++ b/cocoa/HistoryView.m @@ -25,13 +25,6 @@ #import "desktop/history_core.h" #import "desktop/plotters.h" -static NSRect cocoa_history_rect( struct browser_window *bw ) -{ - int width, height; - history_size( bw->history, &width, &height ); - return cocoa_rect( 0, 0, width, height ); -} - @implementation HistoryView @synthesize browser; @@ -42,9 +35,19 @@ static NSRect cocoa_history_rect( struct browser_window *bw ) [self updateHistory]; } +- (NSSize) size; +{ + const CGFloat padding = 10; + + int width, height; + history_size( browser->history, &width, &height ); + + return NSMakeSize( cocoa_px_to_pt( width ) + padding, cocoa_px_to_pt( height ) + padding ); +} + - (void) updateHistory; { - [self setFrameSize: cocoa_history_rect( browser ).size]; + [self setFrameSize: [self size]]; [self setNeedsDisplay: YES]; } 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; diff --git a/cocoa/res/LocalHistoryPanel.xib b/cocoa/res/LocalHistoryPanel.xib index 7832901f1..794d2db54 100644 --- a/cocoa/res/LocalHistoryPanel.xib +++ b/cocoa/res/LocalHistoryPanel.xib @@ -12,7 +12,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1"/> + <integer value="2"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -64,7 +64,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSCustomView" id="820702167"> <reference key="NSNextResponder" ref="753770525"/> - <int key="NSvFlags">274</int> + <int key="NSvFlags">256</int> <string key="NSFrameSize">{480, 270}</string> <reference key="NSSuperview" ref="753770525"/> <string key="NSClassName">HistoryView</string> @@ -239,9 +239,9 @@ </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>{{489, 207}, {480, 270}}</string> + <string>{{364, 310}, {480, 270}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{489, 207}, {480, 270}}</string> + <string>{{364, 310}, {480, 270}}</string> <boolean value="NO"/> <string>{196, 240}</string> <string>{{202, 428}, {480, 270}}</string> |