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

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

Issue 2959943003: Replace AllAppsTileItemView with ArrowExpandView (Closed)
Patch Set: Created 3 years, 5 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
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/expand_arrow_view.h"
26 #include "ui/app_list/views/indicator_chip_view.h" 27 #include "ui/app_list/views/indicator_chip_view.h"
27 #include "ui/app_list/views/search_box_view.h" 28 #include "ui/app_list/views/search_box_view.h"
28 #include "ui/app_list/views/search_result_container_view.h" 29 #include "ui/app_list/views/search_result_container_view.h"
29 #include "ui/app_list/views/search_result_tile_item_view.h" 30 #include "ui/app_list/views/search_result_tile_item_view.h"
30 #include "ui/app_list/views/tile_item_view.h" 31 #include "ui/app_list/views/tile_item_view.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/gfx/canvas.h" 33 #include "ui/gfx/canvas.h"
33 #include "ui/gfx/geometry/insets.h" 34 #include "ui/gfx/geometry/insets.h"
34 #include "ui/strings/grit/ui_strings.h" 35 #include "ui/strings/grit/ui_strings.h"
35 #include "ui/views/background.h" 36 #include "ui/views/background.h"
(...skipping 17 matching lines...) Expand all
53 constexpr int kStartPageSearchBoxWidthFullscreen = 544; 54 constexpr int kStartPageSearchBoxWidthFullscreen = 544;
54 55
55 // WebView constants. 56 // WebView constants.
56 constexpr int kWebViewWidth = 700; 57 constexpr int kWebViewWidth = 700;
57 constexpr int kWebViewHeight = 224; 58 constexpr int kWebViewHeight = 224;
58 59
59 // Tile container constants. 60 // Tile container constants.
60 constexpr int kTileSpacing = 7; 61 constexpr int kTileSpacing = 7;
61 constexpr int kNumStartPageTilesCols = 5; 62 constexpr int kNumStartPageTilesCols = 5;
62 constexpr int kTilesHorizontalMarginLeft = 145; 63 constexpr int kTilesHorizontalMarginLeft = 145;
63 constexpr int kCenterColumnOfStartPageAppGrid = 3; 64 constexpr int kExpandArrowTopPadding = 28;
64 65
65 constexpr int kLauncherPageBackgroundWidth = 400; 66 constexpr int kLauncherPageBackgroundWidth = 400;
66 67
67 } // namespace 68 } // namespace
68 69
69 class CustomLauncherPageBackgroundView : public views::View { 70 class CustomLauncherPageBackgroundView : public views::View {
70 public: 71 public:
71 explicit CustomLauncherPageBackgroundView( 72 explicit CustomLauncherPageBackgroundView(
72 const std::string& custom_launcher_page_name) 73 const std::string& custom_launcher_page_name)
73 : selected_(false), 74 : selected_(false),
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 new SearchResultTileItemView(this, view_delegate_); 253 new SearchResultTileItemView(this, view_delegate_);
253 if (i % kNumStartPageTilesCols == 0) 254 if (i % kNumStartPageTilesCols == 0)
254 tiles_layout_manager->StartRow(0, 0); 255 tiles_layout_manager->StartRow(0, 0);
255 tiles_layout_manager->AddView(tile_item); 256 tiles_layout_manager->AddView(tile_item);
256 AddChildView(tile_item); 257 AddChildView(tile_item);
257 tile_item->SetParentBackgroundColor(kLabelBackgroundColor); 258 tile_item->SetParentBackgroundColor(kLabelBackgroundColor);
258 tile_item->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW); 259 tile_item->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW);
259 search_result_tile_views_.emplace_back(tile_item); 260 search_result_tile_views_.emplace_back(tile_item);
260 } 261 }
261 262
262 all_apps_button_->UpdateIcon(); 263 if (!features::IsFullscreenAppListEnabled()) {
263 if (features::IsFullscreenAppListEnabled()) { 264 all_apps_button_->UpdateIcon();
264 // Also add a special "all apps" button to the middle of the next row of the
265 // container.
266 tiles_layout_manager->StartRow(0, 0);
267 tiles_layout_manager->SkipColumns(kCenterColumnOfStartPageAppGrid);
268 } else {
269 // Also add a special "all apps" button to the end of the next row of the 265 // Also add a special "all apps" button to the end of the next row of the
270 // container. 266 // container.
271 if (i % kNumStartPageTilesCols == 0) 267 if (i % kNumStartPageTilesCols == 0)
272 tiles_layout_manager->StartRow(0, 0); 268 tiles_layout_manager->StartRow(0, 0);
269
270 tiles_layout_manager->AddView(all_apps_button_);
271 AddChildView(all_apps_button_);
273 } 272 }
274
275 tiles_layout_manager->AddView(all_apps_button_);
276 AddChildView(all_apps_button_);
277 } 273 }
278 274
279 //////////////////////////////////////////////////////////////////////////////// 275 ////////////////////////////////////////////////////////////////////////////////
280 // StartPageView implementation: 276 // StartPageView implementation:
281 StartPageView::StartPageView(AppListMainView* app_list_main_view, 277 StartPageView::StartPageView(AppListMainView* app_list_main_view,
282 AppListViewDelegate* view_delegate, 278 AppListViewDelegate* view_delegate,
283 AppListView* app_list_view) 279 AppListView* app_list_view)
284 : app_list_main_view_(app_list_main_view), 280 : app_list_main_view_(app_list_main_view),
285 view_delegate_(view_delegate), 281 view_delegate_(view_delegate),
286 search_box_spacer_view_(new View()), 282 search_box_spacer_view_(new View()),
(...skipping 16 matching lines...) Expand all
303 AddChildView(instant_container_); 299 AddChildView(instant_container_);
304 300
305 if (is_fullscreen_app_list_enabled_) { 301 if (is_fullscreen_app_list_enabled_) {
306 indicator_ = new IndicatorChipView( 302 indicator_ = new IndicatorChipView(
307 l10n_util::GetStringUTF16(IDS_SUGGESTED_APPS_INDICATOR)); 303 l10n_util::GetStringUTF16(IDS_SUGGESTED_APPS_INDICATOR));
308 AddChildView(indicator_); 304 AddChildView(indicator_);
309 } 305 }
310 306
311 // The view containing the start page tiles. 307 // The view containing the start page tiles.
312 AddChildView(tiles_container_); 308 AddChildView(tiles_container_);
309 if (is_fullscreen_app_list_enabled_) {
310 expand_arrow_view_ = new ExpandArrowView(
311 app_list_main_view_->contents_view(), app_list_view);
312 AddChildView(expand_arrow_view_);
313 }
313 AddChildView(custom_launcher_page_background_); 314 AddChildView(custom_launcher_page_background_);
314 315
315 tiles_container_->SetResults(view_delegate_->GetModel()->results()); 316 tiles_container_->SetResults(view_delegate_->GetModel()->results());
316 } 317 }
317 318
318 StartPageView::~StartPageView() = default; 319 StartPageView::~StartPageView() = default;
319 320
320 void StartPageView::InitInstantContainer() { 321 void StartPageView::InitInstantContainer() {
321 views::BoxLayout* instant_layout_manager = new views::BoxLayout( 322 views::BoxLayout* instant_layout_manager = new views::BoxLayout(
322 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing); 323 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 gfx::Rect indicator_rect(bounds); 419 gfx::Rect indicator_rect(bounds);
419 indicator_rect.Offset( 420 indicator_rect.Offset(
420 (indicator_rect.width() - indicator_->GetPreferredSize().width()) / 2, 421 (indicator_rect.width() - indicator_->GetPreferredSize().width()) / 2,
421 0); 422 0);
422 indicator_->SetBoundsRect(indicator_rect); 423 indicator_->SetBoundsRect(indicator_rect);
423 bounds.Inset(0, indicator_->GetPreferredSize().height(), 0, 0); 424 bounds.Inset(0, indicator_->GetPreferredSize().height(), 0, 0);
424 } 425 }
425 bounds.set_height(tiles_container_->GetHeightForWidth(bounds.width())); 426 bounds.set_height(tiles_container_->GetHeightForWidth(bounds.width()));
426 tiles_container_->SetBoundsRect(bounds); 427 tiles_container_->SetBoundsRect(bounds);
427 428
429 if (expand_arrow_view_) {
430 gfx::Rect expand_arrow_rect(bounds);
431 int left_right_padding =
432 (bounds.width() - expand_arrow_view_->GetPreferredSize().width()) / 2;
433
434 expand_arrow_rect.Inset(left_right_padding,
435 bounds.height() + kExpandArrowTopPadding,
436 left_right_padding, 0);
437 expand_arrow_rect.set_height(
438 expand_arrow_view_->GetPreferredSize().height());
439 expand_arrow_view_->SetBoundsRect(expand_arrow_rect);
440 }
441
428 CustomLauncherPageView* custom_launcher_page_view = 442 CustomLauncherPageView* custom_launcher_page_view =
429 app_list_main_view_->contents_view()->custom_page_view(); 443 app_list_main_view_->contents_view()->custom_page_view();
430 if (!custom_launcher_page_view) 444 if (!custom_launcher_page_view)
431 return; 445 return;
432 446
433 bounds = app_list_main_view_->contents_view() 447 bounds = app_list_main_view_->contents_view()
434 ->custom_page_view() 448 ->custom_page_view()
435 ->GetCollapsedLauncherPageBounds(); 449 ->GetCollapsedLauncherPageBounds();
436 bounds.Intersect(GetContentsBounds()); 450 bounds.Intersect(GetContentsBounds());
437 bounds.ClampToCenteredSize( 451 bounds.ClampToCenteredSize(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // is enabled). 577 // is enabled).
564 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) 578 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0)
565 MaybeOpenCustomLauncherPage(); 579 MaybeOpenCustomLauncherPage();
566 } 580 }
567 581
568 TileItemView* StartPageView::GetTileItemView(size_t index) { 582 TileItemView* StartPageView::GetTileItemView(size_t index) {
569 return tiles_container_->GetTileItemView(index); 583 return tiles_container_->GetTileItemView(index);
570 } 584 }
571 585
572 } // namespace app_list 586 } // namespace app_list
OLDNEW
« ui/app_list/views/expand_arrow_view.h ('K') | « ui/app_list/views/start_page_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698