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

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

Issue 1974733003: [Material][Mac] Remove NSVisualEffectView from windows with titlebars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/cocoa/tabs/tab_window_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/sdk_forward_declarations.h" 8 #import "base/mac/sdk_forward_declarations.h"
9 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 9 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
10 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 10 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
11 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 11 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h" 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h"
13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
14 #import "chrome/browser/ui/cocoa/themed_window.h" 14 #import "chrome/browser/ui/cocoa/themed_window.h"
15 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
16 #import "ui/base/cocoa/focus_tracker.h" 16 #import "ui/base/cocoa/focus_tracker.h"
17 #include "ui/base/material_design/material_design_controller.h" 17 #include "ui/base/material_design/material_design_controller.h"
18 #include "ui/base/theme_provider.h" 18 #include "ui/base/theme_provider.h"
19 19
20 @interface TabWindowController () 20 @interface TabWindowController ()
21 - (void)setUseOverlay:(BOOL)useOverlay; 21 - (void)setUseOverlay:(BOOL)useOverlay;
22 22
23 // The tab strip background view should always be inserted as the back-most 23 // The tab strip background view should always be inserted as the back-most
24 // subview of the root view. It cannot be a subview of the contentView, as that 24 // subview of the root view. It cannot be a subview of the contentView, as that
25 // would cause it to become layer backed, which would cause it to draw on top 25 // would cause it to become layer backed, which would cause it to draw on top
26 // of non-layer backed content like the window controls. 26 // of non-layer backed content like the window controls.
27 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window; 27 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window
28 titleBar:(BOOL)hasTitleBar;
28 @end 29 @end
29 30
30 @interface TabWindowOverlayWindow : NSWindow 31 @interface TabWindowOverlayWindow : NSWindow
31 @end 32 @end
32 33
33 @implementation TabWindowOverlayWindow 34 @implementation TabWindowOverlayWindow
34 35
35 - (const ui::ThemeProvider*)themeProvider { 36 - (const ui::ThemeProvider*)themeProvider {
36 return [[self parentWindow] themeProvider]; 37 return [[self parentWindow] themeProvider];
37 } 38 }
38 39
39 - (ThemedWindowStyle)themedWindowStyle { 40 - (ThemedWindowStyle)themedWindowStyle {
40 return [[self parentWindow] themedWindowStyle]; 41 return [[self parentWindow] themedWindowStyle];
41 } 42 }
42 43
43 - (NSPoint)themeImagePositionForAlignment:(ThemeImageAlignment)alignment { 44 - (NSPoint)themeImagePositionForAlignment:(ThemeImageAlignment)alignment {
44 return [[self parentWindow] themeImagePositionForAlignment:alignment]; 45 return [[self parentWindow] themeImagePositionForAlignment:alignment];
45 } 46 }
46 47
47 @end 48 @end
48 49
49 @implementation TabWindowController 50 @implementation TabWindowController
50 51
51 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip { 52 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip
53 titleBar:(BOOL)hasTitleBar {
52 const CGFloat kDefaultWidth = 750; 54 const CGFloat kDefaultWidth = 750;
53 const CGFloat kDefaultHeight = 600; 55 const CGFloat kDefaultHeight = 600;
54 56
55 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight); 57 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight);
56 base::scoped_nsobject<FramedBrowserWindow> window( 58 base::scoped_nsobject<FramedBrowserWindow> window(
57 [[FramedBrowserWindow alloc] initWithContentRect:contentRect 59 [[FramedBrowserWindow alloc] initWithContentRect:contentRect
58 hasTabStrip:hasTabStrip]); 60 hasTabStrip:hasTabStrip]);
59 [window setReleasedWhenClosed:YES]; 61 [window setReleasedWhenClosed:YES];
60 [window setAutorecalculatesKeyViewLoop:YES]; 62 [window setAutorecalculatesKeyViewLoop:YES];
61 63
(...skipping 19 matching lines...) Expand all
81 // moves to the child window and stays opaque. 83 // moves to the child window and stays opaque.
82 NSView* windowView = [window contentView]; 84 NSView* windowView = [window contentView];
83 tabStripBackgroundView_.reset([[TabStripBackgroundView alloc] 85 tabStripBackgroundView_.reset([[TabStripBackgroundView alloc]
84 initWithFrame:NSMakeRect(0, 86 initWithFrame:NSMakeRect(0,
85 NSMaxY([windowView bounds]) - 87 NSMaxY([windowView bounds]) -
86 kBrowserFrameViewPaintHeight, 88 kBrowserFrameViewPaintHeight,
87 NSWidth([windowView bounds]), 89 NSWidth([windowView bounds]),
88 kBrowserFrameViewPaintHeight)]); 90 kBrowserFrameViewPaintHeight)]);
89 [tabStripBackgroundView_ 91 [tabStripBackgroundView_
90 setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; 92 setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
91 [self insertTabStripBackgroundViewIntoWindow:window]; 93 [self insertTabStripBackgroundViewIntoWindow:window titleBar:hasTitleBar];
92 94
93 tabStripView_.reset([[TabStripView alloc] 95 tabStripView_.reset([[TabStripView alloc]
94 initWithFrame:NSMakeRect( 96 initWithFrame:NSMakeRect(
95 0, 0, kDefaultWidth, chrome::kTabStripHeight)]); 97 0, 0, kDefaultWidth, chrome::kTabStripHeight)]);
96 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | 98 [tabStripView_ setAutoresizingMask:NSViewWidthSizable |
97 NSViewMinYMargin]; 99 NSViewMinYMargin];
98 if (hasTabStrip) 100 if (hasTabStrip)
99 [windowView addSubview:tabStripView_]; 101 [windowView addSubview:tabStripView_];
100 } 102 }
101 return self; 103 return self;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return YES; 330 return YES;
329 } 331 }
330 332
331 // Tell the window that it needs to call performClose: as soon as the current 333 // Tell the window that it needs to call performClose: as soon as the current
332 // drag is complete. This prevents a window (and its overlay) from going away 334 // drag is complete. This prevents a window (and its overlay) from going away
333 // during a drag. 335 // during a drag.
334 - (void)deferPerformClose { 336 - (void)deferPerformClose {
335 closeDeferred_ = YES; 337 closeDeferred_ = YES;
336 } 338 }
337 339
338 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window { 340 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window
341 titleBar:(BOOL)hasTitleBar {
339 DCHECK(tabStripBackgroundView_); 342 DCHECK(tabStripBackgroundView_);
340 NSView* rootView = [[window contentView] superview]; 343 NSView* rootView = [[window contentView] superview];
341 344
342 // In Material Design on 10.10 and higher, the top portion of the window is 345 // In Material Design on 10.10 and higher, the top portion of the window is
343 // blurred using an NSVisualEffectView. 346 // blurred using an NSVisualEffectView.
344 Class nsVisualEffectViewClass = NSClassFromString(@"NSVisualEffectView"); 347 Class nsVisualEffectViewClass = NSClassFromString(@"NSVisualEffectView");
345 if (!ui::MaterialDesignController::IsModeMaterial() || 348 if (!ui::MaterialDesignController::IsModeMaterial() ||
346 !nsVisualEffectViewClass) { 349 !nsVisualEffectViewClass) {
347 [rootView addSubview:tabStripBackgroundView_ 350 [rootView addSubview:tabStripBackgroundView_
348 positioned:NSWindowBelow 351 positioned:NSWindowBelow
349 relativeTo:nil]; 352 relativeTo:nil];
350 return; 353 return;
351 } 354 }
352 355
356 [window setTitlebarAppearsTransparent:YES];
shrike 2016/05/13 18:30:21 What happens in the title-bar case if you don't do
357
358 // If the window has a normal titlebar, then do not add NSVisualEffectView.
359 if (hasTitleBar)
360 return;
361
353 base::scoped_nsobject<NSVisualEffectView> visualEffectView( 362 base::scoped_nsobject<NSVisualEffectView> visualEffectView(
354 [[nsVisualEffectViewClass alloc] 363 [[nsVisualEffectViewClass alloc]
355 initWithFrame:[tabStripBackgroundView_ frame]]); 364 initWithFrame:[tabStripBackgroundView_ frame]]);
356 DCHECK(visualEffectView); 365 DCHECK(visualEffectView);
357 366
358 [visualEffectView setAutoresizingMask: 367 [visualEffectView setAutoresizingMask:
359 [tabStripBackgroundView_ autoresizingMask]]; 368 [tabStripBackgroundView_ autoresizingMask]];
360 [tabStripBackgroundView_ 369 [tabStripBackgroundView_
361 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 370 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
362 371
363 // Set to a default appearance and material. If this is an Incognito window 372 // Set to a default appearance and material. If this is an Incognito window
364 // the material and vibrancy should be dark but this method gets called at 373 // the material and vibrancy should be dark but this method gets called at
365 // the start of -[BrowserWindowController initWithBrowser:takeOwnership:], 374 // the start of -[BrowserWindowController initWithBrowser:takeOwnership:],
366 // before the |browser_| ivar has been set. Without a browser object we 375 // before the |browser_| ivar has been set. Without a browser object we
367 // can't check the window's theme. The final setup happens in 376 // can't check the window's theme. The final setup happens in
368 // -[TabStripView setController:], at which point we have access to the theme. 377 // -[TabStripView setController:], at which point we have access to the theme.
369 [visualEffectView setAppearance: 378 [visualEffectView setAppearance:
370 [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]]; 379 [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]];
371 [visualEffectView setMaterial:NSVisualEffectMaterialLight]; 380 [visualEffectView setMaterial:NSVisualEffectMaterialLight];
372 [visualEffectView setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; 381 [visualEffectView setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
373 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState]; 382 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState];
374 383
375 [window setTitlebarAppearsTransparent:YES];
376
377 [rootView addSubview:visualEffectView 384 [rootView addSubview:visualEffectView
378 positioned:NSWindowBelow 385 positioned:NSWindowBelow
379 relativeTo:nil]; 386 relativeTo:nil];
380 387
381 // Make the |tabStripBackgroundView_| a child of the NSVisualEffectView. 388 // Make the |tabStripBackgroundView_| a child of the NSVisualEffectView.
382 [tabStripBackgroundView_ setFrame:[visualEffectView bounds]]; 389 [tabStripBackgroundView_ setFrame:[visualEffectView bounds]];
383 [visualEffectView addSubview:tabStripBackgroundView_]; 390 [visualEffectView addSubview:tabStripBackgroundView_];
384 } 391 }
385 392
386 // Called when the size of the window content area has changed. Override to 393 // Called when the size of the window content area has changed. Override to
387 // position specific views. Base class implementation does nothing. 394 // position specific views. Base class implementation does nothing.
388 - (void)layoutSubviews { 395 - (void)layoutSubviews {
389 NOTIMPLEMENTED(); 396 NOTIMPLEMENTED();
390 } 397 }
391 398
392 @end 399 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698