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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm

Issue 98463012: Infinite Suggest for mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed reviewer comments Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/omnibox/omnibox_popup_cell.h" 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 namespace { 9 namespace {
10 10
(...skipping 10 matching lines...) Expand all
21 return [NSColor selectedControlColor]; 21 return [NSColor selectedControlColor];
22 } 22 }
23 NSColor* HoveredBackgroundColor() { 23 NSColor* HoveredBackgroundColor() {
24 return [NSColor controlHighlightColor]; 24 return [NSColor controlHighlightColor];
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 @implementation OmniboxPopupCell 29 @implementation OmniboxPopupCell
30 30
31 - (CGFloat)additionalOffset {
32 return additionalOffset_;
33 }
Scott Hess - ex-Googler 2013/12/14 00:40:57 Is this method needed? -setAdditionalOffset: is n
Anuj 2013/12/16 02:53:19 Done.
34
35 - (void)setAdditionalOffset:(CGFloat)additionalOffset {
36 additionalOffset_ = additionalOffset;
37 }
38
39
31 - (id)init { 40 - (id)init {
32 self = [super init]; 41 self = [super init];
33 if (self) { 42 if (self) {
34 [self setImagePosition:NSImageLeft]; 43 [self setImagePosition:NSImageLeft];
35 [self setBordered:NO]; 44 [self setBordered:NO];
36 [self setButtonType:NSRadioButton]; 45 [self setButtonType:NSRadioButton];
37 46
38 // Without this highlighting messes up white areas of images. 47 // Without this highlighting messes up white areas of images.
39 [self setHighlightsBy:NSNoCellMask]; 48 [self setHighlightsBy:NSNoCellMask];
40 } 49 }
41 return self; 50 return self;
42 } 51 }
43 52
53 - (CGFloat)textOffset {
54 return kTextXOffset + [self additionalOffset];
55 }
56
44 // The default NSButtonCell drawing leaves the image flush left and 57 // The default NSButtonCell drawing leaves the image flush left and
45 // the title next to the image. This spaces things out to line up 58 // the title next to the image. This spaces things out to line up
46 // with the star button and autocomplete field. 59 // with the star button and autocomplete field.
47 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { 60 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
48 if ([self state] == NSOnState || [self isHighlighted]) { 61 if ([self state] == NSOnState || [self isHighlighted]) {
49 if ([self state] == NSOnState) 62 if ([self state] == NSOnState)
50 [SelectedBackgroundColor() set]; 63 [SelectedBackgroundColor() set];
51 else 64 else
52 [HoveredBackgroundColor() set]; 65 [HoveredBackgroundColor() set];
53 NSBezierPath* path = 66 NSBezierPath* path =
(...skipping 16 matching lines...) Expand all
70 operation:NSCompositeSourceOver 83 operation:NSCompositeSourceOver
71 fraction:1.0 84 fraction:1.0
72 respectFlipped:YES 85 respectFlipped:YES
73 hints:nil]; 86 hints:nil];
74 } 87 }
75 88
76 // Adjust the title position to be lined up under the field's text. 89 // Adjust the title position to be lined up under the field's text.
77 NSAttributedString* title = [self attributedTitle]; 90 NSAttributedString* title = [self attributedTitle];
78 if (title && [title length]) { 91 if (title && [title length]) {
79 NSRect titleRect = cellFrame; 92 NSRect titleRect = cellFrame;
80 titleRect.size.width -= kTextXOffset; 93 CGFloat textXOffset = [self textOffset];
81 titleRect.origin.x += kTextXOffset; 94 titleRect.size.width -= textXOffset;
95 titleRect.origin.x += textXOffset;
82 [self drawTitle:title withFrame:titleRect inView:controlView]; 96 [self drawTitle:title withFrame:titleRect inView:controlView];
83 } 97 }
84 } 98 }
85 99
86 @end 100 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698