Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 ToastContentsView::ToastContentsView( | 52 ToastContentsView::ToastContentsView( |
| 53 const std::string& notification_id, | 53 const std::string& notification_id, |
| 54 PopupAlignmentDelegate* alignment_delegate, | 54 PopupAlignmentDelegate* alignment_delegate, |
| 55 base::WeakPtr<MessagePopupCollection> collection) | 55 base::WeakPtr<MessagePopupCollection> collection) |
| 56 : collection_(collection), | 56 : collection_(collection), |
| 57 id_(notification_id), | 57 id_(notification_id), |
| 58 is_closing_(false), | 58 is_closing_(false), |
| 59 closing_animation_(NULL) { | 59 closing_animation_(NULL) { |
| 60 DCHECK(alignment_delegate); | 60 DCHECK(alignment_delegate); |
| 61 set_notify_enter_exit_on_child(true); | 61 set_notify_enter_exit_on_child(true); |
| 62 // Sets the transparent background. Then, when the message view is slid out, | 62 // Sets the transparent background. Then, when the message view is slid out, |
|
sky
2016/10/07 15:21:08
I'm not familiar enough with this code to know if
dewittj
2016/10/07 18:59:26
+mukai@, the original author
Seems like we aren't
Jun Mukai
2016/10/07 20:46:49
It's hard for me to remember everything... Sorry.
| |
| 63 // the whole toast seems to slide although the actual bound of the widget | 63 // the whole toast seems to slide although the actual bound of the widget |
| 64 // remains. This is hacky but easier to keep the consistency. | 64 // remains. This is hacky but easier to keep the consistency. |
| 65 set_background(views::Background::CreateSolidBackground(0, 0, 0, 0)); | 65 set_background(views::Background::CreateSolidBackground(0, 0, 0, 0)); |
| 66 | 66 |
| 67 fade_animation_.reset(new gfx::SlideAnimation(this)); | 67 fade_animation_.reset(new gfx::SlideAnimation(this)); |
| 68 fade_animation_->SetSlideDuration(kFadeInOutDuration); | 68 fade_animation_->SetSlideDuration(kFadeInOutDuration); |
| 69 | 69 |
| 70 CreateWidget(alignment_delegate); | 70 CreateWidget(alignment_delegate); |
| 71 } | 71 } |
| 72 | 72 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 collection_->DecrementDeferCounter(); | 216 collection_->DecrementDeferCounter(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // gfx::AnimationDelegate | 219 // gfx::AnimationDelegate |
| 220 void ToastContentsView::AnimationProgressed(const gfx::Animation* animation) { | 220 void ToastContentsView::AnimationProgressed(const gfx::Animation* animation) { |
| 221 if (animation == bounds_animation_.get()) { | 221 if (animation == bounds_animation_.get()) { |
| 222 gfx::Rect current(animation->CurrentValueBetween( | 222 gfx::Rect current(animation->CurrentValueBetween( |
| 223 animated_bounds_start_, animated_bounds_end_)); | 223 animated_bounds_start_, animated_bounds_end_)); |
| 224 GetWidget()->SetBounds(current); | 224 GetWidget()->SetBounds(current); |
| 225 } else if (animation == fade_animation_.get()) { | 225 } else if (animation == fade_animation_.get()) { |
| 226 GetWidget()->SetOpacity( | 226 GetWidget()->SetOpacity( |
|
sky
2016/10/06 21:44:56
I'm confused, this is changing the opacity. Doesn'
Jun Mukai
2016/10/07 20:46:49
This is for normal show/disappear animation. The h
| |
| 227 static_cast<float>(fade_animation_->GetCurrentValue())); | 227 static_cast<float>(fade_animation_->GetCurrentValue())); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 void ToastContentsView::AnimationEnded(const gfx::Animation* animation) { | 231 void ToastContentsView::AnimationEnded(const gfx::Animation* animation) { |
| 232 OnBoundsAnimationEndedOrCancelled(animation); | 232 OnBoundsAnimationEndedOrCancelled(animation); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void ToastContentsView::AnimationCanceled( | 235 void ToastContentsView::AnimationCanceled( |
| 236 const gfx::Animation* animation) { | 236 const gfx::Animation* animation) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 const std::string& notification_id, | 358 const std::string& notification_id, |
| 359 int button_index) { | 359 int button_index) { |
| 360 if (collection_) | 360 if (collection_) |
| 361 collection_->ClickOnNotificationButton(notification_id, button_index); | 361 collection_->ClickOnNotificationButton(notification_id, button_index); |
| 362 } | 362 } |
| 363 | 363 |
| 364 void ToastContentsView::CreateWidget( | 364 void ToastContentsView::CreateWidget( |
| 365 PopupAlignmentDelegate* alignment_delegate) { | 365 PopupAlignmentDelegate* alignment_delegate) { |
| 366 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 366 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 367 params.keep_on_top = true; | 367 params.keep_on_top = true; |
| 368 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 368 params.opacity = views::Widget::InitParams::INFER_OPACITY; |
| 369 params.delegate = this; | 369 params.delegate = this; |
| 370 views::Widget* widget = new views::Widget(); | 370 views::Widget* widget = new views::Widget(); |
| 371 alignment_delegate->ConfigureWidgetInitParamsForContainer(widget, ¶ms); | 371 alignment_delegate->ConfigureWidgetInitParamsForContainer(widget, ¶ms); |
| 372 widget->set_focus_on_creation(false); | 372 widget->set_focus_on_creation(false); |
| 373 | 373 |
| 374 #if defined(OS_WIN) | 374 #if defined(OS_WIN) |
| 375 // We want to ensure that this toast always goes to the native desktop, | 375 // We want to ensure that this toast always goes to the native desktop, |
| 376 // not the Ash desktop (since there is already another toast contents view | 376 // not the Ash desktop (since there is already another toast contents view |
| 377 // there. | 377 // there. |
| 378 if (!params.parent) | 378 if (!params.parent) |
| 379 params.native_widget = new views::DesktopNativeWidgetAura(widget); | 379 params.native_widget = new views::DesktopNativeWidgetAura(widget); |
| 380 #endif | 380 #endif |
| 381 | 381 |
| 382 widget->Init(params); | 382 widget->Init(params); |
| 383 } | 383 } |
| 384 | 384 |
| 385 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { | 385 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { |
| 386 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, | 386 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, |
| 387 bounds.y(), | 387 bounds.y(), |
| 388 kClosedToastWidth, | 388 kClosedToastWidth, |
| 389 bounds.height()); | 389 bounds.height()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace message_center | 392 } // namespace message_center |
| OLD | NEW |