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

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

Issue 2785683003: views: implement width snapping for DialogDelegateViews (Closed)
Patch Set: Created 3 years, 8 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 #include "ui/views/window/dialog_delegate.h" 5 #include "ui/views/window/dialog_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 //////////////////////////////////////////////////////////////////////////////// 234 ////////////////////////////////////////////////////////////////////////////////
235 // DialogDelegateView: 235 // DialogDelegateView:
236 236
237 DialogDelegateView::DialogDelegateView() { 237 DialogDelegateView::DialogDelegateView() {
238 // A WidgetDelegate should be deleted on DeleteDelegate. 238 // A WidgetDelegate should be deleted on DeleteDelegate.
239 set_owned_by_client(); 239 set_owned_by_client();
240 } 240 }
241 241
242 DialogDelegateView::~DialogDelegateView() {} 242 DialogDelegateView::~DialogDelegateView() {}
243 243
244 gfx::Size DialogDelegateView::GetUnsnappedPreferredSize() const {
245 return View::GetPreferredSize();
246 }
247
244 void DialogDelegateView::DeleteDelegate() { 248 void DialogDelegateView::DeleteDelegate() {
245 delete this; 249 delete this;
246 } 250 }
247 251
248 Widget* DialogDelegateView::GetWidget() { 252 Widget* DialogDelegateView::GetWidget() {
249 return View::GetWidget(); 253 return View::GetWidget();
250 } 254 }
251 255
252 const Widget* DialogDelegateView::GetWidget() const { 256 const Widget* DialogDelegateView::GetWidget() const {
253 return View::GetWidget(); 257 return View::GetWidget();
254 } 258 }
255 259
256 View* DialogDelegateView::GetContentsView() { 260 View* DialogDelegateView::GetContentsView() {
257 return this; 261 return this;
258 } 262 }
259 263
260 void DialogDelegateView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 264 void DialogDelegateView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
261 node_data->SetName(GetWindowTitle()); 265 node_data->SetName(GetWindowTitle());
262 node_data->role = ui::AX_ROLE_DIALOG; 266 node_data->role = ui::AX_ROLE_DIALOG;
263 } 267 }
264 268
269 gfx::Size DialogDelegateView::GetPreferredSize() const {
270 gfx::Size size = GetUnsnappedPreferredSize();
271 size.set_width(
272 ViewsDelegate::GetInstance()->GetSnappedDialogWidth(size.width()));
273 return size;
274 }
275
265 void DialogDelegateView::ViewHierarchyChanged( 276 void DialogDelegateView::ViewHierarchyChanged(
266 const ViewHierarchyChangedDetails& details) { 277 const ViewHierarchyChangedDetails& details) {
267 if (details.is_add && details.child == this && GetWidget()) 278 if (details.is_add && details.child == this && GetWidget())
268 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 279 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
269 } 280 }
270 281
271 } // namespace views 282 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698