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" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 // ContentsAnimator | 30 // ContentsAnimator |
31 | 31 |
32 ContentsAnimator::ContentsAnimator(ContentsView* contents_view) | 32 ContentsAnimator::ContentsAnimator(ContentsView* contents_view) |
33 : contents_view_(contents_view) { | 33 : contents_view_(contents_view) { |
34 } | 34 } |
35 | 35 |
36 ContentsAnimator::~ContentsAnimator() { | 36 ContentsAnimator::~ContentsAnimator() { |
37 } | 37 } |
38 | 38 |
39 gfx::Rect ContentsAnimator::GetOnscreenPageBounds(int page_index) const { | 39 gfx::Rect ContentsAnimator::GetOnscreenPageBounds(int page_index) const { |
Matt Giuca
2015/02/09 03:51:14
I think it's better to simply move GetOnscreenPage
calamity
2015/02/09 05:25:14
SGTM. I'm going to move OffscreenBounds too.
| |
40 return contents_view_->GetPageIndexForState( | 40 AppListModel::State state = contents_view_->GetStateForPageIndex(page_index); |
41 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE) == page_index | 41 return (state == AppListModel::STATE_CUSTOM_LAUNCHER_PAGE || |
42 state == AppListModel::STATE_START) | |
42 ? contents_view_->GetContentsBounds() | 43 ? contents_view_->GetContentsBounds() |
43 : contents_view_->GetDefaultContentsBounds(); | 44 : contents_view_->GetDefaultContentsBounds(); |
44 } | 45 } |
45 | 46 |
46 gfx::Rect ContentsAnimator::GetOffscreenPageBounds(int page_index) const { | 47 gfx::Rect ContentsAnimator::GetOffscreenPageBounds(int page_index) const { |
47 gfx::Rect bounds(GetOnscreenPageBounds(page_index)); | 48 gfx::Rect bounds(GetOnscreenPageBounds(page_index)); |
48 // The start page and search page origins are above; all other pages' origins | 49 // The start page and search page origins are above; all other pages' origins |
49 // are below. | 50 // are below. |
50 bool origin_above = contents_view_->GetPageIndexForState( | 51 bool origin_above = contents_view_->GetPageIndexForState( |
51 AppListModel::STATE_START) == page_index || | 52 AppListModel::STATE_START) == page_index || |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 187 |
187 std::string StartToAppsAnimator::NameForTests() const { | 188 std::string StartToAppsAnimator::NameForTests() const { |
188 return "StartToAppsAnimator"; | 189 return "StartToAppsAnimator"; |
189 } | 190 } |
190 | 191 |
191 void StartToAppsAnimator::Update(double progress, | 192 void StartToAppsAnimator::Update(double progress, |
192 int start_page, | 193 int start_page, |
193 int apps_page) { | 194 int apps_page) { |
194 // TODO(mgiuca): This is just a clone of DefaultAnimator's animation. Write a | 195 // TODO(mgiuca): This is just a clone of DefaultAnimator's animation. Write a |
195 // custom animation for the All Apps button on the Start page. | 196 // custom animation for the All Apps button on the Start page. |
196 gfx::Rect on_screen(contents_view()->GetDefaultContentsBounds()); | 197 gfx::Rect from_page_onscreen(GetOnscreenPageBounds(start_page)); |
198 gfx::Rect to_page_onscreen(GetOnscreenPageBounds(apps_page)); | |
197 gfx::Rect from_page_origin(GetOffscreenPageBounds(start_page)); | 199 gfx::Rect from_page_origin(GetOffscreenPageBounds(start_page)); |
198 gfx::Rect to_page_origin(GetOffscreenPageBounds(apps_page)); | 200 gfx::Rect to_page_origin(GetOffscreenPageBounds(apps_page)); |
199 gfx::Rect from_page_rect( | 201 gfx::Rect from_page_rect(gfx::Tween::RectValueBetween( |
200 gfx::Tween::RectValueBetween(progress, on_screen, from_page_origin)); | 202 progress, from_page_onscreen, from_page_origin)); |
201 gfx::Rect to_page_rect( | 203 gfx::Rect to_page_rect( |
202 gfx::Tween::RectValueBetween(progress, to_page_origin, on_screen)); | 204 gfx::Tween::RectValueBetween(progress, to_page_origin, to_page_onscreen)); |
203 | 205 |
204 contents_view()->GetPageView(start_page)->SetBoundsRect(from_page_rect); | 206 contents_view()->GetPageView(start_page)->SetBoundsRect(from_page_rect); |
205 contents_view()->GetPageView(apps_page)->SetBoundsRect(to_page_rect); | 207 contents_view()->GetPageView(apps_page)->SetBoundsRect(to_page_rect); |
206 | 208 |
207 UpdateCustomPageForDefaultAnimation(progress, start_page, apps_page); | 209 UpdateCustomPageForDefaultAnimation(progress, start_page, apps_page); |
208 UpdateSearchBoxForDefaultAnimation(progress, start_page, apps_page); | 210 UpdateSearchBoxForDefaultAnimation(progress, start_page, apps_page); |
209 } | 211 } |
210 | 212 |
211 // StartToCustomAnimator | 213 // StartToCustomAnimator |
212 | 214 |
(...skipping 17 matching lines...) Expand all Loading... | |
230 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween( | 232 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween( |
231 progress, custom_page_origin, custom_page_on_screen)); | 233 progress, custom_page_origin, custom_page_on_screen)); |
232 | 234 |
233 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect); | 235 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect); |
234 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect); | 236 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect); |
235 | 237 |
236 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page); | 238 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page); |
237 } | 239 } |
238 | 240 |
239 } // namespace app_list | 241 } // namespace app_list |
OLD | NEW |