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

Side by Side Diff: ui/message_center/views/toast_contents_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/message_center/views/toast_contents_view.h ('k') | ui/views/bubble/bubble_delegate.h » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/message_center/views/toast_contents_view.h" 5 #include "ui/message_center/views/toast_contents_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 22 matching lines...) Expand all
33 33
34 // The width of a toast before animated reveal and after closing. 34 // The width of a toast before animated reveal and after closing.
35 const int kClosedToastWidth = 5; 35 const int kClosedToastWidth = 5;
36 36
37 // FadeIn/Out look a bit better if they are slightly longer then default slide. 37 // FadeIn/Out look a bit better if they are slightly longer then default slide.
38 const int kFadeInOutDuration = 200; 38 const int kFadeInOutDuration = 200;
39 39
40 } // namespace. 40 } // namespace.
41 41
42 // static 42 // static
43 gfx::Size ToastContentsView::GetToastSizeForView(views::View* view) { 43 gfx::Size ToastContentsView::GetToastSizeForView(const views::View* view) {
44 int width = kNotificationWidth + view->GetInsets().width(); 44 int width = kNotificationWidth + view->GetInsets().width();
45 return gfx::Size(width, view->GetHeightForWidth(width)); 45 return gfx::Size(width, view->GetHeightForWidth(width));
46 } 46 }
47 47
48 ToastContentsView::ToastContentsView( 48 ToastContentsView::ToastContentsView(
49 const std::string& notification_id, 49 const std::string& notification_id,
50 base::WeakPtr<MessagePopupCollection> collection) 50 base::WeakPtr<MessagePopupCollection> collection)
51 : collection_(collection), 51 : collection_(collection),
52 id_(notification_id), 52 id_(notification_id),
53 is_animating_bounds_(false), 53 is_animating_bounds_(false),
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 collection_->OnMouseExited(this); 275 collection_->OnMouseExited(this);
276 } 276 }
277 277
278 void ToastContentsView::Layout() { 278 void ToastContentsView::Layout() {
279 if (child_count() > 0) { 279 if (child_count() > 0) {
280 child_at(0)->SetBounds( 280 child_at(0)->SetBounds(
281 0, 0, preferred_size_.width(), preferred_size_.height()); 281 0, 0, preferred_size_.width(), preferred_size_.height());
282 } 282 }
283 } 283 }
284 284
285 gfx::Size ToastContentsView::GetPreferredSize() { 285 gfx::Size ToastContentsView::GetPreferredSize() const {
286 return child_count() ? GetToastSizeForView(child_at(0)) : gfx::Size(); 286 return child_count() ? GetToastSizeForView(child_at(0)) : gfx::Size();
287 } 287 }
288 288
289 void ToastContentsView::GetAccessibleState(ui::AXViewState* state) { 289 void ToastContentsView::GetAccessibleState(ui::AXViewState* state) {
290 if (child_count() > 0) 290 if (child_count() > 0)
291 child_at(0)->GetAccessibleState(state); 291 child_at(0)->GetAccessibleState(state);
292 state->role = ui::AX_ROLE_WINDOW; 292 state->role = ui::AX_ROLE_WINDOW;
293 } 293 }
294 294
295 void ToastContentsView::ClickOnNotification( 295 void ToastContentsView::ClickOnNotification(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 352 }
353 353
354 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { 354 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) {
355 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, 355 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth,
356 bounds.y(), 356 bounds.y(),
357 kClosedToastWidth, 357 kClosedToastWidth,
358 bounds.height()); 358 bounds.height());
359 } 359 }
360 360
361 } // namespace message_center 361 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/toast_contents_view.h ('k') | ui/views/bubble/bubble_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698