Chromium Code Reviews| 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/bottom_home_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/views/background.h" | 25 #include "ui/views/background.h" |
| 26 #include "ui/views/layout/box_layout.h" | 26 #include "ui/views/layout/box_layout.h" |
| 27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 28 #include "ui/views/widget/widget_delegate.h" | 28 #include "ui/views/widget/widget_delegate.h" |
| 29 #include "ui/wm/core/shadow_types.h" | 29 #include "ui/wm/core/shadow_types.h" |
| 30 #include "ui/wm/core/visibility_controller.h" | 30 #include "ui/wm/core/visibility_controller.h" |
| 31 #include "ui/wm/core/window_animations.h" | 31 #include "ui/wm/core/window_animations.h" |
| 32 #include "ui/wm/public/activation_change_observer.h" | 32 #include "ui/wm/public/activation_change_observer.h" |
| 33 #include "ui/wm/public/activation_client.h" | 33 #include "ui/wm/public/activation_client.h" |
| 34 | 34 |
| 35 namespace athena { | 35 namespace athena { |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 HomeCard* instance = NULL; | 38 HomeCard* instance = NULL; |
| 39 const int kHomeCardMinimizedHeight = 8; | |
| 39 | 40 |
| 40 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds, | 41 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds, |
| 41 HomeCard::State state) { | 42 HomeCard::State state) { |
| 42 const int kHomeCardHeight = 150; | 43 const int kHomeCardHeight = 100; |
| 43 const int kHomeCardMinimizedHeight = 8; | 44 const int kHomeCardMinimizedHeight = 8; |
|
sadrul
2014/08/13 22:01:13
Did you mean to remove this?
The small text in th
Jun Mukai
2014/08/13 23:18:23
thanks, removed. Also changed the height to 6px. L
| |
| 44 | 45 |
| 45 switch (state) { | 46 switch (state) { |
| 46 case HomeCard::HIDDEN: | 47 case HomeCard::HIDDEN: |
| 47 break; | 48 break; |
| 48 | 49 |
| 49 case HomeCard::VISIBLE_CENTERED: | 50 case HomeCard::VISIBLE_CENTERED: |
| 50 return screen_bounds; | 51 return screen_bounds; |
| 51 | 52 |
| 52 case HomeCard::VISIBLE_BOTTOM: | 53 case HomeCard::VISIBLE_BOTTOM: |
| 53 return gfx::Rect(0, | 54 return gfx::Rect(0, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 DISALLOW_COPY_AND_ASSIGN(HomeCardGestureManager); | 263 DISALLOW_COPY_AND_ASSIGN(HomeCardGestureManager); |
| 263 }; | 264 }; |
| 264 | 265 |
| 265 // The container view of home card contents of each state. | 266 // The container view of home card contents of each state. |
| 266 class HomeCardView : public views::WidgetDelegateView { | 267 class HomeCardView : public views::WidgetDelegateView { |
| 267 public: | 268 public: |
| 268 HomeCardView(app_list::AppListViewDelegate* view_delegate, | 269 HomeCardView(app_list::AppListViewDelegate* view_delegate, |
| 269 aura::Window* container, | 270 aura::Window* container, |
| 270 HomeCardGestureManager::Delegate* gesture_delegate) | 271 HomeCardGestureManager::Delegate* gesture_delegate) |
| 271 : gesture_delegate_(gesture_delegate) { | 272 : gesture_delegate_(gesture_delegate) { |
| 272 bottom_view_ = new BottomHomeView(view_delegate); | 273 bottom_view_ = new AthenaStartPageView(view_delegate); |
| 273 AddChildView(bottom_view_); | 274 AddChildView(bottom_view_); |
| 275 bottom_view_->SetPaintToLayer(true); | |
| 274 | 276 |
| 275 main_view_ = new app_list::AppListMainView( | 277 main_view_ = new app_list::AppListMainView( |
| 276 view_delegate, 0 /* initial_apps_page */, container); | 278 view_delegate, 0 /* initial_apps_page */, container); |
| 277 AddChildView(main_view_); | 279 AddChildView(main_view_); |
| 278 main_view_->set_background( | 280 main_view_->set_background( |
| 279 views::Background::CreateSolidBackground(SK_ColorWHITE)); | 281 views::Background::CreateSolidBackground(SK_ColorWHITE)); |
| 282 main_view_->SetPaintToLayer(true); | |
| 280 | 283 |
| 281 minimized_view_ = CreateMinimizedHome(); | 284 minimized_view_ = CreateMinimizedHome(); |
| 285 minimized_view_->SetPaintToLayer(true); | |
|
sadrul
2014/08/13 22:01:13
I agree with the comment in the CL description: th
Jun Mukai
2014/08/13 23:18:23
Thanks. I think we should keep minimized_view_ as
| |
| 282 AddChildView(minimized_view_); | 286 AddChildView(minimized_view_); |
| 283 } | 287 } |
| 284 | 288 |
| 289 void SetStateProgress(HomeCard::State from_state, | |
| 290 HomeCard::State to_state, | |
| 291 float progress) { | |
| 292 if (from_state == HomeCard::VISIBLE_BOTTOM && | |
| 293 to_state == HomeCard::VISIBLE_MINIMIZED) { | |
| 294 SetStateProgress(to_state, from_state, 1.0 - progress); | |
| 295 return; | |
| 296 } | |
| 297 | |
| 298 // View from minimized to bottom. | |
| 299 if (from_state == HomeCard::VISIBLE_MINIMIZED && | |
| 300 to_state == HomeCard::VISIBLE_BOTTOM) { | |
| 301 bottom_view_->SetVisible(true); | |
| 302 minimized_view_->SetVisible(true); | |
| 303 minimized_view_->layer()->SetOpacity(1.0f - progress); | |
|
sadrul
2014/08/13 22:01:13
When transitioning MINIMIZED ==> BOTTOM, with prog
Jun Mukai
2014/08/13 23:18:23
The progress means how far from |from_state_|, so
| |
| 304 return; | |
| 305 } | |
| 306 | |
| 307 SetState(to_state); | |
| 308 } | |
| 309 | |
| 285 void SetState(HomeCard::State state) { | 310 void SetState(HomeCard::State state) { |
| 286 bottom_view_->SetVisible(state == HomeCard::VISIBLE_BOTTOM); | 311 bottom_view_->SetVisible(state == HomeCard::VISIBLE_BOTTOM); |
| 287 main_view_->SetVisible(state == HomeCard::VISIBLE_CENTERED); | 312 main_view_->SetVisible(state == HomeCard::VISIBLE_CENTERED); |
| 288 minimized_view_->SetVisible(state == HomeCard::VISIBLE_MINIMIZED); | 313 minimized_view_->SetVisible(state == HomeCard::VISIBLE_MINIMIZED); |
| 314 if (minimized_view_->visible()) | |
| 315 minimized_view_->layer()->SetOpacity(1.0f); | |
| 289 if (state == HomeCard::VISIBLE_CENTERED) { | 316 if (state == HomeCard::VISIBLE_CENTERED) { |
| 290 app_list::ContentsView* contents_view = main_view_->contents_view(); | 317 app_list::ContentsView* contents_view = main_view_->contents_view(); |
| 291 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage( | 318 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage( |
| 292 app_list::ContentsView::NAMED_PAGE_START)); | 319 app_list::ContentsView::NAMED_PAGE_START)); |
| 293 } | 320 } |
| 294 wm::SetShadowType(GetWidget()->GetNativeView(), | 321 wm::SetShadowType(GetWidget()->GetNativeView(), |
| 295 state == HomeCard::VISIBLE_MINIMIZED ? | 322 state == HomeCard::VISIBLE_MINIMIZED ? |
| 296 wm::SHADOW_TYPE_NONE : | 323 wm::SHADOW_TYPE_NONE : |
| 297 wm::SHADOW_TYPE_RECTANGULAR); | 324 wm::SHADOW_TYPE_RECTANGULAR); |
| 298 } | 325 } |
| 299 | 326 |
| 300 void ClearGesture() { | 327 void ClearGesture() { |
| 301 gesture_manager_.reset(); | 328 gesture_manager_.reset(); |
| 302 } | 329 } |
| 303 | 330 |
| 304 // views::View: | 331 // views::View: |
| 305 virtual void Layout() OVERRIDE { | 332 virtual void Layout() OVERRIDE { |
| 306 for (int i = 0; i < child_count(); ++i) { | 333 for (int i = 0; i < child_count(); ++i) { |
| 307 views::View* child = child_at(i); | 334 views::View* child = child_at(i); |
| 308 if (child->visible()) { | 335 if (child->visible()) { |
| 309 child->SetBoundsRect(bounds()); | 336 if (child == minimized_view_) { |
| 310 return; | 337 gfx::Rect minimized_bounds = bounds(); |
| 338 minimized_bounds.set_y( | |
| 339 minimized_bounds.bottom() - kHomeCardMinimizedHeight); | |
| 340 child->SetBoundsRect(minimized_bounds); | |
| 341 } else { | |
| 342 child->SetBoundsRect(bounds()); | |
| 343 } | |
| 311 } | 344 } |
| 312 } | 345 } |
| 313 | |
| 314 // One of the child views has to be visible. | |
| 315 NOTREACHED(); | |
| 316 } | 346 } |
| 317 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 347 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
| 318 if (!gesture_manager_ && | 348 if (!gesture_manager_ && |
| 319 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 349 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 320 gesture_manager_.reset(new HomeCardGestureManager( | 350 gesture_manager_.reset(new HomeCardGestureManager( |
| 321 gesture_delegate_, | 351 gesture_delegate_, |
| 322 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); | 352 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); |
| 323 } | 353 } |
| 324 | 354 |
| 325 if (gesture_manager_) | 355 if (gesture_manager_) |
| 326 gesture_manager_->ProcessGestureEvent(event); | 356 gesture_manager_->ProcessGestureEvent(event); |
| 327 } | 357 } |
| 328 | 358 |
| 329 private: | 359 private: |
| 330 virtual views::View* GetContentsView() OVERRIDE { | 360 virtual views::View* GetContentsView() OVERRIDE { |
| 331 return this; | 361 return this; |
| 332 } | 362 } |
| 333 | 363 |
| 334 app_list::AppListMainView* main_view_; | 364 app_list::AppListMainView* main_view_; |
| 335 BottomHomeView* bottom_view_; | 365 views::View* bottom_view_; |
| 336 views::View* minimized_view_; | 366 views::View* minimized_view_; |
| 337 scoped_ptr<HomeCardGestureManager> gesture_manager_; | 367 scoped_ptr<HomeCardGestureManager> gesture_manager_; |
| 338 HomeCardGestureManager::Delegate* gesture_delegate_; | 368 HomeCardGestureManager::Delegate* gesture_delegate_; |
| 339 | 369 |
| 340 DISALLOW_COPY_AND_ASSIGN(HomeCardView); | 370 DISALLOW_COPY_AND_ASSIGN(HomeCardView); |
| 341 }; | 371 }; |
| 342 | 372 |
| 343 class HomeCardImpl : public HomeCard, | 373 class HomeCardImpl : public HomeCard, |
| 344 public AcceleratorHandler, | 374 public AcceleratorHandler, |
| 345 public HomeCardLayoutManager::Delegate, | 375 public HomeCardLayoutManager::Delegate, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 WindowManager::GetInstance()->ToggleOverview(); | 570 WindowManager::GetInstance()->ToggleOverview(); |
| 541 } else { | 571 } else { |
| 542 state_ = final_state; | 572 state_ = final_state; |
| 543 home_card_view_->SetState(final_state); | 573 home_card_view_->SetState(final_state); |
| 544 layout_manager_->Layout(); | 574 layout_manager_->Layout(); |
| 545 } | 575 } |
| 546 } | 576 } |
| 547 | 577 |
| 548 void HomeCardImpl::OnGestureProgressed( | 578 void HomeCardImpl::OnGestureProgressed( |
| 549 State from_state, State to_state, float progress) { | 579 State from_state, State to_state, float progress) { |
| 550 // Do not update |state_| but update the look of home_card_view. | 580 home_card_view_->SetStateProgress(from_state, to_state, progress); |
| 551 // TODO(mukai): allow mixed visual of |from_state| and |to_state|. | |
| 552 home_card_view_->SetState(to_state); | |
| 553 | 581 |
| 554 gfx::Rect screen_bounds = | 582 gfx::Rect screen_bounds = |
| 555 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds(); | 583 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds(); |
| 556 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween( | 584 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween( |
| 557 progress, | 585 progress, |
| 558 GetBoundsForState(screen_bounds, from_state), | 586 GetBoundsForState(screen_bounds, from_state), |
| 559 GetBoundsForState(screen_bounds, to_state))); | 587 GetBoundsForState(screen_bounds, to_state))); |
| 560 | 588 |
| 561 // TODO(mukai): signals the update to the window manager so that it shows the | 589 // TODO(mukai): signals the update to the window manager so that it shows the |
| 562 // intermediate visual state of overview mode. | 590 // intermediate visual state of overview mode. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 instance = NULL; | 622 instance = NULL; |
| 595 } | 623 } |
| 596 | 624 |
| 597 // static | 625 // static |
| 598 HomeCard* HomeCard::Get() { | 626 HomeCard* HomeCard::Get() { |
| 599 DCHECK(instance); | 627 DCHECK(instance); |
| 600 return instance; | 628 return instance; |
| 601 } | 629 } |
| 602 | 630 |
| 603 } // namespace athena | 631 } // namespace athena |
| OLD | NEW |