OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |