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

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 separator init 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 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.
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(retain, nonatomic) NSAttributedString* contents;
groby-ooo-7-16 2015/06/12 18:51:06 We ultimately want this readonly, since this _shou
dschuyler 2015/06/12 21:39:13 Done.
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(nonatomic) CGFloat contentsOffset;
groby-ooo-7-16 2015/06/12 18:51:06 See above re: immutable.
dschuyler 2015/06/12 21:39:14 Done.
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 image:(NSImage*)image
49 answerImage:(NSImage*)answerImage;
45 50
46 - (NSAttributedString*)description; 51 // Each row is allowed to have a different value.
47 52 - (CGFloat)rowHeight;
48 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth;
49
50 - (void)setContentsOffset:(CGFloat)contentsOffset;
51 53
52 // Returns the width of the match contents. 54 // Returns the width of the match contents.
53 - (CGFloat)getMatchContentsWidth; 55 - (CGFloat)getMatchContentsWidth;
54 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 {
groby-ooo-7-16 2015/06/12 18:51:06 Skip the empty braces - not needed if you don't ha
dschuyler 2015/06/12 21:39:13 Done.
dschuyler 2015/06/12 21:39:14 Done.
62 }
63
64 - (void)drawMatchWithFrame:(NSRect)cellFrame
65 withCellData:(OmniboxPopupCellData*)cellData
groby-ooo-7-16 2015/06/12 18:51:06 Does this need cellData? Can't it retrieve that fr
dschuyler 2015/06/12 21:39:13 Done.
dschuyler 2015/06/12 21:39:13 It can retrieve it from objectValue. Which is pre
66 inView:(NSView*)controlView;
67
55 // Returns the offset of the start of the contents in the input text for the 68 // 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 69 // given match. It is costly to compute this offset, so it is computed once and
57 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. 70 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent.
58 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; 71 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match;
59 72
73 + (NSAttributedString*)createSeparatorString;
74
60 @end 75 @end
61 76
62 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ 77 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698