| 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> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 base::scoped_nsobject<SpinnerView> spinner_; | 25 base::scoped_nsobject<SpinnerView> spinner_; |
| 26 base::scoped_nsobject<NSTextField> status_; | 26 base::scoped_nsobject<NSTextField> status_; |
| 27 base::scoped_nsobject<NSButton> rescanButton_; | 27 base::scoped_nsobject<NSButton> rescanButton_; |
| 28 base::scoped_nsobject<NSButton> connectButton_; | 28 base::scoped_nsobject<NSButton> connectButton_; |
| 29 base::scoped_nsobject<NSButton> cancelButton_; | 29 base::scoped_nsobject<NSButton> cancelButton_; |
| 30 base::scoped_nsobject<NSBox> separator_; | 30 base::scoped_nsobject<NSBox> separator_; |
| 31 base::scoped_nsobject<NSTextField> message_; | 31 base::scoped_nsobject<NSTextField> message_; |
| 32 base::scoped_nsobject<NSButton> helpButton_; | 32 base::scoped_nsobject<NSButton> helpButton_; |
| 33 std::unique_ptr<ChooserController> chooserController_; | 33 std::unique_ptr<ChooserController> chooserController_; |
| 34 std::unique_ptr<ChooserContentViewController> chooserContentViewController_; | 34 std::unique_ptr<ChooserContentViewController> chooserContentViewController_; |
| 35 |
| 36 CGFloat titleHeight_; |
| 37 CGFloat statusHeight_; |
| 38 CGFloat rescanButtonHeight_; |
| 39 CGFloat connectButtonWidth_; |
| 40 CGFloat connectButtonHeight_; |
| 41 CGFloat cancelButtonWidth_; |
| 42 CGFloat cancelButtonHeight_; |
| 43 CGFloat messageHeight_; |
| 44 |
| 45 struct FrameAndOrigin { |
| 46 NSRect scroll_view_frame; |
| 47 NSPoint connect_button_origin; |
| 48 NSPoint cancel_button_origin; |
| 49 }; |
| 50 |
| 51 // The cached |scrollView_| frame and |connectButton_| and |cancelButton_| |
| 52 // origins for views layout: |
| 53 // When |status_| is shown. |
| 54 FrameAndOrigin statusShown_; |
| 55 // When |rescanButton_| is shown. |
| 56 FrameAndOrigin rescanButtonShown_; |
| 57 // When neither |status_| nor |rescanButton_| is shown. |
| 58 FrameAndOrigin noStatusOrRescanButtonShown_; |
| 59 |
| 60 // The cached |status_| and |rescanButton_| origins. |
| 61 NSPoint statusOrigin_; |
| 62 NSPoint rescanButtonOrigin_; |
| 35 } | 63 } |
| 36 | 64 |
| 37 // Designated initializer. | 65 // Designated initializer. |
| 38 - (instancetype)initWithChooserTitle:(NSString*)chooserTitle | 66 - (instancetype)initWithChooserTitle:(NSString*)chooserTitle |
| 39 chooserController: | 67 chooserController: |
| 40 (std::unique_ptr<ChooserController>)chooserController; | 68 (std::unique_ptr<ChooserController>)chooserController; |
| 41 | 69 |
| 42 // Creates the title for the chooser. | 70 // Creates the title for the chooser. |
| 43 - (base::scoped_nsobject<NSTextField>)createChooserTitle:(NSString*)title; | 71 - (base::scoped_nsobject<NSTextField>)createChooserTitle:(NSString*)title; |
| 44 | 72 |
| 45 // Creates a button with |title|. | 73 // Creates a button with |title|. |
| 46 - (base::scoped_nsobject<NSButton>)createButtonWithTitle:(NSString*)title; | 74 - (base::scoped_nsobject<NSButton>)createButtonWithTitle:(NSString*)title; |
| 47 | 75 |
| 48 // Creates the "Connect" button. | 76 // Creates the "Connect" button. |
| 49 - (base::scoped_nsobject<NSButton>)createConnectButton; | 77 - (base::scoped_nsobject<NSButton>)createConnectButton; |
| 50 | 78 |
| 51 // Creates the "Cancel" button. | 79 // Creates the "Cancel" button. |
| 52 - (base::scoped_nsobject<NSButton>)createCancelButton; | 80 - (base::scoped_nsobject<NSButton>)createCancelButton; |
| 53 | 81 |
| 54 // Creates the separator. | 82 // Creates the separator. |
| 55 - (base::scoped_nsobject<NSBox>)createSeparator; | 83 - (base::scoped_nsobject<NSBox>)createSeparator; |
| 56 | 84 |
| 57 // Creates a text field with |text|. | 85 // Creates a text field with |text|. |
| 58 - (base::scoped_nsobject<NSTextField>)createTextField:(NSString*)text; | 86 - (base::scoped_nsobject<NSTextField>)createTextField:(NSString*)text; |
| 59 | 87 |
| 60 // Creates a hyperlink button with |text|. | 88 // Creates a hyperlink button with |text|. |
| 61 - (base::scoped_nsobject<NSButton>)createHyperlinkButtonWithText: | 89 - (base::scoped_nsobject<NSButton>)createHyperlinkButtonWithText: |
| 62 (NSString*)text; | 90 (NSString*)text; |
| 63 | 91 |
| 92 // Calculates the frame for the |scrollView_|. |
| 93 - (NSRect)calculateScrollViewFrame:(CGFloat)buttonRowHeight; |
| 94 |
| 95 // Calculates the origin for the |status_| text. |
| 96 - (NSPoint)calculateStatusOrigin:(CGFloat)buttonRowHeight; |
| 97 |
| 98 // Calculates the origin for the "Re-scan" button. |
| 99 - (NSPoint)calculateRescanButtonOrigin:(CGFloat)buttonRowHeight; |
| 100 |
| 101 // Calculates the origin for the "Connect" button. |
| 102 - (NSPoint)calculateConnectButtonOrigin:(CGFloat)buttonRowHeight; |
| 103 |
| 104 // Calculates the origin for the "Cancel" button. |
| 105 - (NSPoint)calculateCancelButtonOrigin:(CGFloat)buttonRowHeight; |
| 106 |
| 107 // Updates the origin and size of the view. |
| 108 - (void)updateView; |
| 109 |
| 64 // Gets the table view for the chooser. | 110 // Gets the table view for the chooser. |
| 65 - (NSTableView*)tableView; | 111 - (NSTableView*)tableView; |
| 66 | 112 |
| 67 // Gets the spinner. | 113 // Gets the spinner. |
| 68 - (SpinnerView*)spinner; | 114 - (SpinnerView*)spinner; |
| 69 | 115 |
| 70 // Gets the status text field. | 116 // Gets the status text field. |
| 71 - (NSTextField*)status; | 117 - (NSTextField*)status; |
| 72 | 118 |
| 73 // Gets the "Re-scan" button. | 119 // Gets the "Re-scan" button. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 102 | 148 |
| 103 // Called when "Re-scan" button is pressed. | 149 // Called when "Re-scan" button is pressed. |
| 104 - (void)onRescan:(id)sender; | 150 - (void)onRescan:(id)sender; |
| 105 | 151 |
| 106 // Called when the "Get help" button is pressed. | 152 // Called when the "Get help" button is pressed. |
| 107 - (void)onHelpPressed:(id)sender; | 153 - (void)onHelpPressed:(id)sender; |
| 108 | 154 |
| 109 @end | 155 @end |
| 110 | 156 |
| 111 #endif // CHROME_BROWSER_UI_COCOA_CHOOSER_CONTENT_VIEW_COCOA_H_ | 157 #endif // CHROME_BROWSER_UI_COCOA_CHOOSER_CONTENT_VIEW_COCOA_H_ |
| OLD | NEW |