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 #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 @class OmniboxPopupCell; | |
|
groby-ooo-7-16
2015/06/11 01:22:17
I don't think you need that any more
dschuyler
2015/06/11 22:34:22
Done.
| |
| 14 | 15 |
| 15 // OmniboxPopupCell overrides how backgrounds are displayed to | 16 @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 | 17 @private |
| 20 // The popup view parent of this cell. | |
| 21 OmniboxPopupViewMac* parent_; | |
| 22 | |
| 23 // The match which will be rendered for this row in omnibox dropdown. | |
| 24 AutocompleteMatch match_; | |
| 25 | |
| 26 // NSAttributedString instances for various match components. | 18 // NSAttributedString instances for various match components. |
| 27 base::scoped_nsobject<NSAttributedString> separator_; | 19 base::scoped_nsobject<NSAttributedString> contents_; |
|
groby-ooo-7-16
2015/06/11 01:22:17
If you use these purely as data container and noth
dschuyler
2015/06/11 22:34:22
Done.
| |
| 28 base::scoped_nsobject<NSAttributedString> description_; | 20 base::scoped_nsobject<NSAttributedString> description_; |
| 29 | 21 |
| 30 base::scoped_nsobject<NSImage> answerImage_; | 22 base::scoped_nsobject<NSImage> answerImage_; |
| 31 | 23 |
| 32 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs | 24 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs |
| 33 // to be a member of the class. This allows the |NSAttributedString| instance | 25 // to be a member of the class. This allows the |NSAttributedString| instance |
| 34 // to stay alive between the call to |drawTitle| and the actual paint event | 26 // to stay alive between the call to |drawTitle| and the actual paint event |
| 35 // which accesses the |NSAttributedString| instance. | 27 // which accesses the |NSAttributedString| instance. |
| 36 base::scoped_nsobject<NSAttributedString> prefix_; | 28 base::scoped_nsobject<NSAttributedString> prefix_; |
| 37 | 29 |
| 30 base::scoped_nsobject<NSImage> image_; | |
| 31 | |
| 38 // The width of widest match contents in a set of infinite suggestions. | 32 // The width of widest match contents in a set of infinite suggestions. |
| 39 CGFloat maxMatchContentsWidth_; | 33 CGFloat maxMatchContentsWidth_; |
| 40 | 34 |
| 41 // The offset at which the infinite suggestion contents should be displayed. | 35 // The offset at which the infinite suggestion contents should be displayed. |
| 42 CGFloat contentsOffset_; | 36 CGFloat contentsOffset_; |
| 37 | |
| 38 bool isContentsRTL_; | |
| 39 AutocompleteMatch::Type matchType_; | |
| 43 } | 40 } |
| 44 | 41 |
| 42 - (instancetype)initWithMatch:(const AutocompleteMatch&)match | |
| 43 image:(NSImage*)image; | |
| 44 | |
| 45 // Each row is allowed to have a different value. | |
| 46 - (CGFloat)rowHeight; | |
| 47 | |
| 45 - (void)setAnswerImage:(NSImage*)image; | 48 - (void)setAnswerImage:(NSImage*)image; |
| 46 | 49 |
| 47 - (void)setMatch:(const AutocompleteMatch&)match; | |
| 48 | |
| 49 - (NSAttributedString*)description; | |
| 50 | |
| 51 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth; | 50 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth; |
| 52 | 51 |
| 53 - (void)setContentsOffset:(CGFloat)contentsOffset; | 52 - (void)setContentsOffset:(CGFloat)contentsOffset; |
| 54 | 53 |
| 55 // Returns the width of the match contents. | 54 // Returns the width of the match contents. |
| 56 - (CGFloat)getMatchContentsWidth; | 55 - (CGFloat)getMatchContentsWidth; |
| 57 | 56 |
| 57 @end | |
| 58 | |
| 59 // OmniboxPopupCell overrides how cells are displayed. The OmniboxPopupCell | |
| 60 // uses information from OmniboxPopupCellData to draw suggestion results. | |
| 61 @interface OmniboxPopupCell : NSCell { | |
| 62 base::scoped_nsobject<NSAttributedString> separator_; | |
| 63 } | |
| 64 | |
| 65 - (void)drawMatchWithFrame:(NSRect)cellFrame | |
| 66 withCellData:(OmniboxPopupCellData*)cellData | |
| 67 inView:(NSView*)controlView; | |
| 68 | |
| 58 // Returns the offset of the start of the contents in the input text for the | 69 // Returns the offset of the start of the contents in the input text for the |
| 59 // given match. It is costly to compute this offset, so it is computed once and | 70 // given match. It is costly to compute this offset, so it is computed once and |
| 60 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. | 71 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. |
| 61 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; | 72 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; |
| 62 | 73 |
| 63 @end | 74 @end |
| 64 | 75 |
| 65 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ | 76 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ |
| OLD | NEW |