| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHOOSER_CONTENT_VIEW_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_CHOOSER_CONTENT_VIEW_COCOA_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_CHOOSER_CONTENT_VIEW_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_CHOOSER_CONTENT_VIEW_COCOA_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 | 13 |
| 14 class ChooserContentViewController; | 14 class ChooserContentViewController; |
| 15 class ChooserController; | 15 class ChooserController; |
| 16 @class SpinnerView; | 16 @class SpinnerView; |
| 17 | 17 |
| 18 // A chooser content view class that user can select an option. | 18 // A chooser content view class that user can select an option. |
| 19 @interface ChooserContentViewCocoa : NSView { | 19 @interface ChooserContentViewCocoa : NSView { |
| 20 @private | 20 @private |
| 21 base::scoped_nsobject<NSTextField> titleView_; | 21 base::scoped_nsobject<NSTextField> titleView_; |
| 22 base::scoped_nsobject<NSButton> adapterOffHelpButton_; | 22 base::scoped_nsobject<NSButton> adapterOffHelpButton_; |
| 23 base::scoped_nsobject<NSTextField> adapterOffMessage_; | 23 base::scoped_nsobject<NSTextField> adapterOffMessage_; |
| 24 base::scoped_nsobject<NSScrollView> scrollView_; | 24 base::scoped_nsobject<NSScrollView> scrollView_; |
| 25 base::scoped_nsobject<NSTableColumn> tableColumn_; | 25 base::scoped_nsobject<NSTableColumn> tableColumn_; |
| 26 base::scoped_nsobject<NSTableView> tableView_; | 26 base::scoped_nsobject<NSTableView> tableView_; |
| 27 base::scoped_nsobject<SpinnerView> spinner_; | 27 base::scoped_nsobject<SpinnerView> spinner_; |
| 28 base::scoped_nsobject<NSTextField> status_; | |
| 29 base::scoped_nsobject<NSButton> rescanButton_; | |
| 30 base::scoped_nsobject<NSButton> connectButton_; | 28 base::scoped_nsobject<NSButton> connectButton_; |
| 31 base::scoped_nsobject<NSButton> cancelButton_; | 29 base::scoped_nsobject<NSButton> cancelButton_; |
| 32 base::scoped_nsobject<NSBox> separator_; | 30 base::scoped_nsobject<NSBox> separator_; |
| 33 base::scoped_nsobject<NSTextField> message_; | |
| 34 base::scoped_nsobject<NSButton> helpButton_; | 31 base::scoped_nsobject<NSButton> helpButton_; |
| 32 base::scoped_nsobject<NSTextField> scanningMessage_; |
| 33 base::scoped_nsobject<NSTextField> wordConnector_; |
| 34 base::scoped_nsobject<NSButton> rescanButton_; |
| 35 std::unique_ptr<ChooserController> chooserController_; | 35 std::unique_ptr<ChooserController> chooserController_; |
| 36 std::unique_ptr<ChooserContentViewController> chooserContentViewController_; | 36 std::unique_ptr<ChooserContentViewController> chooserContentViewController_; |
| 37 | |
| 38 CGFloat titleHeight_; | |
| 39 CGFloat statusHeight_; | |
| 40 CGFloat rescanButtonHeight_; | |
| 41 CGFloat connectButtonWidth_; | |
| 42 CGFloat connectButtonHeight_; | |
| 43 CGFloat cancelButtonWidth_; | |
| 44 CGFloat cancelButtonHeight_; | |
| 45 CGFloat messageHeight_; | |
| 46 | |
| 47 struct FrameAndOrigin { | |
| 48 NSRect scroll_view_frame; | |
| 49 NSPoint connect_button_origin; | |
| 50 NSPoint cancel_button_origin; | |
| 51 }; | |
| 52 | |
| 53 // The cached |scrollView_| frame and |connectButton_| and |cancelButton_| | |
| 54 // origins for views layout: | |
| 55 // When |status_| is shown. | |
| 56 FrameAndOrigin statusShown_; | |
| 57 // When |rescanButton_| is shown. | |
| 58 FrameAndOrigin rescanButtonShown_; | |
| 59 // When neither |status_| nor |rescanButton_| is shown. | |
| 60 FrameAndOrigin noStatusOrRescanButtonShown_; | |
| 61 | |
| 62 // The cached |status_| and |rescanButton_| origins. | |
| 63 NSPoint statusOrigin_; | |
| 64 NSPoint rescanButtonOrigin_; | |
| 65 } | 37 } |
| 66 | 38 |
| 67 // Designated initializer. | 39 // Designated initializer. |
| 68 - (instancetype)initWithChooserTitle:(NSString*)chooserTitle | 40 - (instancetype)initWithChooserTitle:(NSString*)chooserTitle |
| 69 chooserController: | 41 chooserController: |
| 70 (std::unique_ptr<ChooserController>)chooserController; | 42 (std::unique_ptr<ChooserController>)chooserController; |
| 71 | 43 |
| 72 // Creates the title for the chooser. | 44 // Creates the title for the chooser. |
| 73 - (base::scoped_nsobject<NSTextField>)createChooserTitle:(NSString*)title; | 45 - (base::scoped_nsobject<NSTextField>)createChooserTitle:(NSString*)title; |
| 74 | 46 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 87 // Creates the "Cancel" button. | 59 // Creates the "Cancel" button. |
| 88 - (base::scoped_nsobject<NSButton>)createCancelButton; | 60 - (base::scoped_nsobject<NSButton>)createCancelButton; |
| 89 | 61 |
| 90 // Creates the separator. | 62 // Creates the separator. |
| 91 - (base::scoped_nsobject<NSBox>)createSeparator; | 63 - (base::scoped_nsobject<NSBox>)createSeparator; |
| 92 | 64 |
| 93 // Creates a hyperlink button with |text|. | 65 // Creates a hyperlink button with |text|. |
| 94 - (base::scoped_nsobject<NSButton>)createHyperlinkButtonWithText: | 66 - (base::scoped_nsobject<NSButton>)createHyperlinkButtonWithText: |
| 95 (NSString*)text; | 67 (NSString*)text; |
| 96 | 68 |
| 97 // Calculates the frame for the |scrollView_|. | |
| 98 - (NSRect)calculateScrollViewFrame:(CGFloat)buttonRowHeight; | |
| 99 | |
| 100 // Calculates the origin for the |status_| text. | |
| 101 - (NSPoint)calculateStatusOrigin:(CGFloat)buttonRowHeight; | |
| 102 | |
| 103 // Calculates the origin for the "Re-scan" button. | |
| 104 - (NSPoint)calculateRescanButtonOrigin:(CGFloat)buttonRowHeight; | |
| 105 | |
| 106 // Calculates the origin for the "Connect" button. | |
| 107 - (NSPoint)calculateConnectButtonOrigin:(CGFloat)buttonRowHeight; | |
| 108 | |
| 109 // Calculates the origin for the "Cancel" button. | |
| 110 - (NSPoint)calculateCancelButtonOrigin:(CGFloat)buttonRowHeight; | |
| 111 | |
| 112 // Updates the origin and size of the view. | |
| 113 - (void)updateView; | |
| 114 | |
| 115 // Gets the adapter off help button. | 69 // Gets the adapter off help button. |
| 116 - (NSButton*)adapterOffHelpButton; | 70 - (NSButton*)adapterOffHelpButton; |
| 117 | 71 |
| 118 // Gets the table view for the chooser. | 72 // Gets the table view for the chooser. |
| 119 - (NSTableView*)tableView; | 73 - (NSTableView*)tableView; |
| 120 | 74 |
| 121 // Gets the spinner. | 75 // Gets the spinner. |
| 122 - (SpinnerView*)spinner; | 76 - (SpinnerView*)spinner; |
| 123 | 77 |
| 124 // Gets the status text field. | |
| 125 - (NSTextField*)status; | |
| 126 | |
| 127 // Gets the "Re-scan" button. | |
| 128 - (NSButton*)rescanButton; | |
| 129 | |
| 130 // Gets the "Connect" button. | 78 // Gets the "Connect" button. |
| 131 - (NSButton*)connectButton; | 79 - (NSButton*)connectButton; |
| 132 | 80 |
| 133 // Gets the "Cancel" button. | 81 // Gets the "Cancel" button. |
| 134 - (NSButton*)cancelButton; | 82 - (NSButton*)cancelButton; |
| 135 | 83 |
| 136 // Gets the "Get help" button. | 84 // Gets the "Get help" button. |
| 137 - (NSButton*)helpButton; | 85 - (NSButton*)helpButton; |
| 138 | 86 |
| 87 // Gets the scanning message. |
| 88 - (NSTextField*)scanningMessage; |
| 89 |
| 90 // Gets the word connector. |
| 91 - (NSTextField*)wordConnector; |
| 92 |
| 93 // Gets the "Re-scan" button. |
| 94 - (NSButton*)rescanButton; |
| 95 |
| 139 // The number of options in the |tableView_|. | 96 // The number of options in the |tableView_|. |
| 140 - (NSInteger)numberOfOptions; | 97 - (NSInteger)numberOfOptions; |
| 141 | 98 |
| 142 // The |index|th option string which is listed in the chooser. | 99 // The |index|th option string which is listed in the chooser. |
| 143 - (NSString*)optionAtIndex:(NSInteger)index; | 100 - (NSString*)optionAtIndex:(NSInteger)index; |
| 144 | 101 |
| 145 // Update |tableView_| when chooser options changed. | 102 // Update |tableView_| when chooser options changed. |
| 146 - (void)updateTableView; | 103 - (void)updateTableView; |
| 147 | 104 |
| 148 // Called when the "Connect" button is pressed. | 105 // Called when the "Connect" button is pressed. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 172 // Gets the text from table row view. For testing and internal use only. | 129 // Gets the text from table row view. For testing and internal use only. |
| 173 - (NSTextField*)tableRowViewText:(NSInteger)row; | 130 - (NSTextField*)tableRowViewText:(NSInteger)row; |
| 174 | 131 |
| 175 // Gets the paired status from table row view. For testing and internal use | 132 // Gets the paired status from table row view. For testing and internal use |
| 176 // only. | 133 // only. |
| 177 - (NSTextField*)tableRowViewPairedStatus:(NSInteger)row; | 134 - (NSTextField*)tableRowViewPairedStatus:(NSInteger)row; |
| 178 | 135 |
| 179 @end | 136 @end |
| 180 | 137 |
| 181 #endif // CHROME_BROWSER_UI_COCOA_CHOOSER_CONTENT_VIEW_COCOA_H_ | 138 #endif // CHROME_BROWSER_UI_COCOA_CHOOSER_CONTENT_VIEW_COCOA_H_ |
| OLD | NEW |