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

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

Issue 688523002: [Cocoa] Tab audio mute control, behind a switch (off by default). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent TabStripController from unconditionally causing creation of MediaIndicatorButton. Created 6 years, 1 month 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_view.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/sdk_forward_declarations.h" 9 #include "base/mac/sdk_forward_declarations.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "chrome/browser/themes/theme_service.h" 11 #include "chrome/browser/themes/theme_service.h"
12 #import "chrome/browser/ui/cocoa/tabs/media_indicator_button.h"
12 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 13 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
13 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" 14 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
14 #import "chrome/browser/ui/cocoa/themed_window.h" 15 #import "chrome/browser/ui/cocoa/themed_window.h"
15 #import "chrome/browser/ui/cocoa/view_id_util.h" 16 #import "chrome/browser/ui/cocoa/view_id_util.h"
16 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
17 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
18 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMFadeTruncatingTextFiel dCell.h" 19 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMFadeTruncatingTextFiel dCell.h"
19 #import "ui/base/cocoa/nsgraphics_context_additions.h" 20 #import "ui/base/cocoa/nsgraphics_context_additions.h"
20 #import "ui/base/cocoa/nsview_additions.h" 21 #import "ui/base/cocoa/nsview_additions.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 [self adjustGlowValue]; 149 [self adjustGlowValue];
149 } 150 }
150 151
151 - (void)setTrackingEnabled:(BOOL)enabled { 152 - (void)setTrackingEnabled:(BOOL)enabled {
152 if (![closeButton_ isHidden]) { 153 if (![closeButton_ isHidden]) {
153 [closeButton_ setTrackingEnabled:enabled]; 154 [closeButton_ setTrackingEnabled:enabled];
154 } 155 }
155 } 156 }
156 157
157 // Determines which view a click in our frame actually hit. It's either this 158 // Determines which view a click in our frame actually hit. It's either this
158 // view or our child close button. 159 // view or one of the child buttons.
159 - (NSView*)hitTest:(NSPoint)aPoint { 160 - (NSView*)hitTest:(NSPoint)aPoint {
161 NSView* const defaultHitTestResult = [super hitTest:aPoint];
162 if ([defaultHitTestResult isKindOfClass:[NSButton class]])
163 return defaultHitTestResult;
164
160 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; 165 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]];
161 if (![closeButton_ isHidden])
162 if (NSPointInRect(viewPoint, [closeButton_ frame])) return closeButton_;
163
164 NSRect pointRect = NSMakeRect(viewPoint.x, viewPoint.y, 1, 1); 166 NSRect pointRect = NSMakeRect(viewPoint.x, viewPoint.y, 1, 1);
165 167
166 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 168 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
167 NSImage* left = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage(); 169 NSImage* left = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage();
168 if (viewPoint.x < [left size].width) { 170 if (viewPoint.x < [left size].width) {
169 NSRect imageRect = NSMakeRect(0, 0, [left size].width, [left size].height); 171 NSRect imageRect = NSMakeRect(0, 0, [left size].width, [left size].height);
170 if ([left hitTestRect:pointRect withImageDestinationRect:imageRect 172 if ([left hitTestRect:pointRect withImageDestinationRect:imageRect
171 context:nil hints:nil flipped:NO]) { 173 context:nil hints:nil flipped:NO]) {
172 return self; 174 return self;
173 } 175 }
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; 786 CGFloat middleWidth = tabWidth - leftWidth - rightWidth;
785 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); 787 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight);
786 [[NSColor whiteColor] setFill]; 788 [[NSColor whiteColor] setFill];
787 NSRectFill(middleRect); 789 NSRectFill(middleRect);
788 790
789 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); 791 maskCache_.reset(CGBitmapContextCreateImage(maskContext));
790 return maskCache_; 792 return maskCache_;
791 } 793 }
792 794
793 @end // @implementation TabView(Private) 795 @end // @implementation TabView(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698