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

Side by Side Diff: ui/app_list/views/start_page_view.cc

Issue 2952303002: cros: add SUGGESTED APPS indicator to start page (Closed)
Patch Set: include Created 3 years, 6 months 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 | « ui/app_list/views/start_page_view.h ('k') | ui/strings/ui_strings.grd » ('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 "ui/app_list/views/start_page_view.h" 5 #include "ui/app_list/views/start_page_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "ui/accessibility/ax_node_data.h" 14 #include "ui/accessibility/ax_node_data.h"
15 #include "ui/app_list/app_list_constants.h" 15 #include "ui/app_list/app_list_constants.h"
16 #include "ui/app_list/app_list_features.h" 16 #include "ui/app_list/app_list_features.h"
17 #include "ui/app_list/app_list_item.h" 17 #include "ui/app_list/app_list_item.h"
18 #include "ui/app_list/app_list_model.h" 18 #include "ui/app_list/app_list_model.h"
19 #include "ui/app_list/app_list_switches.h" 19 #include "ui/app_list/app_list_switches.h"
20 #include "ui/app_list/app_list_view_delegate.h" 20 #include "ui/app_list/app_list_view_delegate.h"
21 #include "ui/app_list/search_result.h" 21 #include "ui/app_list/search_result.h"
22 #include "ui/app_list/views/all_apps_tile_item_view.h" 22 #include "ui/app_list/views/all_apps_tile_item_view.h"
23 #include "ui/app_list/views/app_list_main_view.h" 23 #include "ui/app_list/views/app_list_main_view.h"
24 #include "ui/app_list/views/contents_view.h" 24 #include "ui/app_list/views/contents_view.h"
25 #include "ui/app_list/views/custom_launcher_page_view.h" 25 #include "ui/app_list/views/custom_launcher_page_view.h"
26 #include "ui/app_list/views/indicator_chip_view.h"
26 #include "ui/app_list/views/search_box_view.h" 27 #include "ui/app_list/views/search_box_view.h"
27 #include "ui/app_list/views/search_result_container_view.h" 28 #include "ui/app_list/views/search_result_container_view.h"
28 #include "ui/app_list/views/search_result_tile_item_view.h" 29 #include "ui/app_list/views/search_result_tile_item_view.h"
29 #include "ui/app_list/views/tile_item_view.h" 30 #include "ui/app_list/views/tile_item_view.h"
31 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/geometry/insets.h" 33 #include "ui/gfx/geometry/insets.h"
34 #include "ui/strings/grit/ui_strings.h"
32 #include "ui/views/background.h" 35 #include "ui/views/background.h"
33 #include "ui/views/controls/image_view.h" 36 #include "ui/views/controls/image_view.h"
34 #include "ui/views/controls/label.h" 37 #include "ui/views/controls/label.h"
35 #include "ui/views/controls/textfield/textfield.h" 38 #include "ui/views/controls/textfield/textfield.h"
36 #include "ui/views/layout/box_layout.h" 39 #include "ui/views/layout/box_layout.h"
37 #include "ui/views/layout/grid_layout.h" 40 #include "ui/views/layout/grid_layout.h"
38 #include "ui/views/widget/widget.h" 41 #include "ui/views/widget/widget.h"
39 42
40 namespace app_list { 43 namespace app_list {
41 44
42 namespace { 45 namespace {
43 46
44 // Layout constants. 47 // Layout constants.
48 constexpr int kSearchBoxTopPadding = 24;
45 constexpr int kInstantContainerSpacing = 24; 49 constexpr int kInstantContainerSpacing = 24;
46 constexpr int kSearchBoxAndTilesSpacing = 35; 50 constexpr int kSearchBoxAndTilesSpacing = 35;
51 constexpr int kSearchBoxAndIndicatorSpacing = 21;
47 constexpr int kStartPageSearchBoxWidth = 480; 52 constexpr int kStartPageSearchBoxWidth = 480;
53 constexpr int kStartPageSearchBoxWidthFullscreen = 544;
48 54
49 // WebView constants. 55 // WebView constants.
50 constexpr int kWebViewWidth = 700; 56 constexpr int kWebViewWidth = 700;
51 constexpr int kWebViewHeight = 224; 57 constexpr int kWebViewHeight = 224;
52 58
53 // Tile container constants. 59 // Tile container constants.
54 constexpr int kTileSpacing = 7; 60 constexpr int kTileSpacing = 7;
55 constexpr int kNumStartPageTilesCols = 5; 61 constexpr int kNumStartPageTilesCols = 5;
56 constexpr int kTilesHorizontalMarginLeft = 145; 62 constexpr int kTilesHorizontalMarginLeft = 145;
57 constexpr int kCenterColumnOfStartPageAppGrid = 3; 63 constexpr int kCenterColumnOfStartPageAppGrid = 3;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 : app_list_main_view_(app_list_main_view), 284 : app_list_main_view_(app_list_main_view),
279 view_delegate_(view_delegate), 285 view_delegate_(view_delegate),
280 search_box_spacer_view_(new View()), 286 search_box_spacer_view_(new View()),
281 instant_container_(new views::View), 287 instant_container_(new views::View),
282 custom_launcher_page_background_(new CustomLauncherPageBackgroundView( 288 custom_launcher_page_background_(new CustomLauncherPageBackgroundView(
283 view_delegate_->GetModel()->custom_launcher_page_name())), 289 view_delegate_->GetModel()->custom_launcher_page_name())),
284 tiles_container_(new StartPageTilesContainer( 290 tiles_container_(new StartPageTilesContainer(
285 app_list_main_view->contents_view(), 291 app_list_main_view->contents_view(),
286 new AllAppsTileItemView(app_list_main_view_->contents_view(), 292 new AllAppsTileItemView(app_list_main_view_->contents_view(),
287 app_list_view), 293 app_list_view),
288 view_delegate)) { 294 view_delegate)),
295 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) {
289 search_box_spacer_view_->SetPreferredSize(gfx::Size( 296 search_box_spacer_view_->SetPreferredSize(gfx::Size(
290 kStartPageSearchBoxWidth, 297 is_fullscreen_app_list_enabled_ ? kStartPageSearchBoxWidthFullscreen
298 : kStartPageSearchBoxWidth,
291 app_list_main_view->search_box_view()->GetPreferredSize().height())); 299 app_list_main_view->search_box_view()->GetPreferredSize().height()));
292 300
293 // The view containing the start page WebContents and SearchBoxSpacerView. 301 // The view containing the start page WebContents and SearchBoxSpacerView.
294 InitInstantContainer(); 302 InitInstantContainer();
295 AddChildView(instant_container_); 303 AddChildView(instant_container_);
296 304
305 if (is_fullscreen_app_list_enabled_) {
306 indicator_ = new IndicatorChipView(
307 l10n_util::GetStringUTF16(IDS_SUGGESTED_APPS_INDICATOR));
308 AddChildView(indicator_);
309 }
310
297 // The view containing the start page tiles. 311 // The view containing the start page tiles.
298 AddChildView(tiles_container_); 312 AddChildView(tiles_container_);
299 AddChildView(custom_launcher_page_background_); 313 AddChildView(custom_launcher_page_background_);
300 314
301 tiles_container_->SetResults(view_delegate_->GetModel()->results()); 315 tiles_container_->SetResults(view_delegate_->GetModel()->results());
302 } 316 }
303 317
304 StartPageView::~StartPageView() { 318 StartPageView::~StartPageView() = default;
305 }
306 319
307 void StartPageView::InitInstantContainer() { 320 void StartPageView::InitInstantContainer() {
308 views::BoxLayout* instant_layout_manager = new views::BoxLayout( 321 views::BoxLayout* instant_layout_manager = new views::BoxLayout(
309 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing); 322 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing);
310 instant_layout_manager->set_inside_border_insets( 323 if (is_fullscreen_app_list_enabled_) {
311 gfx::Insets(0, 0, kSearchBoxAndTilesSpacing, 0)); 324 instant_layout_manager->set_inside_border_insets(
325 gfx::Insets(kSearchBoxTopPadding, 0, kSearchBoxAndIndicatorSpacing, 0));
326 } else {
327 instant_layout_manager->set_inside_border_insets(
328 gfx::Insets(0, 0, kSearchBoxAndTilesSpacing, 0));
329 }
312 instant_layout_manager->set_main_axis_alignment( 330 instant_layout_manager->set_main_axis_alignment(
313 views::BoxLayout::MAIN_AXIS_ALIGNMENT_END); 331 views::BoxLayout::MAIN_AXIS_ALIGNMENT_END);
314 instant_layout_manager->set_cross_axis_alignment( 332 instant_layout_manager->set_cross_axis_alignment(
315 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 333 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
316 instant_container_->SetLayoutManager(instant_layout_manager); 334 instant_container_->SetLayoutManager(instant_layout_manager);
317 335
318 // Create the view for the Google Doodle if the fullscreen launcher is not 336 // Create the view for the Google Doodle if the fullscreen launcher is not
319 // enabled. 337 // enabled.
320 if (!features::IsFullscreenAppListEnabled()) { 338 if (!is_fullscreen_app_list_enabled_) {
321 views::View* web_view = view_delegate_->CreateStartPageWebView( 339 views::View* web_view = view_delegate_->CreateStartPageWebView(
322 gfx::Size(kWebViewWidth, kWebViewHeight)); 340 gfx::Size(kWebViewWidth, kWebViewHeight));
323 341
324 if (web_view) { 342 if (web_view) {
325 web_view->SetFocusBehavior(FocusBehavior::NEVER); 343 web_view->SetFocusBehavior(FocusBehavior::NEVER);
326 instant_container_->AddChildView(web_view); 344 instant_container_->AddChildView(web_view);
327 } 345 }
328 } 346 }
329 347
330 instant_container_->AddChildView(search_box_spacer_view_); 348 instant_container_->AddChildView(search_box_spacer_view_);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 gfx::Rect StartPageView::GetSearchBoxBounds() const { 404 gfx::Rect StartPageView::GetSearchBoxBounds() const {
387 return search_box_spacer_view_->bounds() + 405 return search_box_spacer_view_->bounds() +
388 GetPageBoundsForState(AppListModel::STATE_START).OffsetFromOrigin(); 406 GetPageBoundsForState(AppListModel::STATE_START).OffsetFromOrigin();
389 } 407 }
390 408
391 void StartPageView::Layout() { 409 void StartPageView::Layout() {
392 gfx::Rect bounds(GetContentsBounds()); 410 gfx::Rect bounds(GetContentsBounds());
393 bounds.set_height(instant_container_->GetHeightForWidth(bounds.width())); 411 bounds.set_height(instant_container_->GetHeightForWidth(bounds.width()));
394 instant_container_->SetBoundsRect(bounds); 412 instant_container_->SetBoundsRect(bounds);
395 413
396 // Tiles begin where the instant container ends. 414 // For old launcher, tiles begin where the instant container ends; for
415 // fullscreen app list launcher, tiles begin where the |indicator_| ends.
397 bounds.set_y(bounds.bottom()); 416 bounds.set_y(bounds.bottom());
417 if (indicator_) {
418 gfx::Rect indicator_rect(bounds);
419 indicator_rect.Offset(
420 (indicator_rect.width() - indicator_->GetPreferredSize().width()) / 2,
421 0);
422 indicator_->SetBoundsRect(indicator_rect);
423 bounds.Inset(0, indicator_->GetPreferredSize().height(), 0, 0);
424 }
398 bounds.set_height(tiles_container_->GetHeightForWidth(bounds.width())); 425 bounds.set_height(tiles_container_->GetHeightForWidth(bounds.width()));
399 tiles_container_->SetBoundsRect(bounds); 426 tiles_container_->SetBoundsRect(bounds);
400 427
401 CustomLauncherPageView* custom_launcher_page_view = 428 CustomLauncherPageView* custom_launcher_page_view =
402 app_list_main_view_->contents_view()->custom_page_view(); 429 app_list_main_view_->contents_view()->custom_page_view();
403 if (!custom_launcher_page_view) 430 if (!custom_launcher_page_view)
404 return; 431 return;
405 432
406 bounds = app_list_main_view_->contents_view() 433 bounds = app_list_main_view_->contents_view()
407 ->custom_page_view() 434 ->custom_page_view()
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 // is enabled). 563 // is enabled).
537 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) 564 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0)
538 MaybeOpenCustomLauncherPage(); 565 MaybeOpenCustomLauncherPage();
539 } 566 }
540 567
541 TileItemView* StartPageView::GetTileItemView(size_t index) { 568 TileItemView* StartPageView::GetTileItemView(size_t index) {
542 return tiles_container_->GetTileItemView(index); 569 return tiles_container_->GetTileItemView(index);
543 } 570 }
544 571
545 } // namespace app_list 572 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/start_page_view.h ('k') | ui/strings/ui_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698