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_MATRIX_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #import "ui/base/cocoa/tracking_area.h" | 10 #import "ui/base/cocoa/tracking_area.h" |
11 #include "ui/base/window_open_disposition.h" | 11 #include "ui/base/window_open_disposition.h" |
12 | 12 |
13 @class OmniboxPopupCell; | |
14 | |
15 @interface OmniboxPopupTableController | |
16 : NSViewController<NSTableViewDelegate, NSTableViewDataSource> { | |
17 @private | |
18 base::scoped_nsobject<NSArray> array_; | |
19 NSInteger hovered_index_; | |
20 }; | |
21 | |
22 // Set the hovered highlight. | |
23 - (void)highlightRowAt:(NSInteger)rowIndex withView:(NSView*)view; | |
24 | |
25 // Which row has the hovered highlight. | |
26 - (NSInteger)highlightedRow; | |
27 | |
28 // Get the drawing rectangle for the given row. | |
29 - (NSRect)rectForRow:(NSInteger)rowIndex; | |
30 | |
31 @end | |
32 | |
13 @class OmniboxPopupMatrix; | 33 @class OmniboxPopupMatrix; |
14 | 34 |
15 class OmniboxPopupMatrixDelegate { | 35 class OmniboxPopupMatrixDelegate { |
16 public: | 36 public: |
17 // Called when the selection in the matrix changes. | 37 // Called when the selection in the matrix changes. |
18 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; | 38 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; |
19 | 39 |
20 // Called when the user clicks on a row. | 40 // Called when the user clicks on a row. |
21 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; | 41 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; |
22 | 42 |
23 // Called when the user middle clicks on a row. | 43 // Called when the user middle clicks on a row. |
24 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, | 44 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, |
25 size_t row) = 0; | 45 size_t row) = 0; |
26 }; | 46 }; |
27 | 47 |
28 // Sets up a tracking area to implement hover by highlighting the cell the mouse | 48 // Sets up a tracking area to implement hover by highlighting the cell the mouse |
29 // is over. | 49 // is over. |
30 @interface OmniboxPopupMatrix : NSMatrix { | 50 @interface OmniboxPopupMatrix : NSTableView { |
31 OmniboxPopupMatrixDelegate* delegate_; // weak | 51 OmniboxPopupMatrixDelegate* delegate_; // weak |
32 ui::ScopedCrTrackingArea trackingArea_; | 52 ui::ScopedCrTrackingArea trackingArea_; |
53 base::scoped_nsobject<OmniboxPopupTableController> controller_; | |
33 } | 54 } |
34 | 55 |
35 // Create a zero-size matrix. | 56 // Create a zero-size matrix. |
36 - (id)initWithDelegate:(OmniboxPopupMatrixDelegate*)delegate; | 57 - (id)initWithDelegate:(OmniboxPopupMatrixDelegate*)delegate; |
37 | 58 |
38 // Sets the delegate. | 59 // Sets the OmniboxPopupMatrixDelegate which is not the same as the NSTableView |
39 - (void)setDelegate:(OmniboxPopupMatrixDelegate*)delegate; | 60 // delegate. |
61 - (void)setTheDelegate:(OmniboxPopupMatrixDelegate*)delegate; | |
40 | 62 |
41 // Return the currently highlighted row. Returns -1 if no row is highlighted. | 63 // Return the currently highlighted row. Returns -1 if no row is highlighted. |
42 - (NSInteger)highlightedRow; | 64 - (NSInteger)highlightedRow; |
43 | 65 |
66 // Select the row by turning it on. Turns off prior selection. | |
Scott Hess - ex-Googler
2015/05/07 22:35:42
IMHO, using on and off are themselves weird, they'
dschuyler
2015/05/13 01:41:11
Done.
| |
67 - (void)selectRowAt:(NSInteger)rowIndex; | |
68 | |
69 // Setup the information used by the NSTableView data source. | |
70 - (void)setDataArray:(NSArray*)array; | |
71 | |
44 @end | 72 @end |
45 | 73 |
46 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 74 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
OLD | NEW |