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

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

Issue 1857093002: [Mac] Fix tabstrip background opacity problem when dragging tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rework tab dragging detection. Created 4 years, 8 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
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_strip_view.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
6 6
7 #include <cmath> // floor 7 #include <cmath> // floor
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 12 matching lines...) Expand all
23 #import "ui/base/cocoa/nsgraphics_context_additions.h" 23 #import "ui/base/cocoa/nsgraphics_context_additions.h"
24 #import "ui/base/cocoa/nsview_additions.h" 24 #import "ui/base/cocoa/nsview_additions.h"
25 #include "ui/base/l10n/l10n_util_mac.h" 25 #include "ui/base/l10n/l10n_util_mac.h"
26 #include "ui/base/material_design/material_design_controller.h" 26 #include "ui/base/material_design/material_design_controller.h"
27 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 27 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
28 28
29 @implementation TabStripView 29 @implementation TabStripView
30 30
31 @synthesize dropArrowShown = dropArrowShown_; 31 @synthesize dropArrowShown = dropArrowShown_;
32 @synthesize dropArrowPosition = dropArrowPosition_; 32 @synthesize dropArrowPosition = dropArrowPosition_;
33 @synthesize inATabDraggingOverlayWindow = inATabDraggingOverlayWindow_;
33 34
34 - (id)initWithFrame:(NSRect)frame { 35 - (id)initWithFrame:(NSRect)frame {
35 self = [super initWithFrame:frame]; 36 self = [super initWithFrame:frame];
36 if (self) { 37 if (self) {
37 newTabButton_.reset([[NewTabButton alloc] initWithFrame: 38 newTabButton_.reset([[NewTabButton alloc] initWithFrame:
38 NSMakeRect(295, 0, 40, 27)]); 39 NSMakeRect(295, 0, 40, 27)]);
39 [newTabButton_ setToolTip:l10n_util::GetNSString(IDS_TOOLTIP_NEW_TAB)]; 40 [newTabButton_ setToolTip:l10n_util::GetNSString(IDS_TOOLTIP_NEW_TAB)];
40 41
41 // Set lastMouseUp_ = -1000.0 so that timestamp-lastMouseUp_ is big unless 42 // Set lastMouseUp_ = -1000.0 so that timestamp-lastMouseUp_ is big unless
42 // lastMouseUp_ has been reset. 43 // lastMouseUp_ has been reset.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 112 }
112 113
113 - (void)drawRect:(NSRect)dirtyRect { 114 - (void)drawRect:(NSRect)dirtyRect {
114 const ui::ThemeProvider* themeProvider = [[self window] themeProvider]; 115 const ui::ThemeProvider* themeProvider = [[self window] themeProvider];
115 bool hasCustomThemeImage = themeProvider && 116 bool hasCustomThemeImage = themeProvider &&
116 themeProvider->HasCustomImage(IDR_THEME_FRAME); 117 themeProvider->HasCustomImage(IDR_THEME_FRAME);
117 bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial(); 118 bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial();
118 BOOL supportsVibrancy = [self visualEffectView] != nil; 119 BOOL supportsVibrancy = [self visualEffectView] != nil;
119 BOOL isMainWindow = [[self window] isMainWindow]; 120 BOOL isMainWindow = [[self window] isMainWindow];
120 121
121 if (themeProvider && !hasCustomThemeImage && isModeMaterial) { 122 // If in Material Design mode, decrease the tabstrip background's translucency
123 // by overlaying it with a partially-transparent gray (but only if not themed,
124 // and not being used to drag tabs between browser windows). The gray is
125 // somewhat opaque for Incognito mode, very opaque for non-Incognito mode, and
126 // completely opaque when the window is not active.
127 if (themeProvider && !hasCustomThemeImage && isModeMaterial &&
128 !inATabDraggingOverlayWindow_) {
122 NSColor* theColor = nil; 129 NSColor* theColor = nil;
123 if (isMainWindow) { 130 if (isMainWindow) {
124 // The vibrancy overlay makes the Incognito NSVisualEffectView
125 // somewhat darker, and the non-Incognito NSVisualEffectView much darker.
126 if (supportsVibrancy && 131 if (supportsVibrancy &&
127 !themeProvider->HasCustomColor(ThemeProperties::COLOR_FRAME)) { 132 !themeProvider->HasCustomColor(ThemeProperties::COLOR_FRAME)) {
128 theColor = themeProvider->GetNSColor( 133 theColor = themeProvider->GetNSColor(
129 ThemeProperties::COLOR_FRAME_VIBRANCY_OVERLAY); 134 ThemeProperties::COLOR_FRAME_VIBRANCY_OVERLAY);
130 } else { 135 } else {
131 theColor = themeProvider->GetNSColor(ThemeProperties::COLOR_FRAME); 136 theColor = themeProvider->GetNSColor(ThemeProperties::COLOR_FRAME);
132 } 137 }
133 } else { 138 } else {
134 // Inactive MD windows always draw a solid color.
135 theColor = themeProvider->GetNSColor( 139 theColor = themeProvider->GetNSColor(
136 ThemeProperties::COLOR_FRAME_INACTIVE); 140 ThemeProperties::COLOR_FRAME_INACTIVE);
137 } 141 }
138 142
139 if (theColor) { 143 if (theColor) {
140 [theColor set]; 144 [theColor set];
141 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver); 145 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver);
142 } 146 }
143 } 147 }
144 148
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } else { 413 } else {
410 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState]; 414 [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState];
411 } 415 }
412 } 416 }
413 417
414 - (void)windowDidChangeActive { 418 - (void)windowDidChangeActive {
415 [self setNeedsDisplay:YES]; 419 [self setNeedsDisplay:YES];
416 } 420 }
417 421
418 @end 422 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_view.h ('k') | chrome/browser/ui/cocoa/tabs/tab_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698