| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 const gfx::Animation* animation) { | 192 const gfx::Animation* animation) { |
| 193 if (is_closing_ && closing_animation_ == animation && GetWidget()) { | 193 if (is_closing_ && closing_animation_ == animation && GetWidget()) { |
| 194 views::Widget* widget = GetWidget(); | 194 views::Widget* widget = GetWidget(); |
| 195 | 195 |
| 196 // TODO(dewittj): This is a workaround to prevent a nasty bug where | 196 // TODO(dewittj): This is a workaround to prevent a nasty bug where |
| 197 // closing a transparent widget doesn't actually remove the window, | 197 // closing a transparent widget doesn't actually remove the window, |
| 198 // causing entire areas of the screen to become unresponsive to clicks. | 198 // causing entire areas of the screen to become unresponsive to clicks. |
| 199 // See crbug.com/243469 | 199 // See crbug.com/243469 |
| 200 widget->Hide(); | 200 widget->Hide(); |
| 201 #if defined(OS_WIN) | 201 #if defined(OS_WIN) |
| 202 widget->SetOpacity(0xFF); | 202 widget->SetOpacity(1.f); |
| 203 #endif | 203 #endif |
| 204 | 204 |
| 205 widget->Close(); | 205 widget->Close(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // This cannot be called before GetWidget()->Close(). Decrementing defer count | 208 // This cannot be called before GetWidget()->Close(). Decrementing defer count |
| 209 // will invoke update, which may invoke another close animation with | 209 // will invoke update, which may invoke another close animation with |
| 210 // incrementing defer counter. Close() after such process will cause a | 210 // incrementing defer counter. Close() after such process will cause a |
| 211 // mismatch between increment/decrement. See crbug.com/238477 | 211 // mismatch between increment/decrement. See crbug.com/238477 |
| 212 if (collection_) | 212 if (collection_) |
| 213 collection_->DecrementDeferCounter(); | 213 collection_->DecrementDeferCounter(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // gfx::AnimationDelegate | 216 // gfx::AnimationDelegate |
| 217 void ToastContentsView::AnimationProgressed(const gfx::Animation* animation) { | 217 void ToastContentsView::AnimationProgressed(const gfx::Animation* animation) { |
| 218 if (animation == bounds_animation_.get()) { | 218 if (animation == bounds_animation_.get()) { |
| 219 gfx::Rect current(animation->CurrentValueBetween( | 219 gfx::Rect current(animation->CurrentValueBetween( |
| 220 animated_bounds_start_, animated_bounds_end_)); | 220 animated_bounds_start_, animated_bounds_end_)); |
| 221 GetWidget()->SetBounds(current); | 221 GetWidget()->SetBounds(current); |
| 222 } else if (animation == fade_animation_.get()) { | 222 } else if (animation == fade_animation_.get()) { |
| 223 unsigned char opacity = | 223 GetWidget()->SetOpacity( |
| 224 static_cast<unsigned char>(fade_animation_->GetCurrentValue() * 255); | 224 static_cast<float>(fade_animation_->GetCurrentValue())); |
| 225 GetWidget()->SetOpacity(opacity); | |
| 226 } | 225 } |
| 227 } | 226 } |
| 228 | 227 |
| 229 void ToastContentsView::AnimationEnded(const gfx::Animation* animation) { | 228 void ToastContentsView::AnimationEnded(const gfx::Animation* animation) { |
| 230 OnBoundsAnimationEndedOrCancelled(animation); | 229 OnBoundsAnimationEndedOrCancelled(animation); |
| 231 } | 230 } |
| 232 | 231 |
| 233 void ToastContentsView::AnimationCanceled( | 232 void ToastContentsView::AnimationCanceled( |
| 234 const gfx::Animation* animation) { | 233 const gfx::Animation* animation) { |
| 235 OnBoundsAnimationEndedOrCancelled(animation); | 234 OnBoundsAnimationEndedOrCancelled(animation); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 380 } |
| 382 | 381 |
| 383 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { | 382 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { |
| 384 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, | 383 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, |
| 385 bounds.y(), | 384 bounds.y(), |
| 386 kClosedToastWidth, | 385 kClosedToastWidth, |
| 387 bounds.height()); | 386 bounds.height()); |
| 388 } | 387 } |
| 389 | 388 |
| 390 } // namespace message_center | 389 } // namespace message_center |
| OLD | NEW |