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_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_cell_; | |
|
Scott Hess - ex-Googler
2015/05/04 19:40:20
hovered_index_ or hovered_row_, since it's not the
dschuyler
2015/05/04 23:51:40
Done.
| |
| 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 @end | |
| 29 | |
| 13 @class OmniboxPopupMatrix; | 30 @class OmniboxPopupMatrix; |
| 14 | 31 |
| 15 class OmniboxPopupMatrixDelegate { | 32 class OmniboxPopupMatrixDelegate { |
| 16 public: | 33 public: |
| 17 // Called when the selection in the matrix changes. | 34 // Called when the selection in the matrix changes. |
| 18 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; | 35 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; |
| 19 | 36 |
| 20 // Called when the user clicks on a row. | 37 // Called when the user clicks on a row. |
| 21 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; | 38 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; |
| 22 | 39 |
| 23 // Called when the user middle clicks on a row. | 40 // Called when the user middle clicks on a row. |
| 24 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, | 41 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, |
| 25 size_t row) = 0; | 42 size_t row) = 0; |
| 26 }; | 43 }; |
| 27 | 44 |
| 28 // Sets up a tracking area to implement hover by highlighting the cell the mouse | 45 // Sets up a tracking area to implement hover by highlighting the cell the mouse |
| 29 // is over. | 46 // is over. |
| 30 @interface OmniboxPopupMatrix : NSMatrix { | 47 @interface OmniboxPopupMatrix : NSTableView { |
| 31 OmniboxPopupMatrixDelegate* delegate_; // weak | 48 OmniboxPopupMatrixDelegate* delegate_; // weak |
| 32 ui::ScopedCrTrackingArea trackingArea_; | 49 ui::ScopedCrTrackingArea trackingArea_; |
| 50 base::scoped_nsobject<OmniboxPopupTableController> controller_; | |
| 33 } | 51 } |
| 34 | 52 |
| 35 // Create a zero-size matrix. | 53 // Create a zero-size matrix. |
| 36 - (id)initWithDelegate:(OmniboxPopupMatrixDelegate*)delegate; | 54 - (id)initWithDelegate:(OmniboxPopupMatrixDelegate*)delegate; |
| 37 | 55 |
| 38 // Sets the delegate. | 56 // Sets the OmniboxPopupMatrixDelegate which is not the same as the NSTableView |
| 39 - (void)setDelegate:(OmniboxPopupMatrixDelegate*)delegate; | 57 // delegate. |
| 58 - (void)setTheDelegate:(OmniboxPopupMatrixDelegate*)delegate; | |
| 40 | 59 |
| 41 // Return the currently highlighted row. Returns -1 if no row is highlighted. | 60 // Return the currently highlighted row. Returns -1 if no row is highlighted. |
| 42 - (NSInteger)highlightedRow; | 61 - (NSInteger)highlightedRow; |
| 43 | 62 |
| 63 // Select the row by turning it 'on'. Turns 'off' prior selection. | |
| 64 - (void)selectRowAt:(NSInteger)rowIndex; | |
| 65 | |
| 66 // Setup the information used by the NSTableView data source. | |
| 67 - (void)setDataArray:(NSArray*)array; | |
| 68 | |
| 44 @end | 69 @end |
| 45 | 70 |
| 46 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ | 71 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_MATRIX_H_ |
| OLD | NEW |