| 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/message_center_view.h" | 5 #include "ui/message_center/views/message_center_view.h" | 
| 6 | 6 | 
| 7 #include <list> | 7 #include <list> | 
| 8 #include <map> | 8 #include <map> | 
| 9 | 9 | 
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" | 
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" | 
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" | 
| 13 #include "grit/ui_strings.h" | 13 #include "grit/ui_strings.h" | 
| 14 #include "ui/base/animation/multi_animation.h" |  | 
| 15 #include "ui/base/animation/slide_animation.h" |  | 
| 16 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" | 
|  | 15 #include "ui/gfx/animation/multi_animation.h" | 
|  | 16 #include "ui/gfx/animation/slide_animation.h" | 
| 17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" | 
| 18 #include "ui/gfx/insets.h" | 18 #include "ui/gfx/insets.h" | 
| 19 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" | 
| 20 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" | 
| 21 #include "ui/message_center/message_center.h" | 21 #include "ui/message_center/message_center.h" | 
| 22 #include "ui/message_center/message_center_style.h" | 22 #include "ui/message_center/message_center_style.h" | 
| 23 #include "ui/message_center/message_center_types.h" | 23 #include "ui/message_center/message_center_types.h" | 
| 24 #include "ui/message_center/views/message_center_button_bar.h" | 24 #include "ui/message_center/views/message_center_button_bar.h" | 
| 25 #include "ui/message_center/views/message_view.h" | 25 #include "ui/message_center/views/message_view.h" | 
| 26 #include "ui/message_center/views/notification_view.h" | 26 #include "ui/message_center/views/notification_view.h" | 
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 409     clearing_all_views_.push_back(child); | 409     clearing_all_views_.push_back(child); | 
| 410   } | 410   } | 
| 411   DoUpdateIfPossible(); | 411   DoUpdateIfPossible(); | 
| 412 } | 412 } | 
| 413 | 413 | 
| 414 void MessageListView::OnBoundsAnimatorProgressed( | 414 void MessageListView::OnBoundsAnimatorProgressed( | 
| 415     views::BoundsAnimator* animator) { | 415     views::BoundsAnimator* animator) { | 
| 416   DCHECK_EQ(animator_.get(), animator); | 416   DCHECK_EQ(animator_.get(), animator); | 
| 417   for (std::set<views::View*>::iterator iter = deleted_when_done_.begin(); | 417   for (std::set<views::View*>::iterator iter = deleted_when_done_.begin(); | 
| 418        iter != deleted_when_done_.end(); ++iter) { | 418        iter != deleted_when_done_.end(); ++iter) { | 
| 419     const ui::SlideAnimation* animation = animator->GetAnimationForView(*iter); | 419     const gfx::SlideAnimation* animation = animator->GetAnimationForView(*iter); | 
| 420     if (animation) | 420     if (animation) | 
| 421       (*iter)->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); | 421       (*iter)->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); | 
| 422   } | 422   } | 
| 423 } | 423 } | 
| 424 | 424 | 
| 425 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 425 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 
| 426   STLDeleteContainerPointers( | 426   STLDeleteContainerPointers( | 
| 427       deleted_when_done_.begin(), deleted_when_done_.end()); | 427       deleted_when_done_.begin(), deleted_when_done_.end()); | 
| 428   deleted_when_done_.clear(); | 428   deleted_when_done_.clear(); | 
| 429 | 429 | 
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 677   if (visible) { | 677   if (visible) { | 
| 678     source_view_ = scroller_; | 678     source_view_ = scroller_; | 
| 679     target_view_ = settings_view_; | 679     target_view_ = settings_view_; | 
| 680   } else { | 680   } else { | 
| 681     source_view_ = settings_view_; | 681     source_view_ = settings_view_; | 
| 682     target_view_ = scroller_; | 682     target_view_ = scroller_; | 
| 683   } | 683   } | 
| 684   source_height_ = source_view_->GetHeightForWidth(width()); | 684   source_height_ = source_view_->GetHeightForWidth(width()); | 
| 685   target_height_ = target_view_->GetHeightForWidth(width()); | 685   target_height_ = target_view_->GetHeightForWidth(width()); | 
| 686 | 686 | 
| 687   ui::MultiAnimation::Parts parts; | 687   gfx::MultiAnimation::Parts parts; | 
| 688   // First part: slide resize animation. | 688   // First part: slide resize animation. | 
| 689   parts.push_back(ui::MultiAnimation::Part( | 689   parts.push_back(gfx::MultiAnimation::Part( | 
| 690       (source_height_ == target_height_) ? 0 : kDefaultAnimationDurationMs, | 690       (source_height_ == target_height_) ? 0 : kDefaultAnimationDurationMs, | 
| 691       ui::Tween::EASE_OUT)); | 691       gfx::Tween::EASE_OUT)); | 
| 692   // Second part: fade-out the source_view. | 692   // Second part: fade-out the source_view. | 
| 693   if (source_view_->layer()) { | 693   if (source_view_->layer()) { | 
| 694     parts.push_back(ui::MultiAnimation::Part( | 694     parts.push_back(gfx::MultiAnimation::Part( | 
| 695         kDefaultAnimationDurationMs, ui::Tween::LINEAR)); | 695         kDefaultAnimationDurationMs, gfx::Tween::LINEAR)); | 
| 696   } else { | 696   } else { | 
| 697     parts.push_back(ui::MultiAnimation::Part()); | 697     parts.push_back(gfx::MultiAnimation::Part()); | 
| 698   } | 698   } | 
| 699   // Third part: fade-in the target_view. | 699   // Third part: fade-in the target_view. | 
| 700   if (target_view_->layer()) { | 700   if (target_view_->layer()) { | 
| 701     parts.push_back(ui::MultiAnimation::Part( | 701     parts.push_back(gfx::MultiAnimation::Part( | 
| 702         kDefaultAnimationDurationMs, ui::Tween::LINEAR)); | 702         kDefaultAnimationDurationMs, gfx::Tween::LINEAR)); | 
| 703     target_view_->layer()->SetOpacity(0); | 703     target_view_->layer()->SetOpacity(0); | 
| 704     target_view_->SetVisible(true); | 704     target_view_->SetVisible(true); | 
| 705   } else { | 705   } else { | 
| 706     parts.push_back(ui::MultiAnimation::Part()); | 706     parts.push_back(gfx::MultiAnimation::Part()); | 
| 707   } | 707   } | 
| 708   settings_transition_animation_.reset(new ui::MultiAnimation( | 708   settings_transition_animation_.reset(new gfx::MultiAnimation( | 
| 709       parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz))); | 709       parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz))); | 
| 710   settings_transition_animation_->set_delegate(this); | 710   settings_transition_animation_->set_delegate(this); | 
| 711   settings_transition_animation_->set_continuous(false); | 711   settings_transition_animation_->set_continuous(false); | 
| 712   settings_transition_animation_->Start(); | 712   settings_transition_animation_->Start(); | 
| 713 | 713 | 
| 714   button_bar_->SetBackArrowVisible(visible); | 714   button_bar_->SetBackArrowVisible(visible); | 
| 715 } | 715 } | 
| 716 | 716 | 
| 717 void MessageCenterView::ClearAllNotifications() { | 717 void MessageCenterView::ClearAllNotifications() { | 
| 718   if (is_closing_) | 718   if (is_closing_) | 
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 925                                            // notification. | 925                                            // notification. | 
| 926       view->set_scroller(scroller_); | 926       view->set_scroller(scroller_); | 
| 927       message_list_view_->UpdateNotificationAt(view, index); | 927       message_list_view_->UpdateNotificationAt(view, index); | 
| 928       message_views_[index] = view; | 928       message_views_[index] = view; | 
| 929       NotificationsChanged(); | 929       NotificationsChanged(); | 
| 930       break; | 930       break; | 
| 931     } | 931     } | 
| 932   } | 932   } | 
| 933 } | 933 } | 
| 934 | 934 | 
| 935 void MessageCenterView::AnimationEnded(const ui::Animation* animation) { | 935 void MessageCenterView::AnimationEnded(const gfx::Animation* animation) { | 
| 936   DCHECK_EQ(animation, settings_transition_animation_.get()); | 936   DCHECK_EQ(animation, settings_transition_animation_.get()); | 
| 937 | 937 | 
| 938   Visibility visibility = target_view_ == settings_view_ | 938   Visibility visibility = target_view_ == settings_view_ | 
| 939                               ? VISIBILITY_SETTINGS | 939                               ? VISIBILITY_SETTINGS | 
| 940                               : VISIBILITY_MESSAGE_CENTER; | 940                               : VISIBILITY_MESSAGE_CENTER; | 
| 941   message_center_->SetVisibility(visibility); | 941   message_center_->SetVisibility(visibility); | 
| 942 | 942 | 
| 943   source_view_->SetVisible(false); | 943   source_view_->SetVisible(false); | 
| 944   target_view_->SetVisible(true); | 944   target_view_->SetVisible(true); | 
| 945   if (source_view_->layer()) | 945   if (source_view_->layer()) | 
| 946     source_view_->layer()->SetOpacity(1.0); | 946     source_view_->layer()->SetOpacity(1.0); | 
| 947   if (target_view_->layer()) | 947   if (target_view_->layer()) | 
| 948     target_view_->layer()->SetOpacity(1.0); | 948     target_view_->layer()->SetOpacity(1.0); | 
| 949   settings_transition_animation_.reset(); | 949   settings_transition_animation_.reset(); | 
| 950   PreferredSizeChanged(); | 950   PreferredSizeChanged(); | 
| 951   Layout(); | 951   Layout(); | 
| 952 } | 952 } | 
| 953 | 953 | 
| 954 void MessageCenterView::AnimationProgressed(const ui::Animation* animation) { | 954 void MessageCenterView::AnimationProgressed(const gfx::Animation* animation) { | 
| 955   DCHECK_EQ(animation, settings_transition_animation_.get()); | 955   DCHECK_EQ(animation, settings_transition_animation_.get()); | 
| 956   PreferredSizeChanged(); | 956   PreferredSizeChanged(); | 
| 957   if (settings_transition_animation_->current_part_index() == 1 && | 957   if (settings_transition_animation_->current_part_index() == 1 && | 
| 958       source_view_->layer()) { | 958       source_view_->layer()) { | 
| 959     source_view_->layer()->SetOpacity( | 959     source_view_->layer()->SetOpacity( | 
| 960         1.0 - settings_transition_animation_->GetCurrentValue()); | 960         1.0 - settings_transition_animation_->GetCurrentValue()); | 
| 961     SchedulePaint(); | 961     SchedulePaint(); | 
| 962   } else if (settings_transition_animation_->current_part_index() == 2 && | 962   } else if (settings_transition_animation_->current_part_index() == 2 && | 
| 963              target_view_->layer()) { | 963              target_view_->layer()) { | 
| 964     target_view_->layer()->SetOpacity( | 964     target_view_->layer()->SetOpacity( | 
| 965         settings_transition_animation_->GetCurrentValue()); | 965         settings_transition_animation_->GetCurrentValue()); | 
| 966     SchedulePaint(); | 966     SchedulePaint(); | 
| 967   } | 967   } | 
| 968 } | 968 } | 
| 969 | 969 | 
| 970 void MessageCenterView::AnimationCanceled(const ui::Animation* animation) { | 970 void MessageCenterView::AnimationCanceled(const gfx::Animation* animation) { | 
| 971   DCHECK_EQ(animation, settings_transition_animation_.get()); | 971   DCHECK_EQ(animation, settings_transition_animation_.get()); | 
| 972   AnimationEnded(animation); | 972   AnimationEnded(animation); | 
| 973 } | 973 } | 
| 974 | 974 | 
| 975 void MessageCenterView::AddNotificationAt(const Notification& notification, | 975 void MessageCenterView::AddNotificationAt(const Notification& notification, | 
| 976                                           int index) { | 976                                           int index) { | 
| 977   // NotificationViews are expanded by default here until | 977   // NotificationViews are expanded by default here until | 
| 978   // http://crbug.com/217902 is fixed. TODO(dharcourt): Fix. | 978   // http://crbug.com/217902 is fixed. TODO(dharcourt): Fix. | 
| 979   MessageView* view = | 979   MessageView* view = | 
| 980       NotificationView::Create(notification, | 980       NotificationView::Create(notification, | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 999   scroller_->InvalidateLayout(); | 999   scroller_->InvalidateLayout(); | 
| 1000   PreferredSizeChanged(); | 1000   PreferredSizeChanged(); | 
| 1001   Layout(); | 1001   Layout(); | 
| 1002 } | 1002 } | 
| 1003 | 1003 | 
| 1004 void MessageCenterView::SetNotificationViewForTest(views::View* view) { | 1004 void MessageCenterView::SetNotificationViewForTest(views::View* view) { | 
| 1005   message_list_view_->AddNotificationAt(view, 0); | 1005   message_list_view_->AddNotificationAt(view, 0); | 
| 1006 } | 1006 } | 
| 1007 | 1007 | 
| 1008 }  // namespace message_center | 1008 }  // namespace message_center | 
| OLD | NEW | 
|---|