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/gfx/shadow_value.h" |
15 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
17 | 18 |
18 namespace app_list { | 19 namespace app_list { |
19 | 20 |
| 21 namespace { |
| 22 |
| 23 gfx::ShadowValue GetSearchBoxShadowForState(AppListModel::State state) { |
| 24 return GetShadowForZHeight(state == AppListModel::STATE_SEARCH_RESULTS ? 1 |
| 25 : 2); |
| 26 } |
| 27 |
| 28 } // namespace |
| 29 |
20 // ContentsAnimator | 30 // ContentsAnimator |
21 | 31 |
22 ContentsAnimator::ContentsAnimator(ContentsView* contents_view) | 32 ContentsAnimator::ContentsAnimator(ContentsView* contents_view) |
23 : contents_view_(contents_view) { | 33 : contents_view_(contents_view) { |
24 } | 34 } |
25 | 35 |
26 ContentsAnimator::~ContentsAnimator() { | 36 ContentsAnimator::~ContentsAnimator() { |
27 } | 37 } |
28 | 38 |
29 gfx::Rect ContentsAnimator::GetOnscreenPageBounds(int page_index) const { | 39 gfx::Rect ContentsAnimator::GetOnscreenPageBounds(int page_index) const { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 100 |
91 // These are in ContentsView coordinates. | 101 // These are in ContentsView coordinates. |
92 gfx::Rect search_box_from( | 102 gfx::Rect search_box_from( |
93 contents_view()->GetSearchBoxBoundsForPageIndex(from_page)); | 103 contents_view()->GetSearchBoxBoundsForPageIndex(from_page)); |
94 gfx::Rect search_box_to( | 104 gfx::Rect search_box_to( |
95 contents_view()->GetSearchBoxBoundsForPageIndex(to_page)); | 105 contents_view()->GetSearchBoxBoundsForPageIndex(to_page)); |
96 | 106 |
97 gfx::Rect search_box_rect = | 107 gfx::Rect search_box_rect = |
98 gfx::Tween::RectValueBetween(progress, search_box_from, search_box_to); | 108 gfx::Tween::RectValueBetween(progress, search_box_from, search_box_to); |
99 | 109 |
| 110 AppListModel::State from_state = |
| 111 contents_view()->GetStateForPageIndex(from_page); |
| 112 AppListModel::State to_state = contents_view()->GetStateForPageIndex(to_page); |
| 113 |
| 114 gfx::ShadowValue original_shadow = GetSearchBoxShadowForState(from_state); |
| 115 gfx::ShadowValue target_shadow = GetSearchBoxShadowForState(to_state); |
| 116 |
100 SearchBoxView* search_box = contents_view()->GetSearchBoxView(); | 117 SearchBoxView* search_box = contents_view()->GetSearchBoxView(); |
101 search_box->GetWidget()->SetBounds(contents_view()->ConvertRectToWidget( | 118 gfx::Point offset(gfx::Tween::LinearIntValueBetween( |
102 search_box->GetViewBoundsForSearchBoxContentsBounds(search_box_rect))); | 119 progress, original_shadow.x(), target_shadow.x()), |
| 120 gfx::Tween::LinearIntValueBetween( |
| 121 progress, original_shadow.y(), target_shadow.y())); |
| 122 search_box->SetShadow(gfx::ShadowValue( |
| 123 offset, gfx::Tween::LinearIntValueBetween( |
| 124 progress, original_shadow.blur(), target_shadow.blur()), |
| 125 gfx::Tween::ColorValueBetween(progress, original_shadow.color(), |
| 126 target_shadow.color()))); |
| 127 |
| 128 search_box->GetWidget()->SetBounds( |
| 129 search_box->GetViewBoundsForSearchBoxContentsBounds( |
| 130 contents_view()->ConvertRectToWidget(search_box_rect))); |
103 } | 131 } |
104 | 132 |
105 void ContentsAnimator::ClipSearchResultsPageToOnscreenBounds( | 133 void ContentsAnimator::ClipSearchResultsPageToOnscreenBounds( |
106 int page_index, | 134 int page_index, |
107 const gfx::Rect& current_bounds, | 135 const gfx::Rect& current_bounds, |
108 const gfx::Rect& onscreen_bounds) { | 136 const gfx::Rect& onscreen_bounds) { |
109 int search_results_index = | 137 int search_results_index = |
110 contents_view()->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS); | 138 contents_view()->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS); |
111 if (page_index != search_results_index) | 139 if (page_index != search_results_index) |
112 return; | 140 return; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween( | 230 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween( |
203 progress, custom_page_origin, custom_page_on_screen)); | 231 progress, custom_page_origin, custom_page_on_screen)); |
204 | 232 |
205 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect); | 233 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect); |
206 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect); | 234 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect); |
207 | 235 |
208 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page); | 236 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page); |
209 } | 237 } |
210 | 238 |
211 } // namespace app_list | 239 } // namespace app_list |
OLD | NEW |