| 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 10 matching lines...) Expand all Loading... |
| 21 #include "ui/message_center/views/message_view.h" | 21 #include "ui/message_center/views/message_view.h" |
| 22 #include "ui/views/background.h" | 22 #include "ui/views/background.h" |
| 23 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
| 26 | 26 |
| 27 #if defined(OS_WIN) && defined(USE_ASH) | 27 #if defined(OS_WIN) && defined(USE_ASH) |
| 28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 using gfx::Screen; | |
| 32 | |
| 33 namespace message_center { | 31 namespace message_center { |
| 34 namespace { | 32 namespace { |
| 35 | 33 |
| 36 // The width of a toast before animated reveal and after closing. | 34 // The width of a toast before animated reveal and after closing. |
| 37 const int kClosedToastWidth = 5; | 35 const int kClosedToastWidth = 5; |
| 38 | 36 |
| 39 // 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. |
| 40 const int kFadeInOutDuration = 200; | 38 const int kFadeInOutDuration = 200; |
| 41 | 39 |
| 42 } // namespace. | 40 } // namespace. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 240 |
| 243 void ToastContentsView::OnDisplayChanged() { | 241 void ToastContentsView::OnDisplayChanged() { |
| 244 views::Widget* widget = GetWidget(); | 242 views::Widget* widget = GetWidget(); |
| 245 if (!widget) | 243 if (!widget) |
| 246 return; | 244 return; |
| 247 | 245 |
| 248 gfx::NativeView native_view = widget->GetNativeView(); | 246 gfx::NativeView native_view = widget->GetNativeView(); |
| 249 if (!native_view || !collection_.get()) | 247 if (!native_view || !collection_.get()) |
| 250 return; | 248 return; |
| 251 | 249 |
| 252 collection_->OnDisplayMetricsChanged( | 250 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( |
| 253 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view), | 251 native_view)->GetDisplayNearestWindow(native_view)); |
| 254 gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS | | |
| 255 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | |
| 256 } | 252 } |
| 257 | 253 |
| 258 void ToastContentsView::OnWorkAreaChanged() { | 254 void ToastContentsView::OnWorkAreaChanged() { |
| 259 views::Widget* widget = GetWidget(); | 255 views::Widget* widget = GetWidget(); |
| 260 if (!widget) | 256 if (!widget) |
| 261 return; | 257 return; |
| 262 | 258 |
| 263 gfx::NativeView native_view = widget->GetNativeView(); | 259 gfx::NativeView native_view = widget->GetNativeView(); |
| 264 if (!native_view || !collection_.get()) | 260 if (!native_view || !collection_.get()) |
| 265 return; | 261 return; |
| 266 | 262 |
| 267 collection_->OnDisplayMetricsChanged( | 263 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( |
| 268 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view), | 264 native_view)->GetDisplayNearestWindow(native_view)); |
| 269 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | |
| 270 } | 265 } |
| 271 | 266 |
| 272 // views::View | 267 // views::View |
| 273 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) { | 268 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) { |
| 274 if (collection_) | 269 if (collection_) |
| 275 collection_->OnMouseEntered(this); | 270 collection_->OnMouseEntered(this); |
| 276 } | 271 } |
| 277 | 272 |
| 278 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) { | 273 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) { |
| 279 if (collection_) | 274 if (collection_) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 352 } |
| 358 | 353 |
| 359 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { | 354 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { |
| 360 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, | 355 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, |
| 361 bounds.y(), | 356 bounds.y(), |
| 362 kClosedToastWidth, | 357 kClosedToastWidth, |
| 363 bounds.height()); | 358 bounds.height()); |
| 364 } | 359 } |
| 365 | 360 |
| 366 } // namespace message_center | 361 } // namespace message_center |
| OLD | NEW |