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 "athena/home/athena_start_page_view.h" | 5 #include "athena/home/athena_start_page_view.h" |
6 | 6 |
7 #include "athena/home/home_card_constants.h" | 7 #include "athena/home/home_card_constants.h" |
| 8 #include "athena/system/public/system_ui.h" |
8 #include "base/bind.h" | 9 #include "base/bind.h" |
9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
10 #include "third_party/skia/include/core/SkPaint.h" | 11 #include "third_party/skia/include/core/SkPaint.h" |
11 #include "third_party/skia/include/core/SkPath.h" | 12 #include "third_party/skia/include/core/SkPath.h" |
12 #include "ui/app_list/app_list_item.h" | 13 #include "ui/app_list/app_list_item.h" |
13 #include "ui/app_list/app_list_item_list.h" | 14 #include "ui/app_list/app_list_item_list.h" |
14 #include "ui/app_list/app_list_model.h" | 15 #include "ui/app_list/app_list_model.h" |
15 #include "ui/app_list/app_list_view_delegate.h" | 16 #include "ui/app_list/app_list_view_delegate.h" |
16 #include "ui/app_list/search_box_model.h" | 17 #include "ui/app_list/search_box_model.h" |
17 #include "ui/app_list/views/search_box_view.h" | 18 #include "ui/app_list/views/search_box_view.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 }; | 149 }; |
149 | 150 |
150 } // namespace | 151 } // namespace |
151 | 152 |
152 namespace athena { | 153 namespace athena { |
153 | 154 |
154 // static | 155 // static |
155 const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView"; | 156 const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView"; |
156 | 157 |
157 AthenaStartPageView::LayoutData::LayoutData() | 158 AthenaStartPageView::LayoutData::LayoutData() |
158 : logo_opacity(1.0f), | 159 : system_info_opacity(1.0f), |
| 160 logo_opacity(1.0f), |
159 background_opacity(1.0f) { | 161 background_opacity(1.0f) { |
160 } | 162 } |
161 | 163 |
162 AthenaStartPageView::AthenaStartPageView( | 164 AthenaStartPageView::AthenaStartPageView( |
163 app_list::AppListViewDelegate* view_delegate) | 165 app_list::AppListViewDelegate* view_delegate) |
164 : delegate_(view_delegate), | 166 : delegate_(view_delegate), |
165 layout_state_(0.0f), | 167 layout_state_(0.0f), |
166 weak_factory_(this) { | 168 weak_factory_(this) { |
167 background_ = new views::View(); | 169 background_ = new views::View(); |
168 background_->set_background( | 170 background_->set_background( |
169 views::Background::CreateSolidBackground(SK_ColorWHITE)); | 171 views::Background::CreateSolidBackground(SK_ColorWHITE)); |
170 background_->SetPaintToLayer(true); | 172 background_->SetPaintToLayer(true); |
171 background_->SetFillsBoundsOpaquely(false); | 173 background_->SetFillsBoundsOpaquely(false); |
172 AddChildView(background_); | 174 AddChildView(background_); |
173 | 175 |
| 176 system_info_view_ = |
| 177 SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_DARK); |
| 178 system_info_view_->SetPaintToLayer(true); |
| 179 system_info_view_->SetFillsBoundsOpaquely(false); |
| 180 AddChildView(system_info_view_); |
| 181 |
174 logo_ = view_delegate->CreateStartPageWebView( | 182 logo_ = view_delegate->CreateStartPageWebView( |
175 gfx::Size(kWebViewWidth, kWebViewHeight)); | 183 gfx::Size(kWebViewWidth, kWebViewHeight)); |
176 logo_->SetPaintToLayer(true); | 184 logo_->SetPaintToLayer(true); |
177 logo_->SetFillsBoundsOpaquely(false); | 185 logo_->SetFillsBoundsOpaquely(false); |
178 logo_->SetSize(gfx::Size(kWebViewWidth, kWebViewHeight)); | 186 logo_->SetSize(gfx::Size(kWebViewWidth, kWebViewHeight)); |
179 AddChildView(logo_); | 187 AddChildView(logo_); |
180 | 188 |
181 search_results_view_ = new app_list::SearchResultListView( | 189 search_results_view_ = new app_list::SearchResultListView( |
182 NULL, view_delegate); | 190 NULL, view_delegate); |
183 // search_results_view_'s size will shrink after settings results. | 191 // search_results_view_'s size will shrink after settings results. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void AthenaStartPageView::RequestFocusOnSearchBox() { | 235 void AthenaStartPageView::RequestFocusOnSearchBox() { |
228 search_box_view_->search_box()->RequestFocus(); | 236 search_box_view_->search_box()->RequestFocus(); |
229 } | 237 } |
230 | 238 |
231 void AthenaStartPageView::SetLayoutState(float layout_state) { | 239 void AthenaStartPageView::SetLayoutState(float layout_state) { |
232 layout_state_ = layout_state; | 240 layout_state_ = layout_state; |
233 Layout(); | 241 Layout(); |
234 } | 242 } |
235 | 243 |
236 void AthenaStartPageView::SetLayoutStateWithAnimation(float layout_state) { | 244 void AthenaStartPageView::SetLayoutStateWithAnimation(float layout_state) { |
| 245 ui::ScopedLayerAnimationSettings system_info( |
| 246 system_info_view_->layer()->GetAnimator()); |
237 ui::ScopedLayerAnimationSettings logo(logo_->layer()->GetAnimator()); | 247 ui::ScopedLayerAnimationSettings logo(logo_->layer()->GetAnimator()); |
238 ui::ScopedLayerAnimationSettings search_box( | 248 ui::ScopedLayerAnimationSettings search_box( |
239 search_box_container_->layer()->GetAnimator()); | 249 search_box_container_->layer()->GetAnimator()); |
240 ui::ScopedLayerAnimationSettings icons( | 250 ui::ScopedLayerAnimationSettings icons( |
241 app_icon_container_->layer()->GetAnimator()); | 251 app_icon_container_->layer()->GetAnimator()); |
242 ui::ScopedLayerAnimationSettings controls( | 252 ui::ScopedLayerAnimationSettings controls( |
243 control_icon_container_->layer()->GetAnimator()); | 253 control_icon_container_->layer()->GetAnimator()); |
244 | 254 |
| 255 system_info.SetTweenType(gfx::Tween::EASE_IN_OUT); |
245 logo.SetTweenType(gfx::Tween::EASE_IN_OUT); | 256 logo.SetTweenType(gfx::Tween::EASE_IN_OUT); |
246 search_box.SetTweenType(gfx::Tween::EASE_IN_OUT); | 257 search_box.SetTweenType(gfx::Tween::EASE_IN_OUT); |
247 icons.SetTweenType(gfx::Tween::EASE_IN_OUT); | 258 icons.SetTweenType(gfx::Tween::EASE_IN_OUT); |
248 controls.SetTweenType(gfx::Tween::EASE_IN_OUT); | 259 controls.SetTweenType(gfx::Tween::EASE_IN_OUT); |
249 | 260 |
250 SetLayoutState(layout_state); | 261 SetLayoutState(layout_state); |
251 } | 262 } |
252 | 263 |
253 AthenaStartPageView::LayoutData AthenaStartPageView::CreateBottomBounds( | 264 AthenaStartPageView::LayoutData AthenaStartPageView::CreateBottomBounds( |
254 int width) { | 265 int width) { |
255 LayoutData state; | 266 LayoutData state; |
256 state.icons.set_size(app_icon_container_->size()); | 267 state.icons.set_size(app_icon_container_->size()); |
257 state.icons.set_x(kIconMargin); | 268 state.icons.set_x(kIconMargin); |
258 state.icons.set_y(kIconMargin); | 269 state.icons.set_y(kIconMargin); |
259 | 270 |
260 state.controls.set_size(control_icon_container_->size()); | 271 state.controls.set_size(control_icon_container_->size()); |
261 state.controls.set_x(width - kIconMargin - state.controls.width()); | 272 state.controls.set_x(width - kIconMargin - state.controls.width()); |
262 state.controls.set_y(kIconMargin); | 273 state.controls.set_y(kIconMargin); |
263 | 274 |
264 int search_box_max_width = | 275 int search_box_max_width = |
265 state.controls.x() - state.icons.right() - kIconMargin * 2; | 276 state.controls.x() - state.icons.right() - kIconMargin * 2; |
266 state.search_box.set_width(std::min(search_box_max_width, kSearchBoxWidth)); | 277 state.search_box.set_width(std::min(search_box_max_width, kSearchBoxWidth)); |
267 state.search_box.set_height(search_box_container_->height()); | 278 state.search_box.set_height(search_box_container_->height()); |
268 state.search_box.set_x((width - state.search_box.width()) / 2); | 279 state.search_box.set_x((width - state.search_box.width()) / 2); |
269 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); | 280 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); |
270 | 281 |
| 282 state.system_info_opacity = 0.0f; |
271 state.logo_opacity = 0.0f; | 283 state.logo_opacity = 0.0f; |
272 state.background_opacity = 0.9f; | 284 state.background_opacity = 0.9f; |
273 return state; | 285 return state; |
274 } | 286 } |
275 | 287 |
276 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( | 288 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( |
277 int width) { | 289 int width) { |
278 LayoutData state; | 290 LayoutData state; |
279 | 291 |
280 state.search_box.set_size(search_box_container_->GetPreferredSize()); | 292 state.search_box.set_size(search_box_container_->GetPreferredSize()); |
281 state.search_box.set_x((width - state.search_box.width()) / 2); | 293 state.search_box.set_x((width - state.search_box.width()) / 2); |
282 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); | 294 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); |
283 | 295 |
284 state.icons.set_size(app_icon_container_->size()); | 296 state.icons.set_size(app_icon_container_->size()); |
285 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); | 297 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); |
286 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); | 298 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); |
287 | 299 |
288 state.controls.set_size(control_icon_container_->size()); | 300 state.controls.set_size(control_icon_container_->size()); |
289 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); | 301 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); |
290 state.controls.set_y(state.icons.y()); | 302 state.controls.set_y(state.icons.y()); |
291 | 303 |
| 304 state.system_info_opacity = 1.0f; |
292 state.logo_opacity = 1.0f; | 305 state.logo_opacity = 1.0f; |
293 state.background_opacity = 1.0f; | 306 state.background_opacity = 1.0f; |
294 return state; | 307 return state; |
295 } | 308 } |
296 | 309 |
297 void AthenaStartPageView::LayoutSearchResults(bool should_show_search_results) { | 310 void AthenaStartPageView::LayoutSearchResults(bool should_show_search_results) { |
298 if (should_show_search_results == | 311 if (should_show_search_results == |
299 search_results_view_->layer()->GetTargetVisibility()) { | 312 search_results_view_->layer()->GetTargetVisibility()) { |
300 return; | 313 return; |
301 } | 314 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 370 } |
358 | 371 |
359 void AthenaStartPageView::OnSearchResultLayoutAnimationCompleted( | 372 void AthenaStartPageView::OnSearchResultLayoutAnimationCompleted( |
360 bool should_show_search_results) { | 373 bool should_show_search_results) { |
361 logo_->SetVisible(!should_show_search_results); | 374 logo_->SetVisible(!should_show_search_results); |
362 search_results_view_->SetVisible(should_show_search_results); | 375 search_results_view_->SetVisible(should_show_search_results); |
363 } | 376 } |
364 | 377 |
365 void AthenaStartPageView::Layout() { | 378 void AthenaStartPageView::Layout() { |
366 search_results_view_->SetVisible(false); | 379 search_results_view_->SetVisible(false); |
| 380 |
| 381 system_info_view_->SetBounds( |
| 382 0, 0, width(), system_info_view_->GetPreferredSize().height()); |
| 383 |
367 gfx::Rect logo_bounds(x() + width() / 2 - kWebViewWidth / 2, y() + kTopMargin, | 384 gfx::Rect logo_bounds(x() + width() / 2 - kWebViewWidth / 2, y() + kTopMargin, |
368 kWebViewWidth, kWebViewHeight); | 385 kWebViewWidth, kWebViewHeight); |
369 logo_->SetBoundsRect(logo_bounds); | 386 logo_->SetBoundsRect(logo_bounds); |
370 | 387 |
371 LayoutData bottom_bounds = CreateBottomBounds(width()); | 388 LayoutData bottom_bounds = CreateBottomBounds(width()); |
372 LayoutData centered_bounds = CreateCenteredBounds(width()); | 389 LayoutData centered_bounds = CreateCenteredBounds(width()); |
373 | 390 |
| 391 system_info_view_->layer()->SetOpacity(gfx::Tween::FloatValueBetween( |
| 392 gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_), |
| 393 bottom_bounds.system_info_opacity, centered_bounds.system_info_opacity)); |
| 394 system_info_view_->SetVisible( |
| 395 system_info_view_->layer()->GetTargetOpacity() != 0.0f); |
| 396 |
374 logo_->layer()->SetOpacity(gfx::Tween::FloatValueBetween( | 397 logo_->layer()->SetOpacity(gfx::Tween::FloatValueBetween( |
375 gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_), | 398 gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_), |
376 bottom_bounds.logo_opacity, centered_bounds.logo_opacity)); | 399 bottom_bounds.logo_opacity, centered_bounds.logo_opacity)); |
377 logo_->SetVisible(logo_->layer()->GetTargetOpacity() != 0.0f); | 400 logo_->SetVisible(logo_->layer()->GetTargetOpacity() != 0.0f); |
378 | 401 |
379 app_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween( | 402 app_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween( |
380 layout_state_, bottom_bounds.icons, centered_bounds.icons)); | 403 layout_state_, bottom_bounds.icons, centered_bounds.icons)); |
381 control_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween( | 404 control_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween( |
382 layout_state_, bottom_bounds.controls, centered_bounds.controls)); | 405 layout_state_, bottom_bounds.controls, centered_bounds.controls)); |
383 search_box_container_->SetBoundsRect(gfx::Tween::RectValueBetween( | 406 search_box_container_->SetBoundsRect(gfx::Tween::RectValueBetween( |
(...skipping 18 matching lines...) Expand all Loading... |
402 base::TrimWhitespace( | 425 base::TrimWhitespace( |
403 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); | 426 delegate_->GetModel()->search_box()->text(), base::TRIM_ALL, &query); |
404 | 427 |
405 if (!query.empty()) | 428 if (!query.empty()) |
406 search_results_view_->SetSelectedIndex(0); | 429 search_results_view_->SetSelectedIndex(0); |
407 | 430 |
408 LayoutSearchResults(!query.empty()); | 431 LayoutSearchResults(!query.empty()); |
409 } | 432 } |
410 | 433 |
411 } // namespace athena | 434 } // namespace athena |
OLD | NEW |