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

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

Issue 473623002: Redesign the home card bottom state. (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/bottom_home_view.cc ('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/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 kHomeCardHeight = 100;
40 const int kHomeCardMinimizedHeight = 6;
39 41
40 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds, 42 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds,
41 HomeCard::State state) { 43 HomeCard::State state) {
42 const int kHomeCardHeight = 150;
43 const int kHomeCardMinimizedHeight = 8;
44
45 switch (state) { 44 switch (state) {
46 case HomeCard::HIDDEN: 45 case HomeCard::HIDDEN:
47 break; 46 break;
48 47
49 case HomeCard::VISIBLE_CENTERED: 48 case HomeCard::VISIBLE_CENTERED:
50 return screen_bounds; 49 return screen_bounds;
51 50
52 case HomeCard::VISIBLE_BOTTOM: 51 case HomeCard::VISIBLE_BOTTOM:
53 return gfx::Rect(0, 52 return gfx::Rect(0,
54 screen_bounds.bottom() - kHomeCardHeight, 53 screen_bounds.bottom() - kHomeCardHeight,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 DISALLOW_COPY_AND_ASSIGN(HomeCardGestureManager); 261 DISALLOW_COPY_AND_ASSIGN(HomeCardGestureManager);
263 }; 262 };
264 263
265 // The container view of home card contents of each state. 264 // The container view of home card contents of each state.
266 class HomeCardView : public views::WidgetDelegateView { 265 class HomeCardView : public views::WidgetDelegateView {
267 public: 266 public:
268 HomeCardView(app_list::AppListViewDelegate* view_delegate, 267 HomeCardView(app_list::AppListViewDelegate* view_delegate,
269 aura::Window* container, 268 aura::Window* container,
270 HomeCardGestureManager::Delegate* gesture_delegate) 269 HomeCardGestureManager::Delegate* gesture_delegate)
271 : gesture_delegate_(gesture_delegate) { 270 : gesture_delegate_(gesture_delegate) {
272 bottom_view_ = new BottomHomeView(view_delegate); 271 bottom_view_ = new AthenaStartPageView(view_delegate);
273 AddChildView(bottom_view_); 272 AddChildView(bottom_view_);
273 bottom_view_->SetPaintToLayer(true);
274 bottom_view_->layer()->SetFillsBoundsOpaquely(false);
274 275
275 main_view_ = new app_list::AppListMainView( 276 main_view_ = new app_list::AppListMainView(
276 view_delegate, 0 /* initial_apps_page */, container); 277 view_delegate, 0 /* initial_apps_page */, container);
277 AddChildView(main_view_); 278 AddChildView(main_view_);
278 main_view_->set_background( 279 main_view_->set_background(
279 views::Background::CreateSolidBackground(SK_ColorWHITE)); 280 views::Background::CreateSolidBackground(SK_ColorWHITE));
281 main_view_->SetPaintToLayer(true);
280 282
281 minimized_view_ = CreateMinimizedHome(); 283 minimized_view_ = CreateMinimizedHome();
284 minimized_view_->SetPaintToLayer(true);
282 AddChildView(minimized_view_); 285 AddChildView(minimized_view_);
283 } 286 }
284 287
288 void SetStateProgress(HomeCard::State from_state,
289 HomeCard::State to_state,
290 float progress) {
291 if (from_state == HomeCard::VISIBLE_BOTTOM &&
292 to_state == HomeCard::VISIBLE_MINIMIZED) {
293 SetStateProgress(to_state, from_state, 1.0 - progress);
294 return;
295 }
296
297 // View from minimized to bottom.
298 if (from_state == HomeCard::VISIBLE_MINIMIZED &&
299 to_state == HomeCard::VISIBLE_BOTTOM) {
300 bottom_view_->SetVisible(true);
301 minimized_view_->SetVisible(true);
302 minimized_view_->layer()->SetOpacity(1.0f - progress);
303 return;
304 }
305
306 SetState(to_state);
307 }
308
285 void SetState(HomeCard::State state) { 309 void SetState(HomeCard::State state) {
286 bottom_view_->SetVisible(state == HomeCard::VISIBLE_BOTTOM); 310 bottom_view_->SetVisible(state == HomeCard::VISIBLE_BOTTOM);
287 main_view_->SetVisible(state == HomeCard::VISIBLE_CENTERED); 311 main_view_->SetVisible(state == HomeCard::VISIBLE_CENTERED);
288 minimized_view_->SetVisible(state == HomeCard::VISIBLE_MINIMIZED); 312 minimized_view_->SetVisible(state == HomeCard::VISIBLE_MINIMIZED);
313 if (minimized_view_->visible())
314 minimized_view_->layer()->SetOpacity(1.0f);
289 if (state == HomeCard::VISIBLE_CENTERED) { 315 if (state == HomeCard::VISIBLE_CENTERED) {
290 app_list::ContentsView* contents_view = main_view_->contents_view(); 316 app_list::ContentsView* contents_view = main_view_->contents_view();
291 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage( 317 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage(
292 app_list::ContentsView::NAMED_PAGE_START)); 318 app_list::ContentsView::NAMED_PAGE_START));
293 } 319 }
294 wm::SetShadowType(GetWidget()->GetNativeView(), 320 wm::SetShadowType(GetWidget()->GetNativeView(),
295 state == HomeCard::VISIBLE_MINIMIZED ? 321 state == HomeCard::VISIBLE_MINIMIZED ?
296 wm::SHADOW_TYPE_NONE : 322 wm::SHADOW_TYPE_NONE :
297 wm::SHADOW_TYPE_RECTANGULAR); 323 wm::SHADOW_TYPE_RECTANGULAR);
298 } 324 }
299 325
300 void ClearGesture() { 326 void ClearGesture() {
301 gesture_manager_.reset(); 327 gesture_manager_.reset();
302 } 328 }
303 329
304 // views::View: 330 // views::View:
305 virtual void Layout() OVERRIDE { 331 virtual void Layout() OVERRIDE {
306 for (int i = 0; i < child_count(); ++i) { 332 for (int i = 0; i < child_count(); ++i) {
307 views::View* child = child_at(i); 333 views::View* child = child_at(i);
308 if (child->visible()) { 334 if (child->visible()) {
309 child->SetBoundsRect(bounds()); 335 if (child == minimized_view_) {
310 return; 336 gfx::Rect minimized_bounds = bounds();
337 minimized_bounds.set_y(
338 minimized_bounds.bottom() - kHomeCardMinimizedHeight);
339 child->SetBoundsRect(minimized_bounds);
340 } else {
341 child->SetBoundsRect(bounds());
342 }
311 } 343 }
312 } 344 }
313
314 // One of the child views has to be visible.
315 NOTREACHED();
316 } 345 }
317 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { 346 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
318 if (!gesture_manager_ && 347 if (!gesture_manager_ &&
319 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { 348 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
320 gesture_manager_.reset(new HomeCardGestureManager( 349 gesture_manager_.reset(new HomeCardGestureManager(
321 gesture_delegate_, 350 gesture_delegate_,
322 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); 351 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds()));
323 } 352 }
324 353
325 if (gesture_manager_) 354 if (gesture_manager_)
326 gesture_manager_->ProcessGestureEvent(event); 355 gesture_manager_->ProcessGestureEvent(event);
327 } 356 }
328 357
329 private: 358 private:
330 virtual views::View* GetContentsView() OVERRIDE { 359 virtual views::View* GetContentsView() OVERRIDE {
331 return this; 360 return this;
332 } 361 }
333 362
334 app_list::AppListMainView* main_view_; 363 app_list::AppListMainView* main_view_;
335 BottomHomeView* bottom_view_; 364 views::View* bottom_view_;
336 views::View* minimized_view_; 365 views::View* minimized_view_;
337 scoped_ptr<HomeCardGestureManager> gesture_manager_; 366 scoped_ptr<HomeCardGestureManager> gesture_manager_;
338 HomeCardGestureManager::Delegate* gesture_delegate_; 367 HomeCardGestureManager::Delegate* gesture_delegate_;
339 368
340 DISALLOW_COPY_AND_ASSIGN(HomeCardView); 369 DISALLOW_COPY_AND_ASSIGN(HomeCardView);
341 }; 370 };
342 371
343 class HomeCardImpl : public HomeCard, 372 class HomeCardImpl : public HomeCard,
344 public AcceleratorHandler, 373 public AcceleratorHandler,
345 public HomeCardLayoutManager::Delegate, 374 public HomeCardLayoutManager::Delegate,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 WindowManager::GetInstance()->ToggleOverview(); 569 WindowManager::GetInstance()->ToggleOverview();
541 } else { 570 } else {
542 state_ = final_state; 571 state_ = final_state;
543 home_card_view_->SetState(final_state); 572 home_card_view_->SetState(final_state);
544 layout_manager_->Layout(); 573 layout_manager_->Layout();
545 } 574 }
546 } 575 }
547 576
548 void HomeCardImpl::OnGestureProgressed( 577 void HomeCardImpl::OnGestureProgressed(
549 State from_state, State to_state, float progress) { 578 State from_state, State to_state, float progress) {
550 // Do not update |state_| but update the look of home_card_view. 579 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 580
554 gfx::Rect screen_bounds = 581 gfx::Rect screen_bounds =
555 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds(); 582 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds();
556 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween( 583 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween(
557 progress, 584 progress,
558 GetBoundsForState(screen_bounds, from_state), 585 GetBoundsForState(screen_bounds, from_state),
559 GetBoundsForState(screen_bounds, to_state))); 586 GetBoundsForState(screen_bounds, to_state)));
560 587
561 // TODO(mukai): signals the update to the window manager so that it shows the 588 // TODO(mukai): signals the update to the window manager so that it shows the
562 // intermediate visual state of overview mode. 589 // intermediate visual state of overview mode.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 instance = NULL; 621 instance = NULL;
595 } 622 }
596 623
597 // static 624 // static
598 HomeCard* HomeCard::Get() { 625 HomeCard* HomeCard::Get() {
599 DCHECK(instance); 626 DCHECK(instance);
600 return instance; 627 return instance;
601 } 628 }
602 629
603 } // namespace athena 630 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/bottom_home_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698