From e21cab6a7fc68b311a79a067b408da23173fb255 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Mon, 24 Jan 2011 15:01:34 +0000 Subject: Added local history overlay svn path=/trunk/netsurf/; revision=11479 --- cocoa/BrowserView.m | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'cocoa/BrowserView.m') diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m index e20c053a6..ba0874c3a 100644 --- a/cocoa/BrowserView.m +++ b/cocoa/BrowserView.m @@ -17,6 +17,7 @@ */ #import "BrowserView.h" +#import "HistoryView.h" #import "desktop/browser.h" #import "desktop/history_core.h" @@ -27,6 +28,11 @@ #import "cocoa/font.h" +@interface BrowserView () + +@end + + @implementation BrowserView @synthesize browser; @@ -39,6 +45,8 @@ static const NSTimeInterval CaretBlinkTime = 0.8; - (void) dealloc; { [self setCaretTimer: nil]; + [history release]; + [super dealloc]; } @@ -173,6 +181,11 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) - (void) mouseUp: (NSEvent *)theEvent; { + if (historyVisible) { + [self toggleHistory]; + return; + } + NSPoint location = [self convertMousePoint: theEvent]; browser_mouse_state modifierFlags = cocoa_mouse_flags_for_event( theEvent ); @@ -326,6 +339,28 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) browser_window_key_press( browser, KEY_PASTE ); } +- (void) toggleHistory; +{ + if (!historyVisible) { + if (nil == history) { + history = [[HistoryView alloc] initWithBrowser: browser]; + [history setDelegate: self]; + } + [self addSubview: history]; + + historyVisible = YES; + } else { + [history removeFromSuperview]; + historyVisible = NO; + } +} + + +- (void) historyViewDidSelectItem: (HistoryView *) history; +{ + [history removeFromSuperview]; + historyVisible = NO; +} - (BOOL) acceptsFirstResponder; { -- cgit v1.2.3