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 "ui/app_list/views/contents_animator.h" | 5 #include "ui/app_list/views/contents_animator.h" |
6 | 6 |
7 #include "ui/app_list/app_list_constants.h" | 7 #include "ui/app_list/app_list_constants.h" |
8 #include "ui/app_list/app_list_switches.h" | 8 #include "ui/app_list/app_list_switches.h" |
9 #include "ui/app_list/views/app_list_main_view.h" | 9 #include "ui/app_list/views/app_list_main_view.h" |
10 #include "ui/app_list/views/contents_view.h" | 10 #include "ui/app_list/views/contents_view.h" |
11 #include "ui/app_list/views/search_box_view.h" | 11 #include "ui/app_list/views/search_box_view.h" |
12 #include "ui/app_list/views/start_page_view.h" | 12 #include "ui/app_list/views/start_page_view.h" |
13 #include "ui/gfx/animation/tween.h" | 13 #include "ui/gfx/animation/tween.h" |
14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
17 | 17 |
18 namespace app_list { | 18 namespace app_list { |
19 | 19 |
20 // ContentsAnimator | 20 // ContentsAnimator |
21 | 21 |
22 ContentsAnimator::ContentsAnimator(ContentsView* contents_view) | 22 ContentsAnimator::ContentsAnimator(ContentsView* contents_view) |
23 : contents_view_(contents_view) { | 23 : contents_view_(contents_view) { |
24 } | 24 } |
25 | 25 |
26 ContentsAnimator::~ContentsAnimator() { | 26 ContentsAnimator::~ContentsAnimator() { |
27 } | 27 } |
28 | 28 |
29 gfx::Rect ContentsAnimator::GetOnscreenPageBounds(int page_index) const { | 29 gfx::Rect ContentsAnimator::GetOnscreenPageBounds(int page_index) const { |
30 return contents_view_->IsStateActive(AppListModel::STATE_CUSTOM_LAUNCHER_PAGE) | 30 return contents_view_->GetPageIndexForState( |
| 31 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE) == page_index |
31 ? contents_view_->GetContentsBounds() | 32 ? contents_view_->GetContentsBounds() |
32 : contents_view_->GetDefaultContentsBounds(); | 33 : contents_view_->GetDefaultContentsBounds(); |
33 } | 34 } |
34 | 35 |
35 gfx::Rect ContentsAnimator::GetOffscreenPageBounds(int page_index) const { | 36 gfx::Rect ContentsAnimator::GetOffscreenPageBounds(int page_index) const { |
36 gfx::Rect bounds(contents_view_->GetContentsBounds()); | 37 gfx::Rect bounds(GetOnscreenPageBounds(page_index)); |
37 // The start page and search page origins are above; all other pages' origins | 38 // The start page and search page origins are above; all other pages' origins |
38 // are below. | 39 // are below. |
39 int page_height = bounds.height(); | |
40 bool origin_above = contents_view_->GetPageIndexForState( | 40 bool origin_above = contents_view_->GetPageIndexForState( |
41 AppListModel::STATE_START) == page_index || | 41 AppListModel::STATE_START) == page_index || |
42 contents_view_->GetPageIndexForState( | 42 contents_view_->GetPageIndexForState( |
43 AppListModel::STATE_SEARCH_RESULTS) == page_index; | 43 AppListModel::STATE_SEARCH_RESULTS) == page_index; |
44 bounds.set_y(origin_above ? -page_height : page_height); | 44 bounds.set_y(origin_above |
| 45 ? -bounds.height() |
| 46 : contents_view_->GetContentsBounds().height() + bounds.y()); |
45 return bounds; | 47 return bounds; |
46 } | 48 } |
47 | 49 |
48 void ContentsAnimator::UpdateCustomPageForDefaultAnimation(double progress, | 50 void ContentsAnimator::UpdateCustomPageForDefaultAnimation(double progress, |
49 int from_page, | 51 int from_page, |
50 int to_page) const { | 52 int to_page) const { |
51 int custom_page_index = contents_view()->GetPageIndexForState( | 53 int custom_page_index = contents_view()->GetPageIndexForState( |
52 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); | 54 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); |
53 if (custom_page_index < 0) | 55 if (custom_page_index < 0) |
54 return; | 56 return; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween( | 202 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween( |
201 progress, custom_page_origin, custom_page_on_screen)); | 203 progress, custom_page_origin, custom_page_on_screen)); |
202 | 204 |
203 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect); | 205 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect); |
204 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect); | 206 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect); |
205 | 207 |
206 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page); | 208 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page); |
207 } | 209 } |
208 | 210 |
209 } // namespace app_list | 211 } // namespace app_list |
OLD | NEW |