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

Side by Side Diff: chrome/browser/ui/cocoa/passwords/credential_item_button.mm

Issue 2259533006: Tune the account chooser on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 4 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/passwords/account_chooser_view_controller.mm ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/passwords/credential_item_button.h" 5 #import "chrome/browser/ui/cocoa/passwords/credential_item_button.h"
6 6
7 #import "base/mac/scoped_nsobject.h" 7 #import "base/mac/scoped_nsobject.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h" 9 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h"
10 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
11 #include "grit/theme_resources.h" 11 #include "grit/theme_resources.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/image/image_skia_util_mac.h" 15 #include "ui/gfx/image/image_skia_util_mac.h"
16 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 16 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
17 17
18 namespace { 18 namespace {
19 constexpr CGFloat kFocusRingLineWidth = 2; 19 constexpr CGFloat kFocusRingInset = 3;
20 constexpr CGFloat kHorizontalPaddingBetweenAvatarAndLabel = 10; 20 constexpr CGFloat kHorizontalPaddingBetweenAvatarAndLabel = 10;
21 } // namespace 21 } // namespace
22 22
23 // Custom button cell that adds a left padding before the avatar, and a custom 23 // Custom button cell that adds a left padding before the avatar, and a custom
24 // spacing between the avatar and label. 24 // spacing between the avatar and label.
25 @interface CredentialItemButtonCell : NSButtonCell { 25 @interface CredentialItemButtonCell : NSButtonCell {
26 @private 26 @private
27 // Padding added to the left margin of the button. 27 // Padding added to the left margin of the button.
28 int marginSpacing_; 28 int marginSpacing_;
29 // Spacing between the cell image and title. 29 // Spacing between the cell image and title.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 [super drawImage:image withFrame:frame inView:controlView]; 67 [super drawImage:image withFrame:frame inView:controlView];
68 } 68 }
69 69
70 - (NSSize)cellSize { 70 - (NSSize)cellSize {
71 NSSize buttonSize = [super cellSize]; 71 NSSize buttonSize = [super cellSize];
72 buttonSize.width += imageTitleSpacing_; 72 buttonSize.width += imageTitleSpacing_;
73 buttonSize.width += 2 * marginSpacing_; 73 buttonSize.width += 2 * marginSpacing_;
74 return buttonSize; 74 return buttonSize;
75 } 75 }
76 76
77 - (NSFocusRingType)focusRingType { 77 - (void)drawFocusRingMaskWithFrame:(NSRect)cellFrame
78 // This is taken care of by the custom drawing code. 78 inView:(NSView *)controlView {
79 return NSFocusRingTypeNone; 79 NSRect focusRingRect =
80 } 80 NSInsetRect(cellFrame, kFocusRingInset, kFocusRingInset);
81 81
82 - (void)drawWithFrame:(NSRect)frame inView:(NSView*)controlView { 82 [[NSBezierPath bezierPathWithRoundedRect:focusRingRect
83 [super drawInteriorWithFrame:frame inView:controlView]; 83 xRadius:2
84 84 yRadius:2] fill];
85 // Focus ring.
86 if ([self showsFirstResponder]) {
87 NSRect focusRingRect =
88 NSInsetRect(frame, kFocusRingLineWidth, kFocusRingLineWidth);
89 // TODO(vasilii): When we are targetting 10.7, we should change this to use
90 // -drawFocusRingMaskWithFrame instead.
91 [[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:1] set];
92 NSBezierPath* path = [NSBezierPath bezierPathWithRect:focusRingRect];
93 [path setLineWidth:kFocusRingLineWidth];
94 [path stroke];
95 }
96 } 85 }
97 86
98 @end 87 @end
99 88
100 @interface CredentialItemButton () { 89 @interface CredentialItemButton () {
101 base::scoped_nsobject<NSColor> backgroundColor_; 90 base::scoped_nsobject<NSColor> backgroundColor_;
102 base::scoped_nsobject<NSColor> hoverColor_; 91 base::scoped_nsobject<NSColor> hoverColor_;
103 } 92 }
104 @end 93 @end
105 94
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 136
148 NSColor* backgroundColor = isHighlighted ? hoverColor_ : backgroundColor_; 137 NSColor* backgroundColor = isHighlighted ? hoverColor_ : backgroundColor_;
149 [[self cell] setBackgroundColor:backgroundColor]; 138 [[self cell] setBackgroundColor:backgroundColor];
150 } 139 }
151 140
152 - (BOOL)canBecomeKeyView { 141 - (BOOL)canBecomeKeyView {
153 return YES; 142 return YES;
154 } 143 }
155 144
156 @end 145 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698