Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: athena/home/home_card_impl.cc

Issue 473113002: Introduce the basic animation from minimized to bottom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « athena/home/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/home/public/home_card.h" 5 #include "athena/home/public/home_card.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "athena/common/container_priorities.h" 10 #include "athena/common/container_priorities.h"
11 #include "athena/home/app_list_view_delegate.h" 11 #include "athena/home/app_list_view_delegate.h"
12 #include "athena/home/athena_start_page_view.h" 12 #include "athena/home/athena_start_page_view.h"
13 #include "athena/home/minimized_home.h" 13 #include "athena/home/minimized_home.h"
14 #include "athena/home/public/app_model_builder.h" 14 #include "athena/home/public/app_model_builder.h"
15 #include "athena/input/public/accelerator_manager.h" 15 #include "athena/input/public/accelerator_manager.h"
16 #include "athena/screen/public/screen_manager.h" 16 #include "athena/screen/public/screen_manager.h"
17 #include "athena/wm/public/window_manager.h" 17 #include "athena/wm/public/window_manager.h"
18 #include "athena/wm/public/window_manager_observer.h" 18 #include "athena/wm/public/window_manager_observer.h"
19 #include "base/bind.h" 19 #include "base/bind.h"
20 #include "ui/app_list/search_provider.h" 20 #include "ui/app_list/search_provider.h"
21 #include "ui/app_list/views/app_list_main_view.h" 21 #include "ui/app_list/views/app_list_main_view.h"
22 #include "ui/app_list/views/contents_view.h" 22 #include "ui/app_list/views/contents_view.h"
23 #include "ui/aura/layout_manager.h" 23 #include "ui/aura/layout_manager.h"
24 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
25 #include "ui/compositor/layer_animation_observer.h"
26 #include "ui/compositor/scoped_layer_animation_settings.h"
25 #include "ui/views/background.h" 27 #include "ui/views/background.h"
26 #include "ui/views/layout/box_layout.h" 28 #include "ui/views/layout/box_layout.h"
27 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
28 #include "ui/views/widget/widget_delegate.h" 30 #include "ui/views/widget/widget_delegate.h"
29 #include "ui/wm/core/shadow_types.h" 31 #include "ui/wm/core/shadow_types.h"
30 #include "ui/wm/core/visibility_controller.h" 32 #include "ui/wm/core/visibility_controller.h"
31 #include "ui/wm/core/window_animations.h" 33 #include "ui/wm/core/window_animations.h"
32 #include "ui/wm/public/activation_change_observer.h" 34 #include "ui/wm/public/activation_change_observer.h"
33 #include "ui/wm/public/activation_client.h" 35 #include "ui/wm/public/activation_client.h"
34 36
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 83
82 virtual ~HomeCardLayoutManager() {} 84 virtual ~HomeCardLayoutManager() {}
83 85
84 void Layout() { 86 void Layout() {
85 aura::Window* home_card = delegate_->GetNativeWindow(); 87 aura::Window* home_card = delegate_->GetNativeWindow();
86 // |home_card| could be detached from the root window (e.g. when it is being 88 // |home_card| could be detached from the root window (e.g. when it is being
87 // destroyed). 89 // destroyed).
88 if (!home_card || !home_card->GetRootWindow()) 90 if (!home_card || !home_card->GetRootWindow())
89 return; 91 return;
90 92
91 SetChildBoundsDirect(home_card, GetBoundsForState( 93 {
92 home_card->GetRootWindow()->bounds(), delegate_->GetState())); 94 ui::ScopedLayerAnimationSettings settings(
95 home_card->layer()->GetAnimator());
96 settings.SetTweenType(gfx::Tween::EASE_IN_OUT);
97 SetChildBoundsDirect(home_card, GetBoundsForState(
98 home_card->GetRootWindow()->bounds(), delegate_->GetState()));
99 }
93 } 100 }
94 101
95 private: 102 private:
96 // aura::LayoutManager: 103 // aura::LayoutManager:
97 virtual void OnWindowResized() OVERRIDE { Layout(); } 104 virtual void OnWindowResized() OVERRIDE { Layout(); }
98 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { Layout(); } 105 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { Layout(); }
99 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} 106 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
100 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE { 107 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {
101 Layout(); 108 Layout();
102 } 109 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 app_list::ContentsView* contents_view = main_view_->contents_view(); 323 app_list::ContentsView* contents_view = main_view_->contents_view();
317 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage( 324 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage(
318 app_list::ContentsView::NAMED_PAGE_START)); 325 app_list::ContentsView::NAMED_PAGE_START));
319 } 326 }
320 wm::SetShadowType(GetWidget()->GetNativeView(), 327 wm::SetShadowType(GetWidget()->GetNativeView(),
321 state == HomeCard::VISIBLE_MINIMIZED ? 328 state == HomeCard::VISIBLE_MINIMIZED ?
322 wm::SHADOW_TYPE_NONE : 329 wm::SHADOW_TYPE_NONE :
323 wm::SHADOW_TYPE_RECTANGULAR); 330 wm::SHADOW_TYPE_RECTANGULAR);
324 } 331 }
325 332
333 void SetStateWithAnimation(HomeCard::State from_state,
334 HomeCard::State to_state) {
335 if ((from_state == HomeCard::VISIBLE_MINIMIZED &&
336 to_state == HomeCard::VISIBLE_BOTTOM) ||
337 (from_state == HomeCard::VISIBLE_BOTTOM &&
338 to_state == HomeCard::VISIBLE_MINIMIZED)) {
339 minimized_view_->SetVisible(true);
340 bottom_view_->SetVisible(true);
341 {
342 ui::ScopedLayerAnimationSettings settings(
343 minimized_view_->layer()->GetAnimator());
344 settings.SetTweenType(gfx::Tween::EASE_IN_OUT);
345 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
346 settings.AddObserver(new AnimationObserver(this, to_state));
347 minimized_view_->layer()->SetOpacity(
348 (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.
349 }
350 } else {
351 // TODO(mukai): Take care of other transition.
352 SetState(to_state);
353 }
354 }
355
326 void ClearGesture() { 356 void ClearGesture() {
327 gesture_manager_.reset(); 357 gesture_manager_.reset();
328 } 358 }
329 359
330 // views::View: 360 // views::View:
331 virtual void Layout() OVERRIDE { 361 virtual void Layout() OVERRIDE {
332 for (int i = 0; i < child_count(); ++i) { 362 for (int i = 0; i < child_count(); ++i) {
333 views::View* child = child_at(i); 363 views::View* child = child_at(i);
334 if (child->visible()) { 364 if (child->visible()) {
335 if (child == minimized_view_) { 365 if (child == minimized_view_) {
(...skipping 13 matching lines...) Expand all
349 gesture_manager_.reset(new HomeCardGestureManager( 379 gesture_manager_.reset(new HomeCardGestureManager(
350 gesture_delegate_, 380 gesture_delegate_,
351 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); 381 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds()));
352 } 382 }
353 383
354 if (gesture_manager_) 384 if (gesture_manager_)
355 gesture_manager_->ProcessGestureEvent(event); 385 gesture_manager_->ProcessGestureEvent(event);
356 } 386 }
357 387
358 private: 388 private:
389 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!
390 public:
391 AnimationObserver(HomeCardView* view, HomeCard::State target_state)
392 : view_(view),
393 target_state_(target_state) {}
394 virtual ~AnimationObserver() {}
395
396 private:
397 // ui::ImplicitAnimationObserver:
398 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
399 view_->SetState(target_state_);
400 delete this;
401 }
402
403 HomeCardView* view_;
404 HomeCard::State target_state_;
405
406 DISALLOW_COPY_AND_ASSIGN(AnimationObserver);
407 };
408
359 virtual views::View* GetContentsView() OVERRIDE { 409 virtual views::View* GetContentsView() OVERRIDE {
360 return this; 410 return this;
361 } 411 }
362 412
363 app_list::AppListMainView* main_view_; 413 app_list::AppListMainView* main_view_;
364 views::View* bottom_view_; 414 views::View* bottom_view_;
365 views::View* minimized_view_; 415 views::View* minimized_view_;
366 scoped_ptr<HomeCardGestureManager> gesture_manager_; 416 scoped_ptr<HomeCardGestureManager> gesture_manager_;
367 HomeCardGestureManager::Delegate* gesture_delegate_; 417 HomeCardGestureManager::Delegate* gesture_delegate_;
368 418
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 AcceleratorManager::Get()->RegisterAccelerators( 549 AcceleratorManager::Get()->RegisterAccelerators(
500 accelerator_data, arraysize(accelerator_data), this); 550 accelerator_data, arraysize(accelerator_data), this);
501 } 551 }
502 552
503 void HomeCardImpl::SetState(HomeCard::State state) { 553 void HomeCardImpl::SetState(HomeCard::State state) {
504 if (state_ == state) 554 if (state_ == state)
505 return; 555 return;
506 556
507 // Update |state_| before changing the visibility of the widgets, so that 557 // Update |state_| before changing the visibility of the widgets, so that
508 // LayoutManager callbacks get the correct state. 558 // LayoutManager callbacks get the correct state.
559 HomeCard::State old_state = state_;
509 state_ = state; 560 state_ = state;
510 original_state_ = state; 561 original_state_ = state;
511 if (state_ == HIDDEN) { 562 if (state_ == HIDDEN) {
512 home_card_widget_->Hide(); 563 home_card_widget_->Hide();
513 } else { 564 } else {
514 if (state_ == VISIBLE_CENTERED) 565 if (state_ == VISIBLE_CENTERED)
515 home_card_widget_->Show(); 566 home_card_widget_->Show();
516 else 567 else
517 home_card_widget_->ShowInactive(); 568 home_card_widget_->ShowInactive();
518 home_card_view_->SetState(state); 569 home_card_view_->SetStateWithAnimation(old_state, state);
519 layout_manager_->Layout(); 570 layout_manager_->Layout();
520 } 571 }
521 } 572 }
522 573
523 HomeCard::State HomeCardImpl::GetState() { 574 HomeCard::State HomeCardImpl::GetState() {
524 return state_; 575 return state_;
525 } 576 }
526 577
527 void HomeCardImpl::RegisterSearchProvider( 578 void HomeCardImpl::RegisterSearchProvider(
528 app_list::SearchProvider* search_provider) { 579 app_list::SearchProvider* search_provider) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 612
562 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; 613 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL;
563 } 614 }
564 615
565 void HomeCardImpl::OnGestureEnded(State final_state) { 616 void HomeCardImpl::OnGestureEnded(State final_state) {
566 home_card_view_->ClearGesture(); 617 home_card_view_->ClearGesture();
567 if (state_ != final_state && 618 if (state_ != final_state &&
568 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { 619 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) {
569 WindowManager::GetInstance()->ToggleOverview(); 620 WindowManager::GetInstance()->ToggleOverview();
570 } else { 621 } else {
622 HomeCard::State old_state = state_;
571 state_ = final_state; 623 state_ = final_state;
572 home_card_view_->SetState(final_state); 624 home_card_view_->SetStateWithAnimation(old_state, final_state);
573 layout_manager_->Layout(); 625 layout_manager_->Layout();
574 } 626 }
575 } 627 }
576 628
577 void HomeCardImpl::OnGestureProgressed( 629 void HomeCardImpl::OnGestureProgressed(
578 State from_state, State to_state, float progress) { 630 State from_state, State to_state, float progress) {
579 home_card_view_->SetStateProgress(from_state, to_state, progress); 631 home_card_view_->SetStateProgress(from_state, to_state, progress);
580 632
581 gfx::Rect screen_bounds = 633 gfx::Rect screen_bounds =
582 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds(); 634 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 instance = NULL; 673 instance = NULL;
622 } 674 }
623 675
624 // static 676 // static
625 HomeCard* HomeCard::Get() { 677 HomeCard* HomeCard::Get() {
626 DCHECK(instance); 678 DCHECK(instance);
627 return instance; 679 return instance;
628 } 680 }
629 681
630 } // namespace athena 682 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698