diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 18:44:51 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 18:44:51 +0000 |
commit | 16e785bf7ae2d1910d38e0e5843acd4648d50b21 (patch) | |
tree | 083c57b51daa703772ada68ed65a19e616a59e4a /chrome/browser/cocoa/tab_window_controller.mm | |
parent | 95b9162bf10740841d7803bcb978b87f52bfea3e (diff) | |
download | chromium_src-16e785bf7ae2d1910d38e0e5843acd4648d50b21.zip chromium_src-16e785bf7ae2d1910d38e0e5843acd4648d50b21.tar.gz chromium_src-16e785bf7ae2d1910d38e0e5843acd4648d50b21.tar.bz2 |
Flatten down to a single toolbar per window, significantly simplifying the tab strip as it now no longer needs to forward messages for everything. Created a toolbar controller to encapsulate much of the toolbar logic that was in the tab contents controller. Better parameterized the tab strip controller so that it could switch any view, not just the main window's content view, when switching tabs.
Review URL: http://codereview.chromium.org/65011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/tab_window_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/tab_window_controller.mm | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/tab_window_controller.mm b/chrome/browser/cocoa/tab_window_controller.mm index 691095f..456c973 100644 --- a/chrome/browser/cocoa/tab_window_controller.mm +++ b/chrome/browser/cocoa/tab_window_controller.mm @@ -13,19 +13,16 @@ @implementation TabWindowController @synthesize tabStripView = tabStripView_; +@synthesize tabContentArea = tabContentArea_; - (void)windowDidLoad { // Place the tab bar above the content box and add it to the view hierarchy // as a sibling of the content view so it can overlap with the window frame. - NSRect tabFrame = [contentBox_ frame]; + NSRect tabFrame = [tabContentArea_ frame]; tabFrame.origin = NSMakePoint(0, NSMaxY(tabFrame)); tabFrame.size.height = NSHeight([tabStripView_ frame]); [tabStripView_ setFrame:tabFrame]; [[[[self window] contentView] superview] addSubview:tabStripView_]; - - // tab switching will destroy the content area, so nil this out to ensure - // that nobody tries to use it. - contentBox_ = nil; } - (void)removeOverlay { @@ -45,6 +42,21 @@ [self setUseOverlay:YES]; } +- (NSArray*)viewsToMoveToOverlay { + return [NSArray arrayWithObject:[self tabStripView]]; +} + +// if |useOverlay| is true, we're moving views into the overlay's content +// area. If false, we're moving out of the overlay back into the window's +// content. +- (void)moveViewsBetweenWindowAndOverlay:(BOOL)useOverlay { + NSView* moveTo = useOverlay ? + [overlayWindow_ contentView] : [cachedContentView_ superview]; + NSArray* viewsToMove = [self viewsToMoveToOverlay]; + for (NSView* view in viewsToMove) + [moveTo addSubview:view]; +} + // If |useOverlay| is YES, creates a new overlay window and puts the tab strip // and the content area inside of it. This allows it to have a different opacity // from the title bar. If NO, returns everything to the previous state and @@ -66,7 +78,7 @@ NSView *contentView = [overlayWindow_ contentView]; [contentView addSubview:[self tabStripView]]; cachedContentView_ = [[self window] contentView]; - [contentView addSubview:cachedContentView_]; + [self moveViewsBetweenWindowAndOverlay:useOverlay]; [overlayWindow_ setHasShadow:YES]; [[self window] addChildWindow:overlayWindow_ ordered:NSWindowAbove]; [overlayWindow_ orderFront:nil]; @@ -75,7 +87,7 @@ DCHECK(cachedContentView_); [[self window] setHasShadow:YES]; [[self window] setContentView:cachedContentView_]; - [[cachedContentView_ superview] addSubview:[self tabStripView]]; + [self moveViewsBetweenWindowAndOverlay:useOverlay]; [[self window] makeFirstResponder:cachedContentView_]; [[self window] display]; [[self window] removeChildWindow:overlayWindow_]; |