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

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

Issue 2375843003: views: add Harmony dialog width support (Closed)
Patch Set: remove GetDialogWidth Created 4 years, 2 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_DELEGATE_H_ 5 #ifndef UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_
6 #define UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ 6 #define UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 13 matching lines...) Expand all
24 // DialogDelegate 24 // DialogDelegate
25 // 25 //
26 // DialogDelegate is an interface implemented by objects that wish to show a 26 // DialogDelegate is an interface implemented by objects that wish to show a
27 // dialog box Window. The window that is displayed uses this interface to 27 // dialog box Window. The window that is displayed uses this interface to
28 // determine how it should be displayed and notify the delegate object of 28 // determine how it should be displayed and notify the delegate object of
29 // certain events. 29 // certain events.
30 // 30 //
31 /////////////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////////////
32 class VIEWS_EXPORT DialogDelegate : public ui::DialogModel, 32 class VIEWS_EXPORT DialogDelegate : public ui::DialogModel,
33 public WidgetDelegate { 33 public WidgetDelegate {
34 // These values are in the 32px units the Harmony spec uses.
Evan Stade 2016/10/03 19:04:19 nit: I don't really think we need to mention "harm
Elly Fong-Jones 2016/10/05 13:20:31 But even after we're done, I think people may want
34 public: 35 public:
36 enum DialogWidth {
Evan Stade 2016/10/03 19:04:19 protected?
sky 2016/10/03 21:24:02 enum class and remove DIALOG_WIDTH from each name?
Evan Stade 2016/10/04 00:13:46 ahhhh, I forgot about this distinction. We do have
Elly Fong-Jones 2016/10/05 13:20:31 I don't understand this suggestion - aren't many d
Evan Stade 2016/10/05 19:52:28 I assume you meant to delete this comment
37 DIALOG_WIDTH_UNSPECIFIED,
38 DIALOG_WIDTH_SMALL = 10,
39 DIALOG_WIDTH_MEDIUM = 14,
40 DIALOG_WIDTH_LARGE = 16,
41 };
42
35 DialogDelegate(); 43 DialogDelegate();
36 ~DialogDelegate() override; 44 ~DialogDelegate() override;
37 45
38 // Creates a widget at a default location. 46 // Creates a widget at a default location.
39 static Widget* CreateDialogWidget(WidgetDelegate* delegate, 47 static Widget* CreateDialogWidget(WidgetDelegate* delegate,
40 gfx::NativeWindow context, 48 gfx::NativeWindow context,
41 gfx::NativeView parent); 49 gfx::NativeView parent);
42 50
43 // Returns the dialog widget InitParams for a given |context| or |parent|. 51 // Returns the dialog widget InitParams for a given |context| or |parent|.
44 // If |bounds| is not empty, used to initially place the dialog, otherwise 52 // If |bounds| is not empty, used to initially place the dialog, otherwise
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 118
111 // A helper for accessing the DialogClientView object contained by this 119 // A helper for accessing the DialogClientView object contained by this
112 // delegate's Window. 120 // delegate's Window.
113 const DialogClientView* GetDialogClientView() const; 121 const DialogClientView* GetDialogClientView() const;
114 DialogClientView* GetDialogClientView(); 122 DialogClientView* GetDialogClientView();
115 123
116 protected: 124 protected:
117 // Overridden from WidgetDelegate: 125 // Overridden from WidgetDelegate:
118 ui::AXRole GetAccessibleWindowRole() const override; 126 ui::AXRole GetAccessibleWindowRole() const override;
119 127
128 DialogWidth dialog_width() const { return dialog_width_; }
Evan Stade 2016/10/03 19:04:19 this getter doesn't seem necessary
Elly Fong-Jones 2016/10/05 13:20:31 It was only necessary because the member was priva
129 void set_dialog_width(DialogWidth width) { dialog_width_ = width; }
130
120 private: 131 private:
121 // A flag indicating whether this dialog is able to use the custom frame 132 // A flag indicating whether this dialog is able to use the custom frame
122 // style for dialogs. 133 // style for dialogs.
123 bool supports_custom_frame_; 134 bool supports_custom_frame_;
135
136 // The Harmony width to use for this dialog.
Evan Stade 2016/10/03 19:04:19 s/Harmony //
137 DialogWidth dialog_width_ = DIALOG_WIDTH_UNSPECIFIED;
124 }; 138 };
125 139
126 // A DialogDelegate implementation that is-a View. Used to override GetWidget() 140 // A DialogDelegate implementation that is-a View. Used to override GetWidget()
127 // to call View's GetWidget() for the common case where a DialogDelegate 141 // to call View's GetWidget() for the common case where a DialogDelegate
128 // implementation is-a View. Note that DialogDelegateView is not owned by 142 // implementation is-a View. Note that DialogDelegateView is not owned by
129 // view's hierarchy and is expected to be deleted on DeleteDelegate call. 143 // view's hierarchy and is expected to be deleted on DeleteDelegate call.
130 class VIEWS_EXPORT DialogDelegateView : public DialogDelegate, 144 class VIEWS_EXPORT DialogDelegateView : public DialogDelegate,
131 public View { 145 public View {
132 public: 146 public:
133 DialogDelegateView(); 147 DialogDelegateView();
134 ~DialogDelegateView() override; 148 ~DialogDelegateView() override;
135 149
136 // Overridden from DialogDelegate: 150 // Overridden from DialogDelegate:
137 void DeleteDelegate() override; 151 void DeleteDelegate() override;
138 Widget* GetWidget() override; 152 Widget* GetWidget() override;
139 const Widget* GetWidget() const override; 153 const Widget* GetWidget() const override;
140 View* GetContentsView() override; 154 View* GetContentsView() override;
141 155
142 // Overridden from View: 156 // Overridden from View:
143 void GetAccessibleState(ui::AXViewState* state) override; 157 void GetAccessibleState(ui::AXViewState* state) override;
144 void ViewHierarchyChanged( 158 void ViewHierarchyChanged(
145 const ViewHierarchyChangedDetails& details) override; 159 const ViewHierarchyChangedDetails& details) override;
160 gfx::Size GetPreferredSize() const override;
146 161
147 private: 162 private:
148 DISALLOW_COPY_AND_ASSIGN(DialogDelegateView); 163 DISALLOW_COPY_AND_ASSIGN(DialogDelegateView);
149 }; 164 };
150 165
151 } // namespace views 166 } // namespace views
152 167
153 #endif // UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ 168 #endif // UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698