beginnings of new bookmark manager, off by default

git-svn-id: svn://10.0.0.236/trunk@139033 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pinkerton%netscape.com 2003-03-06 19:04:15 +00:00
parent 96c3b7d967
commit 99bd076da3
7 changed files with 137 additions and 7 deletions

View File

@ -9,6 +9,7 @@
SUPERCLASS = NSTextField;
},
{CLASS = BookmarkItem; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = BookmarkManagerView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
{
ACTIONS = {
addBookmark = id;
@ -41,9 +42,11 @@
},
{CLASS = BrowserContainerView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
{
ACTIONS = {toggleBookmarkManager = id; };
CLASS = BrowserContentView;
LANGUAGE = ObjC;
OUTLETS = {
mBookmarkManagerView = NSView;
mBookmarksToolbar = BookmarksToolbar;
mBrowserContainerView = NSView;
mStatusBar = NSView;
@ -93,6 +96,7 @@
printDocument = id;
reload = id;
reloadSendersTab = id;
reloadWithNewCharset = id;
saveFrameAs = id;
saveImageAs = id;
saveLinkAs = id;
@ -100,6 +104,7 @@
sendURL = id;
smallerTextSize = id;
stop = id;
toggleBookmarkManager = id;
toggleSidebar = id;
viewOnlyThisImage = id;
viewPageSource = id;
@ -137,7 +142,7 @@
mStatusBar = NSView;
mTabBrowser = BrowserTabView;
mTabMenu = NSMenu;
mURLBar = NSTextField;
mURLBar = AutoCompleteTextField;
};
SUPERCLASS = NSWindowController;
},

View File

@ -3,15 +3,15 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>65 36 653 383 0 0 1152 848 </string>
<string>185 81 653 383 0 0 1280 832 </string>
<key>IBEditorPositions</key>
<dict>
<key>124</key>
<string>83 451 170 144 0 0 1280 832 </string>
<key>160</key>
<string>496 172 195 666 0 0 1152 848 </string>
<string>542 156 195 666 0 0 1280 832 </string>
<key>28</key>
<string>567 326 195 457 0 0 1280 832 </string>
<string>542 342 195 457 0 0 1280 832 </string>
<key>297</key>
<string>82 354 213 294 0 0 1280 832 </string>
<key>314</key>
@ -26,6 +26,8 @@
<string>493 520 343 68 0 0 1280 832 </string>
<key>654</key>
<string>159 629 198 144 0 0 1280 832 </string>
<key>731</key>
<string>265 306 654 459 0 0 1280 832 </string>
</dict>
<key>IBFramework Version</key>
<string>291.0</string>
@ -41,6 +43,10 @@
<string>8</string>
<key>IBLockedObjects</key>
<array/>
<key>IBOpenObjects</key>
<array>
<integer>731</integer>
</array>
<key>IBSystem Version</key>
<string>6I32</string>
</dict>

View File

@ -44,9 +44,16 @@
@interface BrowserContentView : NSView
{
IBOutlet BookmarksToolbar *mBookmarksToolbar;
IBOutlet NSView *mBrowserContainerView;
IBOutlet NSView *mBrowserContainerView; // manages tabs and web content
IBOutlet NSView *mBookmarkManagerView; // swapped in and out by activating bm manager, replacing browser container
IBOutlet NSView *mStatusBar;
NSView* mCurrentContentView; // either the bookmark manager or the browser container, whichever is visible
}
- (IBAction) toggleBookmarkManager:(id)sender;
- (BOOL) isBookmarkManagerVisible;
@end
@ -54,3 +61,9 @@
{
}
@end
@interface BookmarkManagerView : NSView
{
}
@end

View File

@ -91,6 +91,21 @@
@implementation BrowserContentView
- (void) dealloc
{
// release the browser content area if it's not visible since we
// had to retain it to keep it around outside the view hierarchy.
if ([self isBookmarkManagerVisible])
[mBrowserContainerView release];
}
- (void)awakeFromNib
{
// at load time, the browser is the main content area. this can
// change if the user shows the bookmark manager.
mCurrentContentView = mBrowserContainerView;
}
- (void)resizeSubviewsWithOldSize:(NSSize)oldFrameSize
{
float bmToolbarHeight = 0.0;
@ -130,7 +145,12 @@
browserRect.size.height -= statusBarHeight;
browserRect.origin.y += statusBarHeight;
[mBrowserContainerView setFrame:browserRect];
// resize our current content area, whatever it may be. We will
// take care of resizing the other view when we toggle it to
// match the size to avoid taking the hit of resizing it when it's
// not visible.
[mCurrentContentView setFrame:browserRect];
NSLog(@"resizing to %f %f", browserRect.size.width, browserRect.size.height);
}
@ -150,6 +170,35 @@
[super didAddSubview:subview];
}
- (IBAction) toggleBookmarkManager:(id)sender
{
NSView* newView = [self isBookmarkManagerVisible] ? mBrowserContainerView : mBookmarkManagerView;
// detach the old view
[mCurrentContentView retain];
[mCurrentContentView removeFromSuperview];
// add in the new view. Need to resize it _after_ we've added it because
// our tab view optimizes away resizes to content views when they're not
// visible.
[self addSubview:newView];
[newView setFrame:[mCurrentContentView frame]];
[newView release];
mCurrentContentView = newView;
// don't worry about who has focus, the BWC will take care of that.
}
//
// -isBookmarkManagerVisible
//
// YES if the bookmark manager is currently visible in this window.
//
- (BOOL) isBookmarkManagerVisible
{
return mCurrentContentView == mBookmarkManagerView;
}
@end
#pragma mark -
@ -175,5 +224,23 @@
@end
#pragma mark -
@implementation BookmarkManagerView
- (BOOL) isOpaque
{
return YES;
}
- (void)drawRect:(NSRect)aRect
{
[[NSColor windowBackgroundColor] set];
NSRectFill(aRect);
[[NSColor lightGrayColor] set];
NSFrameRect([self bounds]);
}
@end

View File

@ -340,5 +340,7 @@ typedef enum
// Accessor for the bm data source
- (BookmarksDataSource*)bookmarksDataSource;
- (void)toggleBookmarkManager:(id)sender;
@end

View File

@ -39,8 +39,8 @@
#import "BrowserWindowController.h"
#import "BrowserWrapper.h"
#import "BrowserContentViews.h"
#import "BrowserWrapper.h"
#import "PreferenceManager.h"
#import "BookmarksDataSource.h"
#import "HistoryDataSource.h"
@ -78,6 +78,8 @@
#include <QuickTime/QuickTime.h>
#define USE_DRAWER_FOR_BOOKMARKS 1
static NSString *BrowserToolbarIdentifier = @"Browser Window Toolbar";
static NSString *BackToolbarItemIdentifier = @"Back Toolbar Item";
static NSString *ForwardToolbarItemIdentifier = @"Forward Toolbar Item";
@ -1241,6 +1243,7 @@ static NSArray* sToolbarDefaults = nil;
- (IBAction)toggleSidebar:(id)aSender
{
#if USE_DRAWER_FOR_BOOKMARKS
// Force the window to shrink and move if necessary in order to accommodate the sidebar. We check
// if it will fit on either the left or on the right, and if it won't, shrink the window. We
// used to do this in |drawerWillOpen:| but the problem is that as soon as wel tell cocoa to
@ -1275,6 +1278,9 @@ static NSArray* sToolbarDefaults = nil;
}
[mSidebarDrawer toggle:aSender];
#else
[self toggleBookmarkManager:self];
#endif
}
// map command-left arrow to 'back'
@ -1516,6 +1522,7 @@ static NSArray* sToolbarDefaults = nil;
- (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)aTabViewItem
{
NSLog(@"Notify: did select %@", [aTabViewItem label]);
// we'll get called for the sidebar tabs as well. ignore any calls coming from
// there, we're only interested in the browser tabs.
if (aTabView != mTabBrowser)
@ -2100,6 +2107,36 @@ static NSArray* sToolbarDefaults = nil;
}
//
// -toggleBookmarkManager
//
// switch between a gecko content view and the in-window bookmark manager.
// This changes the current focus and forces it into the content area.
//
- (void)toggleBookmarkManager:(id)sender
{
// deactivate any gecko view that might think it has focus
if ([self isResponderGeckoView:[[self window] firstResponder]]) {
CHBrowserView* browserView = [mBrowserView getBrowserView];
if (browserView)
[browserView setActive:NO];
}
// swap out between content and bookmarks.
[mContentView toggleBookmarkManager:sender];
// if we're now showing the bm manager, force it to have focus,
// otherwise give focus back to gecko.
if ( [mContentView isBookmarkManagerVisible] ) {
//XXX set focus to appropriate area of bm manager
}
else {
CHBrowserView* browserView = [mBrowserView getBrowserView];
if (browserView)
[browserView setActive:YES];
}
}
@end
#pragma mark -