OLD | NEW |
---|---|
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/auto_reset.h" | |
19 #include "base/bind.h" | 20 #include "base/bind.h" |
20 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
21 #include "ui/app_list/search_provider.h" | 22 #include "ui/app_list/search_provider.h" |
22 #include "ui/app_list/views/app_list_main_view.h" | 23 #include "ui/app_list/views/app_list_main_view.h" |
23 #include "ui/app_list/views/contents_view.h" | 24 #include "ui/app_list/views/contents_view.h" |
24 #include "ui/aura/layout_manager.h" | 25 #include "ui/aura/layout_manager.h" |
25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
26 #include "ui/compositor/closure_animation_observer.h" | 27 #include "ui/compositor/closure_animation_observer.h" |
27 #include "ui/compositor/scoped_layer_animation_settings.h" | 28 #include "ui/compositor/scoped_layer_animation_settings.h" |
28 #include "ui/views/background.h" | 29 #include "ui/views/background.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 aura::Window* lost_active) OVERRIDE; | 446 aura::Window* lost_active) OVERRIDE; |
446 | 447 |
447 scoped_ptr<AppModelBuilder> model_builder_; | 448 scoped_ptr<AppModelBuilder> model_builder_; |
448 | 449 |
449 HomeCard::State state_; | 450 HomeCard::State state_; |
450 | 451 |
451 // original_state_ is the state which the home card should go back to after | 452 // original_state_ is the state which the home card should go back to after |
452 // the virtual keyboard is hidden. | 453 // the virtual keyboard is hidden. |
453 HomeCard::State original_state_; | 454 HomeCard::State original_state_; |
454 | 455 |
456 // The state to be entered when the overview mode is turned on. | |
457 HomeCard::State overview_mode_state_; | |
458 | |
455 views::Widget* home_card_widget_; | 459 views::Widget* home_card_widget_; |
456 HomeCardView* home_card_view_; | 460 HomeCardView* home_card_view_; |
457 scoped_ptr<AppListViewDelegate> view_delegate_; | 461 scoped_ptr<AppListViewDelegate> view_delegate_; |
458 HomeCardLayoutManager* layout_manager_; | 462 HomeCardLayoutManager* layout_manager_; |
459 aura::client::ActivationClient* activation_client_; // Not owned | 463 aura::client::ActivationClient* activation_client_; // Not owned |
460 | 464 |
461 // Right now HomeCard allows only one search provider. | 465 // Right now HomeCard allows only one search provider. |
462 // TODO(mukai): port app-list's SearchController and Mixer. | 466 // TODO(mukai): port app-list's SearchController and Mixer. |
463 scoped_ptr<app_list::SearchProvider> search_provider_; | 467 scoped_ptr<app_list::SearchProvider> search_provider_; |
464 | 468 |
465 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); | 469 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); |
466 }; | 470 }; |
467 | 471 |
468 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) | 472 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) |
469 : model_builder_(model_builder), | 473 : model_builder_(model_builder), |
470 state_(HIDDEN), | 474 state_(HIDDEN), |
471 original_state_(VISIBLE_MINIMIZED), | 475 original_state_(VISIBLE_MINIMIZED), |
476 overview_mode_state_(VISIBLE_BOTTOM), | |
472 home_card_widget_(NULL), | 477 home_card_widget_(NULL), |
473 home_card_view_(NULL), | 478 home_card_view_(NULL), |
474 layout_manager_(NULL), | 479 layout_manager_(NULL), |
475 activation_client_(NULL) { | 480 activation_client_(NULL) { |
476 DCHECK(!instance); | 481 DCHECK(!instance); |
477 instance = this; | 482 instance = this; |
478 WindowManager::GetInstance()->AddObserver(this); | 483 WindowManager::GetInstance()->AddObserver(this); |
479 } | 484 } |
480 | 485 |
481 HomeCardImpl::~HomeCardImpl() { | 486 HomeCardImpl::~HomeCardImpl() { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 | 602 |
598 aura::Window* HomeCardImpl::GetNativeWindow() { | 603 aura::Window* HomeCardImpl::GetNativeWindow() { |
599 if (state_ == HIDDEN) | 604 if (state_ == HIDDEN) |
600 return NULL; | 605 return NULL; |
601 | 606 |
602 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; | 607 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; |
603 } | 608 } |
604 | 609 |
605 void HomeCardImpl::OnGestureEnded(State final_state) { | 610 void HomeCardImpl::OnGestureEnded(State final_state) { |
606 home_card_view_->ClearGesture(); | 611 home_card_view_->ClearGesture(); |
607 if (state_ != final_state && | 612 if (state_ != final_state && |
oshima
2014/08/25 20:47:10
can exit early if skip if state_ == final_state?
Jun Mukai
2014/08/25 21:09:05
That will cause a test failure. Also, the home car
oshima
2014/08/25 21:20:25
Acknowledged.
| |
608 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { | 613 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { |
614 base::AutoReset<HomeCard::State> overview_mode( | |
615 &overview_mode_state_, final_state); | |
609 WindowManager::GetInstance()->ToggleOverview(); | 616 WindowManager::GetInstance()->ToggleOverview(); |
610 } else { | 617 } else { |
611 HomeCard::State old_state = state_; | 618 HomeCard::State old_state = state_; |
612 state_ = final_state; | 619 state_ = final_state; |
613 home_card_view_->SetStateWithAnimation(old_state, final_state); | 620 home_card_view_->SetStateWithAnimation(old_state, final_state); |
614 layout_manager_->Layout(); | 621 layout_manager_->Layout(); |
615 } | 622 } |
616 } | 623 } |
617 | 624 |
618 void HomeCardImpl::OnGestureProgressed( | 625 void HomeCardImpl::OnGestureProgressed( |
619 State from_state, State to_state, float progress) { | 626 State from_state, State to_state, float progress) { |
620 home_card_view_->SetStateProgress(from_state, to_state, progress); | 627 home_card_view_->SetStateProgress(from_state, to_state, progress); |
621 | 628 |
622 gfx::Rect screen_bounds = | 629 gfx::Rect screen_bounds = |
623 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds(); | 630 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds(); |
624 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween( | 631 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween( |
625 progress, | 632 progress, |
626 GetBoundsForState(screen_bounds, from_state), | 633 GetBoundsForState(screen_bounds, from_state), |
627 GetBoundsForState(screen_bounds, to_state))); | 634 GetBoundsForState(screen_bounds, to_state))); |
628 | 635 |
629 // TODO(mukai): signals the update to the window manager so that it shows the | 636 // TODO(mukai): signals the update to the window manager so that it shows the |
630 // intermediate visual state of overview mode. | 637 // intermediate visual state of overview mode. |
631 } | 638 } |
632 | 639 |
633 void HomeCardImpl::OnOverviewModeEnter() { | 640 void HomeCardImpl::OnOverviewModeEnter() { |
634 SetState(VISIBLE_BOTTOM); | 641 SetState(overview_mode_state_); |
635 } | 642 } |
636 | 643 |
637 void HomeCardImpl::OnOverviewModeExit() { | 644 void HomeCardImpl::OnOverviewModeExit() { |
638 SetState(VISIBLE_MINIMIZED); | 645 SetState(VISIBLE_MINIMIZED); |
639 } | 646 } |
640 | 647 |
641 void HomeCardImpl::OnWindowActivated(aura::Window* gained_active, | 648 void HomeCardImpl::OnWindowActivated(aura::Window* gained_active, |
642 aura::Window* lost_active) { | 649 aura::Window* lost_active) { |
643 if (state_ != HIDDEN && | 650 if (state_ != HIDDEN && |
644 gained_active != home_card_widget_->GetNativeWindow()) { | 651 gained_active != home_card_widget_->GetNativeWindow()) { |
(...skipping 17 matching lines...) Expand all Loading... | |
662 instance = NULL; | 669 instance = NULL; |
663 } | 670 } |
664 | 671 |
665 // static | 672 // static |
666 HomeCard* HomeCard::Get() { | 673 HomeCard* HomeCard::Get() { |
667 DCHECK(instance); | 674 DCHECK(instance); |
668 return instance; | 675 return instance; |
669 } | 676 } |
670 | 677 |
671 } // namespace athena | 678 } // namespace athena |
OLD | NEW |