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

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

Issue 2705553002: Cleanups for DialogClientView, DialogClientViewTest. (Closed)
Patch Set: Remove unncessary child check Created 3 years, 10 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
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // ButtonListener implementation: 60 // ButtonListener implementation:
61 void ButtonPressed(Button* sender, const ui::Event& event) override; 61 void ButtonPressed(Button* sender, const ui::Event& event) override;
62 62
63 void set_button_row_insets(const gfx::Insets& insets) { 63 void set_button_row_insets(const gfx::Insets& insets) {
64 button_row_insets_ = insets; 64 button_row_insets_ = insets;
65 } 65 }
66 66
67 void set_minimum_size(const gfx::Size& size) { minimum_size_ = size; } 67 void set_minimum_size(const gfx::Size& size) { minimum_size_ = size; }
68 68
69 protected: 69 private:
70 // For testing. 70 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; }
71 explicit DialogClientView(View* contents_view);
72 71
73 // Returns the DialogDelegate for the window. Virtual for testing. 72 // Returns the DialogDelegate for the window.
74 virtual DialogDelegate* GetDialogDelegate() const; 73 DialogDelegate* GetDialogDelegate() const;
75
76 // Create and add the extra view, if supplied by the delegate.
77 void CreateExtraView();
78 74
79 // View implementation. 75 // View implementation.
80 void ChildPreferredSizeChanged(View* child) override; 76 void ChildPreferredSizeChanged(View* child) override;
81 void ChildVisibilityChanged(View* child) override; 77 void ChildVisibilityChanged(View* child) override;
82 78
83 private:
84 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; }
85
86 // Create a dialog button of the appropriate type. 79 // Create a dialog button of the appropriate type.
87 LabelButton* CreateDialogButton(ui::DialogButton type); 80 LabelButton* CreateDialogButton(ui::DialogButton type);
88 81
89 // Update |button|'s text and enabled state according to the delegate's state. 82 // Update |button|'s text and enabled state according to the delegate's state.
90 void UpdateButton(LabelButton* button, ui::DialogButton type); 83 void UpdateButton(LabelButton* button, ui::DialogButton type);
91 84
92 // Returns the height of the buttons. 85 // Returns the height of the buttons.
93 int GetButtonHeight() const; 86 int GetButtonHeight() const;
94 87
95 // Returns the height of the extra view. 88 // Returns the height of the extra view.
96 int GetExtraViewHeight() const; 89 int GetExtraViewHeight() const;
97 90
98 // Returns the height of the row containing the buttons and the extra view. 91 // Returns the height of the row containing the buttons and the extra view.
99 int GetButtonsAndExtraViewRowHeight() const; 92 int GetButtonsAndExtraViewRowHeight() const;
100 93
101 // Returns the insets for the buttons and extra view, including the vertical 94 // Returns the insets for the buttons and extra view, including the vertical
102 // padding between them and the contents view. 95 // padding between them and the contents view.
103 gfx::Insets GetButtonRowInsets() const; 96 gfx::Insets GetButtonRowInsets() const;
104 97
105 // Sets up the focus chain for the child views. This is required since the 98 // Sets up the focus chain for the child views. This is required since the
106 // delegate may choose to add/remove views at any time. 99 // delegate may choose to add/remove views at any time.
107 void SetupFocusChain(); 100 void SetupFocusChain();
108 101
102 // 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.
104 int GetExtraViewSpacing() const;
105
106 // Creates or deletes any buttons that are required. Updates data members.
107 void SetupViews();
108
109 // How much to inset the button row. 109 // How much to inset the button row.
110 gfx::Insets button_row_insets_; 110 gfx::Insets button_row_insets_;
111 111
112 // The minimum size of this dialog, regardless of the size of its content 112 // The minimum size of this dialog, regardless of the size of its content
113 // view. 113 // view.
114 gfx::Size minimum_size_; 114 gfx::Size minimum_size_;
115 115
116 // The dialog buttons. 116 // The dialog buttons.
117 LabelButton* ok_button_ = nullptr; 117 LabelButton* ok_button_ = nullptr;
118 LabelButton* cancel_button_ = nullptr; 118 LabelButton* cancel_button_ = nullptr;
119 119
120 // The extra view shown in the row of buttons; may be NULL. 120 // The extra view shown in the row of buttons; may be NULL.
121 View* extra_view_ = nullptr; 121 View* extra_view_ = nullptr;
122 122
123 // True if we've notified the delegate the window is closing and the delegate 123 // 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 124 // 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 125 // http://crbug.com/71940). This is used to avoid notifying the delegate
126 // twice, which can have bad consequences. 126 // twice, which can have bad consequences.
127 bool delegate_allowed_close_ = false; 127 bool delegate_allowed_close_ = false;
128 128
129 DISALLOW_COPY_AND_ASSIGN(DialogClientView); 129 DISALLOW_COPY_AND_ASSIGN(DialogClientView);
130 }; 130 };
131 131
132 } // namespace views 132 } // namespace views
133 133
134 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ 134 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698