Chromium Code Reviews| Index: athena/home/home_card_impl.cc |
| diff --git a/athena/home/home_card_impl.cc b/athena/home/home_card_impl.cc |
| index 9c993f2c413a80fe3a3dc3d3450a5ce932381b02..99e2169e8412b7bc678ef23d8e55a9cf5c8f7376 100644 |
| --- a/athena/home/home_card_impl.cc |
| +++ b/athena/home/home_card_impl.cc |
| @@ -22,6 +22,8 @@ |
| #include "ui/app_list/views/contents_view.h" |
| #include "ui/aura/layout_manager.h" |
| #include "ui/aura/window.h" |
| +#include "ui/compositor/layer_animation_observer.h" |
| +#include "ui/compositor/scoped_layer_animation_settings.h" |
| #include "ui/views/background.h" |
| #include "ui/views/layout/box_layout.h" |
| #include "ui/views/widget/widget.h" |
| @@ -88,8 +90,13 @@ class HomeCardLayoutManager : public aura::LayoutManager { |
| if (!home_card || !home_card->GetRootWindow()) |
| return; |
| - SetChildBoundsDirect(home_card, GetBoundsForState( |
| - home_card->GetRootWindow()->bounds(), delegate_->GetState())); |
| + { |
| + ui::ScopedLayerAnimationSettings settings( |
| + home_card->layer()->GetAnimator()); |
| + settings.SetTweenType(gfx::Tween::EASE_IN_OUT); |
| + SetChildBoundsDirect(home_card, GetBoundsForState( |
| + home_card->GetRootWindow()->bounds(), delegate_->GetState())); |
| + } |
| } |
| private: |
| @@ -323,6 +330,29 @@ class HomeCardView : public views::WidgetDelegateView { |
| wm::SHADOW_TYPE_RECTANGULAR); |
| } |
| + void SetStateWithAnimation(HomeCard::State from_state, |
| + HomeCard::State to_state) { |
| + if ((from_state == HomeCard::VISIBLE_MINIMIZED && |
| + to_state == HomeCard::VISIBLE_BOTTOM) || |
| + (from_state == HomeCard::VISIBLE_BOTTOM && |
| + to_state == HomeCard::VISIBLE_MINIMIZED)) { |
| + minimized_view_->SetVisible(true); |
| + bottom_view_->SetVisible(true); |
| + { |
| + ui::ScopedLayerAnimationSettings settings( |
| + minimized_view_->layer()->GetAnimator()); |
| + settings.SetTweenType(gfx::Tween::EASE_IN_OUT); |
| + settings.SetTransitionDuration(base::TimeDelta::FromSeconds(5)); |
|
sadrul
2014/08/15 15:36:21
That's ... pretty long! Was for debugging, perhaps
Jun Mukai
2014/08/15 16:35:07
Ugh, removed. That is for debugging. Thanks for ca
|
| + settings.AddObserver(new AnimationObserver(this, to_state)); |
| + minimized_view_->layer()->SetOpacity( |
| + (to_state == HomeCard::VISIBLE_MINIMIZED) ? 1.0f : 0.0f); |
|
sadrul
2014/08/15 15:36:21
Do you need to set the opacity to 0/1 beforehand t
Jun Mukai
2014/08/15 16:35:08
Not sure what you mean, but if you meant the patte
sadrul
2014/08/15 16:37:26
Sounds good.
|
| + } |
| + } else { |
| + // TODO(mukai): Take care of other transition. |
| + SetState(to_state); |
| + } |
| + } |
| + |
| void ClearGesture() { |
| gesture_manager_.reset(); |
| } |
| @@ -356,6 +386,26 @@ class HomeCardView : public views::WidgetDelegateView { |
| } |
| private: |
| + class AnimationObserver : public ui::ImplicitAnimationObserver { |
|
sadrul
2014/08/15 15:36:22
You should use ui::ClosureAnimationObserver!
Jun Mukai
2014/08/15 16:35:08
Done!
|
| + public: |
| + AnimationObserver(HomeCardView* view, HomeCard::State target_state) |
| + : view_(view), |
| + target_state_(target_state) {} |
| + virtual ~AnimationObserver() {} |
| + |
| + private: |
| + // ui::ImplicitAnimationObserver: |
| + virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
| + view_->SetState(target_state_); |
| + delete this; |
| + } |
| + |
| + HomeCardView* view_; |
| + HomeCard::State target_state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AnimationObserver); |
| + }; |
| + |
| virtual views::View* GetContentsView() OVERRIDE { |
| return this; |
| } |
| @@ -506,6 +556,7 @@ void HomeCardImpl::SetState(HomeCard::State state) { |
| // Update |state_| before changing the visibility of the widgets, so that |
| // LayoutManager callbacks get the correct state. |
| + HomeCard::State old_state = state_; |
| state_ = state; |
| original_state_ = state; |
| if (state_ == HIDDEN) { |
| @@ -515,7 +566,7 @@ void HomeCardImpl::SetState(HomeCard::State state) { |
| home_card_widget_->Show(); |
| else |
| home_card_widget_->ShowInactive(); |
| - home_card_view_->SetState(state); |
| + home_card_view_->SetStateWithAnimation(old_state, state); |
| layout_manager_->Layout(); |
| } |
| } |
| @@ -568,8 +619,9 @@ void HomeCardImpl::OnGestureEnded(State final_state) { |
| (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { |
| WindowManager::GetInstance()->ToggleOverview(); |
| } else { |
| + HomeCard::State old_state = state_; |
| state_ = final_state; |
| - home_card_view_->SetState(final_state); |
| + home_card_view_->SetStateWithAnimation(old_state, final_state); |
| layout_manager_->Layout(); |
| } |
| } |