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 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ |
6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ | 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #include "components/omnibox/autocomplete_match.h" | 11 #include "components/omnibox/autocomplete_match.h" |
12 | 12 |
13 class OmniboxPopupViewMac; | 13 class OmniboxPopupViewMac; |
14 | 14 |
15 // OmniboxPopupCell overrides how backgrounds are displayed to | 15 @interface OmniboxPopupCellData : NSObject<NSCopying> { |
16 // handle hover versus selected. So long as we're in there, it also | |
17 // provides some default initialization. | |
18 @interface OmniboxPopupCell : NSButtonCell { | |
19 @private | 16 @private |
20 // The match which will be rendered for this row in omnibox dropdown. | 17 // NSAttributedString instances for various match components. |
Scott Hess - ex-Googler
2015/06/12 22:21:59
The comment telling us that the NSAttributedString
dschuyler
2015/06/12 23:07:54
Done.
| |
21 AutocompleteMatch match_; | 18 NSAttributedString* contents_; |
19 NSAttributedString* description_; | |
22 | 20 |
23 // NSAttributedString instances for various match components. | 21 NSImage* answerImage_; |
24 base::scoped_nsobject<NSAttributedString> separator_; | |
25 base::scoped_nsobject<NSAttributedString> description_; | |
26 | |
27 base::scoped_nsobject<NSImage> answerImage_; | |
28 | 22 |
29 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs | 23 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs |
30 // to be a member of the class. This allows the |NSAttributedString| instance | 24 // to be a member of the class. This allows the |NSAttributedString| instance |
31 // to stay alive between the call to |drawTitle| and the actual paint event | 25 // to stay alive between the call to |drawTitle| and the actual paint event |
32 // which accesses the |NSAttributedString| instance. | 26 // which accesses the |NSAttributedString| instance. |
33 base::scoped_nsobject<NSAttributedString> prefix_; | 27 NSAttributedString* prefix_; |
34 | 28 |
35 // The width of widest match contents in a set of infinite suggestions. | 29 NSImage* image_; |
36 CGFloat maxMatchContentsWidth_; | |
37 | 30 |
38 // The offset at which the infinite suggestion contents should be displayed. | 31 // The offset at which the infinite suggestion contents should be displayed. |
39 CGFloat contentsOffset_; | 32 CGFloat contentsOffset_; |
33 | |
34 BOOL isContentsRTL_; | |
35 AutocompleteMatch::Type matchType_; | |
40 } | 36 } |
41 | 37 |
42 - (void)setAnswerImage:(NSImage*)image; | 38 @property(readonly, retain, nonatomic) NSAttributedString* contents; |
39 @property(readonly, retain, nonatomic) NSAttributedString* description; | |
40 @property(readonly, retain, nonatomic) NSAttributedString* prefix; | |
41 @property(readonly, retain, nonatomic) NSImage* image; | |
42 @property(readonly, retain, nonatomic) NSImage* answerImage; | |
43 @property(readonly, nonatomic) CGFloat contentsOffset; | |
44 @property(readonly, nonatomic) BOOL isContentsRTL; | |
45 @property(readonly, nonatomic) AutocompleteMatch::Type matchType; | |
43 | 46 |
44 - (void)setMatch:(const AutocompleteMatch&)match; | 47 - (instancetype)initWithMatch:(const AutocompleteMatch&)match |
48 contentsOffset:(CGFloat)contentsOffset | |
49 image:(NSImage*)image | |
50 answerImage:(NSImage*)answerImage; | |
45 | 51 |
46 - (NSAttributedString*)description; | 52 // Each row is allowed to have a different value. |
47 | 53 - (CGFloat)rowHeight; |
48 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth; | |
49 | |
50 - (void)setContentsOffset:(CGFloat)contentsOffset; | |
51 | 54 |
52 // Returns the width of the match contents. | 55 // Returns the width of the match contents. |
53 - (CGFloat)getMatchContentsWidth; | 56 - (CGFloat)getMatchContentsWidth; |
54 | 57 |
58 @end | |
59 | |
60 // OmniboxPopupCell overrides how cells are displayed. The OmniboxPopupCell | |
61 // uses information from OmniboxPopupCellData to draw suggestion results. | |
Scott Hess - ex-Googler
2015/06/12 22:21:59
I'd also remove the talking-about-myself-by-given-
dschuyler
2015/06/12 23:07:53
Done.
| |
62 @interface OmniboxPopupCell : NSCell | |
63 | |
64 - (void)drawMatchWithFrame:(NSRect)cellFrame inView:(NSView*)controlView; | |
65 | |
55 // Returns the offset of the start of the contents in the input text for the | 66 // Returns the offset of the start of the contents in the input text for the |
56 // given match. It is costly to compute this offset, so it is computed once and | 67 // given match. It is costly to compute this offset, so it is computed once and |
57 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. | 68 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. |
58 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; | 69 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; |
59 | 70 |
71 + (NSAttributedString*)createSeparatorString; | |
72 | |
60 @end | 73 @end |
61 | 74 |
62 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ | 75 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ |
OLD | NEW |