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

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

Issue 1099403005: [AiS] changing mac omnibox suggestions form NSMatrix to NSTableView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved description access to test code Created 5 years, 6 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
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 #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;
14 15
15 // OmniboxPopupCell overrides how backgrounds are displayed to 16 @interface OmniboxPopupCellData : NSObject {
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.
19 base::scoped_nsobject<NSAttributedString> contents_;
27 base::scoped_nsobject<NSAttributedString> separator_; 20 base::scoped_nsobject<NSAttributedString> separator_;
28 base::scoped_nsobject<NSAttributedString> description_; 21 base::scoped_nsobject<NSAttributedString> description_;
29 22
30 base::scoped_nsobject<NSImage> answerImage_; 23 base::scoped_nsobject<NSImage> answerImage_;
31 24
32 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs 25 // 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 26 // 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 27 // to stay alive between the call to |drawTitle| and the actual paint event
35 // which accesses the |NSAttributedString| instance. 28 // which accesses the |NSAttributedString| instance.
36 base::scoped_nsobject<NSAttributedString> prefix_; 29 base::scoped_nsobject<NSAttributedString> prefix_;
37 30
31 base::scoped_nsobject<NSImage> image_;
32
38 // The width of widest match contents in a set of infinite suggestions. 33 // The width of widest match contents in a set of infinite suggestions.
39 CGFloat maxMatchContentsWidth_; 34 CGFloat maxMatchContentsWidth_;
40 35
41 // The offset at which the infinite suggestion contents should be displayed. 36 // The offset at which the infinite suggestion contents should be displayed.
42 CGFloat contentsOffset_; 37 CGFloat contentsOffset_;
38
39 bool isContentsRTL_;
40 AutocompleteMatch::Type matchType_;
43 } 41 }
44 42
43 - (instancetype)initWithMatch:(const AutocompleteMatch&)match
44 image:(NSImage*)image;
45
46 - (void)drawMatchWithFrame:(NSRect)cellFrame
47 inCell:(OmniboxPopupCell*)cell
48 inView:(NSView*)controlView;
49
50 // Each row is allowed to have a different value.
51 - (CGFloat)rowHeight;
52
45 - (void)setAnswerImage:(NSImage*)image; 53 - (void)setAnswerImage:(NSImage*)image;
46 54
47 - (void)setMatch:(const AutocompleteMatch&)match;
48
49 - (NSAttributedString*)description;
50
51 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth; 55 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth;
52 56
53 - (void)setContentsOffset:(CGFloat)contentsOffset; 57 - (void)setContentsOffset:(CGFloat)contentsOffset;
54 58
55 // Returns the width of the match contents. 59 // Returns the width of the match contents.
56 - (CGFloat)getMatchContentsWidth; 60 - (CGFloat)getMatchContentsWidth;
57 61
62 @end
63
64 // OmniboxPopupCell overrides how cells are displayed. The OmniboxPopupCell
65 // uses information from OmniboxPopupCellData to draw suggestion results.
66 @interface OmniboxPopupCell : NSCell {
67 }
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698