Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/cocoa/tab_window_controller.mm

Issue 258012: [Mac] Insert views into the proper place in the view hierarchy when tearing o... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/tab_window_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/tab_window_controller.h" 5 #import "chrome/browser/cocoa/tab_window_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/cocoa/tab_strip_view.h" 8 #import "chrome/browser/cocoa/tab_strip_view.h"
9 9
10 @interface TabWindowController(PRIVATE) 10 @interface TabWindowController(PRIVATE)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 object:nil]; 53 object:nil];
54 [self performSelector:@selector(removeOverlay) 54 [self performSelector:@selector(removeOverlay)
55 withObject:nil 55 withObject:nil
56 afterDelay:delay]; 56 afterDelay:delay];
57 } 57 }
58 58
59 - (void)showOverlay { 59 - (void)showOverlay {
60 [self setUseOverlay:YES]; 60 [self setUseOverlay:YES];
61 } 61 }
62 62
63 - (NSArray*)viewsToMoveToOverlay {
64 return [NSArray arrayWithObjects:[self tabStripView],
65 [self tabContentArea], nil];
66 }
67
68 // if |useOverlay| is true, we're moving views into the overlay's content 63 // if |useOverlay| is true, we're moving views into the overlay's content
69 // area. If false, we're moving out of the overlay back into the window's 64 // area. If false, we're moving out of the overlay back into the window's
70 // content. 65 // content.
71 - (void)moveViewsBetweenWindowAndOverlay:(BOOL)useOverlay { 66 - (void)moveViewsBetweenWindowAndOverlay:(BOOL)useOverlay {
72 NSView* moveTo = useOverlay ? 67 if (useOverlay) {
73 [overlayWindow_ contentView] : [cachedContentView_ superview]; 68 [[[overlayWindow_ contentView] superview] addSubview:[self tabStripView]];
74 NSArray* viewsToMove = [self viewsToMoveToOverlay]; 69 // Add the original window's content view as a subview of the overlay
75 for (NSView* view in viewsToMove) 70 // window's content view. We cannot simply use setContentView: here because
76 [moveTo addSubview:view]; 71 // the overlay window has a different content size (due to it being
72 // borderless).
73 [[overlayWindow_ contentView] addSubview:cachedContentView_];
74 } else {
75 [[[[self window] contentView] superview] addSubview:[self tabStripView]];
76 [[self window] setContentView:cachedContentView_];
77 }
77 } 78 }
78 79
79 // If |useOverlay| is YES, creates a new overlay window and puts the tab strip 80 // If |useOverlay| is YES, creates a new overlay window and puts the tab strip
80 // and the content area inside of it. This allows it to have a different opacity 81 // and the content area inside of it. This allows it to have a different opacity
81 // from the title bar. If NO, returns everything to the previous state and 82 // from the title bar. If NO, returns everything to the previous state and
82 // destroys the overlay window until it's needed again. The tab strip and window 83 // destroys the overlay window until it's needed again. The tab strip and window
83 // contents are returned to the original window. 84 // contents are returned to the original window.
84 - (void)setUseOverlay:(BOOL)useOverlay { 85 - (void)setUseOverlay:(BOOL)useOverlay {
85 [NSObject cancelPreviousPerformRequestsWithTarget:self 86 [NSObject cancelPreviousPerformRequestsWithTarget:self
86 selector:@selector(removeOverlay) 87 selector:@selector(removeOverlay)
87 object:nil]; 88 object:nil];
88 if (useOverlay && !overlayWindow_) { 89 if (useOverlay && !overlayWindow_) {
89 DCHECK(!cachedContentView_); 90 DCHECK(!cachedContentView_);
90 overlayWindow_ = [[NSPanel alloc] initWithContentRect:[[self window] frame] 91 overlayWindow_ = [[NSPanel alloc] initWithContentRect:[[self window] frame]
91 styleMask:NSBorderlessWindowMask 92 styleMask:NSBorderlessWindowMask
92 backing:NSBackingStoreBuffered 93 backing:NSBackingStoreBuffered
93 defer:YES]; 94 defer:YES];
94 [overlayWindow_ setTitle:@"overlay"]; 95 [overlayWindow_ setTitle:@"overlay"];
95 [overlayWindow_ setBackgroundColor:[NSColor clearColor]]; 96 [overlayWindow_ setBackgroundColor:[NSColor clearColor]];
96 [overlayWindow_ setOpaque:NO]; 97 [overlayWindow_ setOpaque:NO];
97 [overlayWindow_ setDelegate:self]; 98 [overlayWindow_ setDelegate:self];
98 NSView *contentView = [overlayWindow_ contentView];
99 [contentView addSubview:[self tabStripView]];
100 cachedContentView_ = [[self window] contentView]; 99 cachedContentView_ = [[self window] contentView];
101 [self moveViewsBetweenWindowAndOverlay:useOverlay]; 100 [self moveViewsBetweenWindowAndOverlay:useOverlay];
102 [[self window] addChildWindow:overlayWindow_ ordered:NSWindowAbove]; 101 [[self window] addChildWindow:overlayWindow_ ordered:NSWindowAbove];
103 [overlayWindow_ orderFront:nil]; 102 [overlayWindow_ orderFront:nil];
104 } else if (!useOverlay && overlayWindow_) { 103 } else if (!useOverlay && overlayWindow_) {
105 DCHECK(cachedContentView_); 104 DCHECK(cachedContentView_);
106 [[self window] setContentView:cachedContentView_]; 105 [[self window] setContentView:cachedContentView_];
107 [self moveViewsBetweenWindowAndOverlay:useOverlay]; 106 [self moveViewsBetweenWindowAndOverlay:useOverlay];
108 [[self window] makeFirstResponder:cachedContentView_]; 107 [[self window] makeFirstResponder:cachedContentView_];
109 [[self window] display]; 108 [[self window] display];
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 202 }
204 203
205 // Tell the window that it needs to call performClose: as soon as the current 204 // Tell the window that it needs to call performClose: as soon as the current
206 // drag is complete. This prevents a window (and its overlay) from going away 205 // drag is complete. This prevents a window (and its overlay) from going away
207 // during a drag. 206 // during a drag.
208 - (void)deferPerformClose { 207 - (void)deferPerformClose {
209 closeDeferred_ = YES; 208 closeDeferred_ = YES;
210 } 209 }
211 210
212 @end 211 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/tab_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698