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