Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 5 #ifndef UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
| 6 #define UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 6 #define UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/base/ui_base_types.h" | 10 #include "ui/base/ui_base_types.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 // Update the dialog buttons to match the dialog's delegate. | 44 // Update the dialog buttons to match the dialog's delegate. |
| 45 void UpdateDialogButtons(); | 45 void UpdateDialogButtons(); |
| 46 | 46 |
| 47 // ClientView implementation: | 47 // ClientView implementation: |
| 48 bool CanClose() override; | 48 bool CanClose() override; |
| 49 DialogClientView* AsDialogClientView() override; | 49 DialogClientView* AsDialogClientView() override; |
| 50 const DialogClientView* AsDialogClientView() const override; | 50 const DialogClientView* AsDialogClientView() const override; |
| 51 | 51 |
| 52 // View implementation: | 52 // View implementation: |
| 53 gfx::Size GetPreferredSize() const override; | 53 gfx::Size GetPreferredSize() const override; |
| 54 gfx::Size GetMinimumSize() const override; | |
| 55 gfx::Size GetMaximumSize() const override; | |
| 56 | |
| 54 void Layout() override; | 57 void Layout() override; |
| 55 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 58 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 56 void ViewHierarchyChanged( | 59 void ViewHierarchyChanged( |
| 57 const ViewHierarchyChangedDetails& details) override; | 60 const ViewHierarchyChangedDetails& details) override; |
| 58 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 61 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 59 | 62 |
| 60 // ButtonListener implementation: | 63 // ButtonListener implementation: |
| 61 void ButtonPressed(Button* sender, const ui::Event& event) override; | 64 void ButtonPressed(Button* sender, const ui::Event& event) override; |
| 62 | 65 |
| 63 void set_button_row_insets(const gfx::Insets& insets) { | 66 void set_button_row_insets(const gfx::Insets& insets) { |
| 64 button_row_insets_ = insets; | 67 button_row_insets_ = insets; |
| 65 } | 68 } |
| 66 | 69 |
| 67 void set_minimum_size(const gfx::Size& size) { minimum_size_ = size; } | 70 void set_minimum_size(const gfx::Size& size) { minimum_size_ = size; } |
| 68 | 71 |
| 69 private: | 72 private: |
| 70 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } | 73 class ButtonRowContainer; |
| 71 | 74 |
| 72 // Returns the DialogDelegate for the window. | 75 // Returns the DialogDelegate for the window. |
| 73 DialogDelegate* GetDialogDelegate() const; | 76 DialogDelegate* GetDialogDelegate() const; |
| 74 | 77 |
| 75 // View implementation. | 78 // View implementation. |
| 76 void ChildPreferredSizeChanged(View* child) override; | 79 void ChildPreferredSizeChanged(View* child) override; |
| 77 void ChildVisibilityChanged(View* child) override; | 80 void ChildVisibilityChanged(View* child) override; |
| 78 | 81 |
| 79 // Create a dialog button of the appropriate type. | 82 // Create and/or update the dialog button of |type| according to the |
|
Peter Kasting
2017/02/28 03:33:24
Creates, updates (descriptive, not imperative; see
tapted
2017/02/28 06:52:43
Done.
| |
| 80 LabelButton* CreateDialogButton(ui::DialogButton type); | 83 // DialogDelegate methods that provide the button configuration. Stores it in |
| 81 | 84 // the provided data |member| if non-null, otherwise updates it. |
|
Peter Kasting
2017/02/28 03:33:23
This last sentence is still confusing to me.
From
tapted
2017/02/28 06:52:43
Done.
| |
| 82 // Update |button|'s text and enabled state according to the delegate's state. | 85 void UpdateDialogButton(LabelButton** member, ui::DialogButton type); |
| 83 void UpdateButton(LabelButton* button, ui::DialogButton type); | |
| 84 | |
| 85 // Returns the height of the buttons. | |
| 86 int GetButtonHeight() const; | |
| 87 | |
| 88 // Returns the height of the extra view. | |
| 89 int GetExtraViewHeight() const; | |
| 90 | |
| 91 // Returns the height of the row containing the buttons and the extra view. | |
| 92 int GetButtonsAndExtraViewRowHeight() const; | |
| 93 | |
| 94 // Returns the insets for the buttons and extra view, including the vertical | |
| 95 // padding between them and the contents view. | |
| 96 gfx::Insets GetButtonRowInsets() const; | |
| 97 | |
| 98 // Sets up the focus chain for the child views. This is required since the | |
| 99 // delegate may choose to add/remove views at any time. | |
| 100 void SetupFocusChain(); | |
| 101 | 86 |
| 102 // Returns the spacing between the extra view and the ok/cancel buttons. 0 if | 87 // Returns the spacing between the extra view and the ok/cancel buttons. 0 if |
| 103 // no extra view. Otherwise uses GetExtraViewPadding() or the default padding. | 88 // no extra view. Otherwise uses GetExtraViewPadding() or the default padding. |
| 104 int GetExtraViewSpacing() const; | 89 int GetExtraViewSpacing() const; |
| 105 | 90 |
| 91 // Returns any Views in the button row, in the order they should appear. | |
| 92 std::vector<View*> GetButtonRowViews(); | |
| 93 | |
| 94 // Installs and configures the LayoutManager for |button_row_container_|. | |
| 95 void SetupLayout(); | |
| 96 | |
| 106 // Creates or deletes any buttons that are required. Updates data members. | 97 // Creates or deletes any buttons that are required. Updates data members. |
| 98 // After calling this, no button row Views will be in the view hierarchy. | |
| 107 void SetupViews(); | 99 void SetupViews(); |
| 108 | 100 |
| 109 // How much to inset the button row. | 101 // How much to inset the button row. |
| 110 gfx::Insets button_row_insets_; | 102 gfx::Insets button_row_insets_; |
| 111 | 103 |
| 112 // The minimum size of this dialog, regardless of the size of its content | 104 // The minimum size of this dialog, regardless of the size of its content |
| 113 // view. | 105 // view. |
| 114 gfx::Size minimum_size_; | 106 gfx::Size minimum_size_; |
| 115 | 107 |
| 116 // The dialog buttons. | 108 // The dialog buttons. |
| 117 LabelButton* ok_button_ = nullptr; | 109 LabelButton* ok_button_ = nullptr; |
| 118 LabelButton* cancel_button_ = nullptr; | 110 LabelButton* cancel_button_ = nullptr; |
| 119 | 111 |
| 120 // The extra view shown in the row of buttons; may be NULL. | 112 // The extra view shown in the row of buttons; may be NULL. |
| 121 View* extra_view_ = nullptr; | 113 View* extra_view_ = nullptr; |
| 122 | 114 |
| 115 // Container view for the button row. | |
| 116 ButtonRowContainer* button_row_container_ = nullptr; | |
| 117 | |
| 123 // True if we've notified the delegate the window is closing and the delegate | 118 // True if we've notified the delegate the window is closing and the delegate |
| 124 // allowed the close. In some situations it's possible to get two closes (see | 119 // allowed the close. In some situations it's possible to get two closes (see |
| 125 // http://crbug.com/71940). This is used to avoid notifying the delegate | 120 // http://crbug.com/71940). This is used to avoid notifying the delegate |
| 126 // twice, which can have bad consequences. | 121 // twice, which can have bad consequences. |
| 127 bool delegate_allowed_close_ = false; | 122 bool delegate_allowed_close_ = false; |
| 128 | 123 |
| 124 // When true, prevents ViewHierarchyChanged() from clearing out data members. | |
| 125 bool preserve_button_row_data_members_ = false; | |
| 126 | |
| 129 DISALLOW_COPY_AND_ASSIGN(DialogClientView); | 127 DISALLOW_COPY_AND_ASSIGN(DialogClientView); |
| 130 }; | 128 }; |
| 131 | 129 |
| 132 } // namespace views | 130 } // namespace views |
| 133 | 131 |
| 134 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 132 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
| OLD | NEW |