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

Side by Side Diff: chrome/browser/ui/cocoa/hover_close_button.mm

Issue 1310183005: Mac: Fix missing focus rings on toolbar, profile, and tab buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snapshot
Patch Set: Fix extension buttons Created 5 years, 3 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/hover_close_button.h" 5 #import "chrome/browser/ui/cocoa/hover_close_button.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "chrome/grit/generated_resources.h" 8 #include "chrome/grit/generated_resources.h"
9 #include "grit/theme_resources.h" 9 #include "grit/theme_resources.h"
10 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMKeyValueAnimation.h" 10 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMKeyValueAnimation.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 NSRect imageRect = NSZeroRect; 89 NSRect imageRect = NSZeroRect;
90 imageRect.size = [image size]; 90 imageRect.size = [image size];
91 91
92 NSRect destRect = [self bounds]; 92 NSRect destRect = [self bounds];
93 destRect.origin.y = floor((NSHeight(destRect) / 2) 93 destRect.origin.y = floor((NSHeight(destRect) / 2)
94 - (NSHeight(imageRect) / 2)); 94 - (NSHeight(imageRect) / 2));
95 destRect.size = imageRect.size; 95 destRect.size = imageRect.size;
96 96
97 switch(self.hoverState) { 97 switch(self.hoverState) {
98 case kHoverStateMouseOver: 98 case kHoverStateMouseOver:
99 [image drawInRect:destRect
100 fromRect:imageRect
101 operation:NSCompositeSourceOver
102 fraction:1.0
103 respectFlipped:YES
104 hints:nil];
105 break;
106
107 case kHoverStateMouseDown: 99 case kHoverStateMouseDown:
108 [image drawInRect:destRect 100 [image drawInRect:destRect
109 fromRect:imageRect 101 fromRect:imageRect
110 operation:NSCompositeSourceOver 102 operation:NSCompositeSourceOver
111 fraction:1.0 103 fraction:1.0
112 respectFlipped:YES 104 respectFlipped:YES
113 hints:nil]; 105 hints:nil];
114 break; 106 break;
115 107
116 case kHoverStateNone: { 108 case kHoverStateNone: {
(...skipping 16 matching lines...) Expand all
133 fromRect:imageRect 125 fromRect:imageRect
134 operation:NSCompositeSourceOver 126 operation:NSCompositeSourceOver
135 fraction:value 127 fraction:value
136 respectFlipped:YES 128 respectFlipped:YES
137 hints:nil]; 129 hints:nil];
138 break; 130 break;
139 } 131 }
140 } 132 }
141 } 133 }
142 134
135 - (void)drawFocusRingMask {
136 // Match the hover image's shape.
137 NSRect circleRect = NSInsetRect([self bounds], 2, 2);
138 [[NSBezierPath bezierPathWithOvalInRect:circleRect] fill];
139 }
140
143 - (void)setFadeOutValue:(CGFloat)value { 141 - (void)setFadeOutValue:(CGFloat)value {
144 [self setNeedsDisplay]; 142 [self setNeedsDisplay];
145 } 143 }
146 144
147 - (NSImage*)imageForHoverState:(HoverState)hoverState { 145 - (NSImage*)imageForHoverState:(HoverState)hoverState {
148 int imageID = IDR_CLOSE_1; 146 int imageID = IDR_CLOSE_1;
149 switch (hoverState) { 147 switch (hoverState) {
150 case kHoverStateNone: 148 case kHoverStateNone:
151 imageID = IDR_CLOSE_1; 149 imageID = IDR_CLOSE_1;
152 break; 150 break;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 break; 239 break;
242 case kHoverStateMouseDown: 240 case kHoverStateMouseDown:
243 imageID = IDR_CLOSE_DIALOG_P; 241 imageID = IDR_CLOSE_DIALOG_P;
244 break; 242 break;
245 } 243 }
246 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 244 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
247 return bundle.GetNativeImageNamed(imageID).ToNSImage(); 245 return bundle.GetNativeImageNamed(imageID).ToNSImage();
248 } 246 }
249 247
250 @end 248 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/gradient_button_cell.mm ('k') | chrome/browser/ui/cocoa/image_button_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698