Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: athena/home/athena_start_page_view.cc

Issue 692643003: Moves home card background to HomeCardView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « athena/home/athena_start_page_view.h ('k') | athena/home/home_card_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "athena/system/public/system_ui.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 }; 156 };
157 157
158 } // namespace 158 } // namespace
159 159
160 namespace athena { 160 namespace athena {
161 161
162 // static 162 // static
163 const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView"; 163 const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView";
164 164
165 AthenaStartPageView::LayoutData::LayoutData() 165 AthenaStartPageView::LayoutData::LayoutData()
166 : system_info_opacity(1.0f), 166 : system_info_opacity(1.0f), logo_opacity(1.0f) {
167 logo_opacity(1.0f),
168 background_opacity(1.0f) {
169 } 167 }
170 168
171 AthenaStartPageView::AthenaStartPageView( 169 AthenaStartPageView::AthenaStartPageView(
172 app_list::AppListViewDelegate* view_delegate) 170 app_list::AppListViewDelegate* view_delegate)
173 : delegate_(view_delegate), 171 : delegate_(view_delegate),
174 layout_state_(0.0f), 172 layout_state_(0.0f),
175 weak_factory_(this) { 173 weak_factory_(this) {
176 background_ = new views::View();
177 // Vertical gradient background for the time being.
178 // TODO(mukai): replace by the actual one.
179 background_->set_background(
180 views::Background::CreateVerticalGradientBackground(SK_ColorLTGRAY,
181 SK_ColorWHITE));
182 background_->SetPaintToLayer(true);
183 background_->SetFillsBoundsOpaquely(false);
184 AddChildView(background_);
185
186 system_info_view_ = 174 system_info_view_ =
187 SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_DARK); 175 SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_DARK);
188 system_info_view_->SetPaintToLayer(true); 176 system_info_view_->SetPaintToLayer(true);
189 system_info_view_->SetFillsBoundsOpaquely(false); 177 system_info_view_->SetFillsBoundsOpaquely(false);
190 AddChildView(system_info_view_); 178 AddChildView(system_info_view_);
191 179
192 logo_ = view_delegate->CreateStartPageWebView( 180 logo_ = view_delegate->CreateStartPageWebView(
193 gfx::Size(kWebViewWidth, kWebViewHeight)); 181 gfx::Size(kWebViewWidth, kWebViewHeight));
194 logo_->SetPaintToLayer(true); 182 logo_->SetPaintToLayer(true);
195 logo_->SetFillsBoundsOpaquely(false); 183 logo_->SetFillsBoundsOpaquely(false);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 284
297 int search_box_max_width = 285 int search_box_max_width =
298 state.controls.x() - state.icons.right() - kIconMargin * 2; 286 state.controls.x() - state.icons.right() - kIconMargin * 2;
299 state.search_box.set_width(std::min(search_box_max_width, kSearchBoxWidth)); 287 state.search_box.set_width(std::min(search_box_max_width, kSearchBoxWidth));
300 state.search_box.set_height(search_box_container_->height()); 288 state.search_box.set_height(search_box_container_->height());
301 state.search_box.set_x((width - state.search_box.width()) / 2); 289 state.search_box.set_x((width - state.search_box.width()) / 2);
302 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2); 290 state.search_box.set_y((kHomeCardHeight - state.search_box.height()) / 2);
303 291
304 state.system_info_opacity = 0.0f; 292 state.system_info_opacity = 0.0f;
305 state.logo_opacity = 0.0f; 293 state.logo_opacity = 0.0f;
306 state.background_opacity = 0.9f;
307 return state; 294 return state;
308 } 295 }
309 296
310 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( 297 AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds(
311 int width) { 298 int width) {
312 LayoutData state; 299 LayoutData state;
313 300
314 state.search_box.set_size(search_box_container_->GetPreferredSize()); 301 state.search_box.set_size(search_box_container_->GetPreferredSize());
315 state.search_box.set_x((width - state.search_box.width()) / 2); 302 state.search_box.set_x((width - state.search_box.width()) / 2);
316 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing); 303 state.search_box.set_y(logo_->bounds().bottom() + kInstantContainerSpacing);
317 304
318 state.icons.set_size(app_icon_container_->size()); 305 state.icons.set_size(app_icon_container_->size());
319 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2); 306 state.icons.set_x(width / 2 - state.icons.width() - kIconMargin / 2);
320 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing); 307 state.icons.set_y(state.search_box.bottom() + kInstantContainerSpacing);
321 308
322 state.controls.set_size(control_icon_container_->size()); 309 state.controls.set_size(control_icon_container_->size());
323 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2); 310 state.controls.set_x(width / 2 + kIconMargin / 2 + kIconMargin % 2);
324 state.controls.set_y(state.icons.y()); 311 state.controls.set_y(state.icons.y());
325 312
326 state.system_info_opacity = 1.0f; 313 state.system_info_opacity = 1.0f;
327 state.logo_opacity = 1.0f; 314 state.logo_opacity = 1.0f;
328 state.background_opacity = 1.0f;
329 return state; 315 return state;
330 } 316 }
331 317
332 void AthenaStartPageView::UpdateAppIcons() { 318 void AthenaStartPageView::UpdateAppIcons() {
333 app_list::AppListItemList* top_level = 319 app_list::AppListItemList* top_level =
334 delegate_->GetModel()->top_level_item_list(); 320 delegate_->GetModel()->top_level_item_list();
335 size_t max_items = std::min(top_level->item_count(), kMaxIconNum); 321 size_t max_items = std::min(top_level->item_count(), kMaxIconNum);
336 for (size_t i = 0; i < max_items; ++i) { 322 for (size_t i = 0; i < max_items; ++i) {
337 if (i < static_cast<size_t>(app_icon_container_->child_count())) { 323 if (i < static_cast<size_t>(app_icon_container_->child_count())) {
338 AppIconButton* button = 324 AppIconButton* button =
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_), 425 gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_2, layout_state_),
440 bottom_bounds.logo_opacity, centered_bounds.logo_opacity)); 426 bottom_bounds.logo_opacity, centered_bounds.logo_opacity));
441 logo_->SetVisible(logo_->layer()->GetTargetOpacity() != 0.0f); 427 logo_->SetVisible(logo_->layer()->GetTargetOpacity() != 0.0f);
442 428
443 app_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween( 429 app_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween(
444 layout_state_, bottom_bounds.icons, centered_bounds.icons)); 430 layout_state_, bottom_bounds.icons, centered_bounds.icons));
445 control_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween( 431 control_icon_container_->SetBoundsRect(gfx::Tween::RectValueBetween(
446 layout_state_, bottom_bounds.controls, centered_bounds.controls)); 432 layout_state_, bottom_bounds.controls, centered_bounds.controls));
447 search_box_container_->SetBoundsRect(gfx::Tween::RectValueBetween( 433 search_box_container_->SetBoundsRect(gfx::Tween::RectValueBetween(
448 layout_state_, bottom_bounds.search_box, centered_bounds.search_box)); 434 layout_state_, bottom_bounds.search_box, centered_bounds.search_box));
449
450 background_->SetBoundsRect(bounds());
451 background_->layer()->SetOpacity(gfx::Tween::FloatValueBetween(
452 layout_state_,
453 bottom_bounds.background_opacity,
454 centered_bounds.background_opacity));
455 } 435 }
456 436
457 bool AthenaStartPageView::OnKeyPressed(const ui::KeyEvent& key_event) { 437 bool AthenaStartPageView::OnKeyPressed(const ui::KeyEvent& key_event) {
458 return search_results_view_->visible() && 438 return search_results_view_->visible() &&
459 search_results_view_->OnKeyPressed(key_event); 439 search_results_view_->OnKeyPressed(key_event);
460 } 440 }
461 441
462 void AthenaStartPageView::QueryChanged(app_list::SearchBoxView* sender) { 442 void AthenaStartPageView::QueryChanged(app_list::SearchBoxView* sender) {
463 delegate_->StartSearch(); 443 delegate_->StartSearch();
464 444
(...skipping 22 matching lines...) Expand all
487 app_list::AppListItem* item) { 467 app_list::AppListItem* item) {
488 UpdateAppIcons(); 468 UpdateAppIcons();
489 } 469 }
490 470
491 // static 471 // static
492 size_t AthenaStartPageView::GetMaxIconNumForTest() { 472 size_t AthenaStartPageView::GetMaxIconNumForTest() {
493 return kMaxIconNum; 473 return kMaxIconNum;
494 } 474 }
495 475
496 } // namespace athena 476 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/athena_start_page_view.h ('k') | athena/home/home_card_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698