Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: ui/views/window/dialog_client_view.h

Issue 2706423002: Use GridLayout for DialogClientView's button row. (Closed)
Patch Set: Add a juicy test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Update the dialog button |member| according to the DialogDelegate.
Peter Kasting 2017/02/25 06:04:08 Nit: Updates Updates like how? Do you need to sa
tapted 2017/02/27 10:04:19 Done.
80 LabelButton* CreateDialogButton(ui::DialogButton type); 83 void UpdateDialogButton(LabelButton** member, ui::DialogButton type);
81
82 // Update |button|'s text and enabled state according to the delegate's state.
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 84
102 // Returns the spacing between the extra view and the ok/cancel buttons. 0 if 85 // 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. 86 // no extra view. Otherwise uses GetExtraViewPadding() or the default padding.
104 int GetExtraViewSpacing() const; 87 int GetExtraViewSpacing() const;
105 88
89 // Returns the 0-3 Views in the order they should appear in the button row.
Peter Kasting 2017/02/25 06:04:08 Nit: the 0-3 Views -> any button views (Seems bes
tapted 2017/02/27 10:04:19 Done.
90 std::vector<View*> ButtonRowViews();
Peter Kasting 2017/02/25 06:04:08 Nit: GetButtonRowViews()?
tapted 2017/02/27 10:04:19 Done.
91
92 // Installs and configures the LayoutManager for |button_row_container_|.
93 void SetupLayout();
94
106 // Creates or deletes any buttons that are required. Updates data members. 95 // Creates or deletes any buttons that are required. Updates data members.
96 // All buttons are removed from the hierarchy to be added by the layout.
Peter Kasting 2017/02/25 06:04:08 Nit: I don't really understand this sentence. Not
tapted 2017/02/27 10:04:19 Changed to "After calling this, no button row View
Peter Kasting 2017/02/28 03:33:23 Is that accurate, though? Maybe you mean "...any
tapted 2017/02/28 06:52:42 Nah, in this case SetupLayout() is relying on Setu
107 void SetupViews(); 97 void SetupViews();
108 98
109 // How much to inset the button row. 99 // How much to inset the button row.
110 gfx::Insets button_row_insets_; 100 gfx::Insets button_row_insets_;
111 101
112 // The minimum size of this dialog, regardless of the size of its content 102 // The minimum size of this dialog, regardless of the size of its content
113 // view. 103 // view.
114 gfx::Size minimum_size_; 104 gfx::Size minimum_size_;
115 105
116 // The dialog buttons. 106 // The dialog buttons.
117 LabelButton* ok_button_ = nullptr; 107 LabelButton* ok_button_ = nullptr;
118 LabelButton* cancel_button_ = nullptr; 108 LabelButton* cancel_button_ = nullptr;
119 109
120 // The extra view shown in the row of buttons; may be NULL. 110 // The extra view shown in the row of buttons; may be NULL.
121 View* extra_view_ = nullptr; 111 View* extra_view_ = nullptr;
122 112
113 // Container view for the button row.
114 ButtonRowContainer* button_row_container_ = nullptr;
115
123 // True if we've notified the delegate the window is closing and the delegate 116 // 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 117 // 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 118 // http://crbug.com/71940). This is used to avoid notifying the delegate
126 // twice, which can have bad consequences. 119 // twice, which can have bad consequences.
127 bool delegate_allowed_close_ = false; 120 bool delegate_allowed_close_ = false;
128 121
122 // Prevents ViewHierarchyChanged() from clearing out data members.
Peter Kasting 2017/02/25 06:04:08 Nit: "When true, ..."
tapted 2017/02/27 10:04:19 Done.
123 bool in_setup_views_ = false;
Peter Kasting 2017/02/25 06:04:08 Nit: Seems like this should be named by what we wa
tapted 2017/02/27 10:04:19 Done.
124
129 DISALLOW_COPY_AND_ASSIGN(DialogClientView); 125 DISALLOW_COPY_AND_ASSIGN(DialogClientView);
130 }; 126 };
131 127
132 } // namespace views 128 } // namespace views
133 129
134 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ 130 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698