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 OmniboxPopupMatrix; | 13 @class OmniboxPopupCell; |
| 14 | 14 |
| 15 class OmniboxPopupMatrixDelegate { | 15 @interface OmniboxPopupTableController |
| 16 : NSViewController<NSTableViewDelegate, NSTableViewDataSource> { | |
| 17 @private | |
| 18 NSMutableArray* array_; | |
|
Scott Hess - ex-Googler
2015/04/25 06:04:27
Should this be a scoped_nsobject<NSMutableArray>?
dschuyler
2015/05/01 21:50:53
Done.
| |
| 19 }; | |
| 20 | |
| 21 // Allocate or free cells so that count are available. | |
| 22 // Also sets up default settings such as selecting the first cell. | |
| 23 - (void)setCellCount:(NSUInteger)count; | |
| 24 | |
| 25 // Get an immutable version of the array. | |
| 26 - (NSArray*)getCellArray; | |
| 27 | |
| 28 @end | |
| 29 | |
| 30 @class OmniboxPopupTableView; | |
| 31 | |
| 32 class OmniboxPopupTableDelegate { | |
| 16 public: | 33 public: |
| 17 // Called when the selection in the matrix changes. | 34 // Called when the selection in the table changes. |
| 18 virtual void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) = 0; | 35 virtual void OnTableRowSelected(OmniboxPopupTableView* table_view, |
| 36 size_t row) = 0; | |
| 19 | 37 |
| 20 // Called when the user clicks on a row. | 38 // Called when the user clicks on a row. |
| 21 virtual void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) = 0; | 39 virtual void OnTableRowClicked(OmniboxPopupTableView* table_view, |
| 40 size_t row) = 0; | |
| 22 | 41 |
| 23 // Called when the user middle clicks on a row. | 42 // Called when the user middle clicks on a row. |
| 24 virtual void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, | 43 virtual void OnTableRowMiddleClicked(OmniboxPopupTableView* table_view, |
| 25 size_t row) = 0; | 44 size_t row) = 0; |
| 26 }; | 45 }; |
| 27 | 46 |
| 28 // Sets up a tracking area to implement hover by highlighting the cell the mouse | 47 @interface OmniboxPopupTableView : NSTableView { |
| 29 // is over. | 48 OmniboxPopupTableDelegate* delegate_; // weak |
| 30 @interface OmniboxPopupMatrix : NSMatrix { | |
| 31 OmniboxPopupMatrixDelegate* delegate_; // weak | |
| 32 ui::ScopedCrTrackingArea trackingArea_; | 49 ui::ScopedCrTrackingArea trackingArea_; |
| 50 OmniboxPopupTableController* controller_; | |
|
Scott Hess - ex-Googler
2015/04/25 06:04:27
scoped_nsobject<>? Someone needs to own it.
dschuyler
2015/05/01 21:50:53
Would the super own it with the setDelegate or set
Scott Hess - ex-Googler
2015/05/04 19:40:20
Usually, delegates are not owned pointers. I beli
| |
| 33 } | 51 } |
| 34 | 52 |
| 35 // Create a zero-size matrix. | 53 // Create a zero-size table. |
| 36 - (id)initWithDelegate:(OmniboxPopupMatrixDelegate*)delegate; | 54 - (id)initWithDelegate:(OmniboxPopupTableDelegate*)delegate; |
| 37 | 55 |
| 38 // Sets the delegate. | 56 // Sets the delegate. |
| 39 - (void)setDelegate:(OmniboxPopupMatrixDelegate*)delegate; | 57 - (void)setCppDelegate:(OmniboxPopupTableDelegate*)delegate; |
|
Scott Hess - ex-Googler
2015/04/25 06:04:27
I think that's a reasonable change, if clunky (but
dschuyler
2015/05/01 21:50:53
Done.
| |
| 40 | 58 |
| 41 // Return the currently highlighted row. Returns -1 if no row is highlighted. | 59 // Return the currently highlighted row. Returns -1 if no row is highlighted. |
| 42 - (NSInteger)highlightedRow; | 60 - (NSInteger)highlightedRow; |
| 43 | 61 |
| 62 // Allocate or free cells so that count are available. | |
| 63 // Also sets up default settings such as selecting the first cell. | |
| 64 - (void)setCellCount:(NSUInteger)count; | |
| 65 | |
| 66 // Fetch a cell with limit checks on the array. | |
| 67 - (OmniboxPopupCell*)cellAtRow:(NSUInteger)row; | |
|
Scott Hess - ex-Googler
2015/04/25 06:04:27
I can see why you did this for convenience sake, b
dschuyler
2015/05/01 21:50:53
Done.
| |
| 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 |