Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 } | |
| 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 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 70 operation:NSCompositeSourceOver | 79 operation:NSCompositeSourceOver |
| 71 fraction:1.0 | 80 fraction:1.0 |
| 72 respectFlipped:YES | 81 respectFlipped:YES |
| 73 hints:nil]; | 82 hints:nil]; |
| 74 } | 83 } |
| 75 | 84 |
| 76 // Adjust the title position to be lined up under the field's text. | 85 // Adjust the title position to be lined up under the field's text. |
| 77 NSAttributedString* title = [self attributedTitle]; | 86 NSAttributedString* title = [self attributedTitle]; |
| 78 if (title && [title length]) { | 87 if (title && [title length]) { |
| 79 NSRect titleRect = cellFrame; | 88 NSRect titleRect = cellFrame; |
| 80 titleRect.size.width -= kTextXOffset; | 89 CGFloat textXOffset = kTextXOffset + [self additionalOffset]; |
|
Scott Hess - ex-Googler
2013/12/12 19:11:15
I think this might make more sense as a method -te
Anuj
2013/12/12 23:56:22
Done.
| |
| 81 titleRect.origin.x += kTextXOffset; | 90 titleRect.size.width -= textXOffset; |
| 91 titleRect.origin.x += textXOffset; | |
| 82 [self drawTitle:title withFrame:titleRect inView:controlView]; | 92 [self drawTitle:title withFrame:titleRect inView:controlView]; |
| 83 } | 93 } |
| 84 } | 94 } |
| 85 | 95 |
| 86 @end | 96 @end |
| OLD | NEW |