| 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/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/suggestions_container_view.h" | 31 #include "ui/app_list/views/suggestions_container_view.h" |
| 31 #include "ui/app_list/views/tile_item_view.h" | 32 #include "ui/app_list/views/tile_item_view.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
| 34 #include "ui/gfx/geometry/insets.h" | 35 #include "ui/gfx/geometry/insets.h" |
| 35 #include "ui/strings/grit/ui_strings.h" | 36 #include "ui/strings/grit/ui_strings.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 49 constexpr int kInstantContainerSpacing = 24; | 50 constexpr int kInstantContainerSpacing = 24; |
| 50 constexpr int kSearchBoxAndTilesSpacing = 35; | 51 constexpr int kSearchBoxAndTilesSpacing = 35; |
| 51 constexpr int kSearchBoxAndIndicatorSpacing = 21; | 52 constexpr int kSearchBoxAndIndicatorSpacing = 21; |
| 52 constexpr int kStartPageSearchBoxWidth = 480; | 53 constexpr int kStartPageSearchBoxWidth = 480; |
| 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 |
| 60 constexpr int kExpandArrowTopPadding = 28; |
| 59 constexpr int kLauncherPageBackgroundWidth = 400; | 61 constexpr int kLauncherPageBackgroundWidth = 400; |
| 60 | 62 |
| 61 } // namespace | 63 } // namespace |
| 62 | 64 |
| 63 class CustomLauncherPageBackgroundView : public views::View { | 65 class CustomLauncherPageBackgroundView : public views::View { |
| 64 public: | 66 public: |
| 65 explicit CustomLauncherPageBackgroundView( | 67 explicit CustomLauncherPageBackgroundView( |
| 66 const std::string& custom_launcher_page_name) | 68 const std::string& custom_launcher_page_name) |
| 67 : selected_(false), | 69 : selected_(false), |
| 68 custom_launcher_page_name_(custom_launcher_page_name) { | 70 custom_launcher_page_name_(custom_launcher_page_name) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 // StartPageView implementation: | 98 // StartPageView implementation: |
| 97 StartPageView::StartPageView(AppListMainView* app_list_main_view, | 99 StartPageView::StartPageView(AppListMainView* app_list_main_view, |
| 98 AppListViewDelegate* view_delegate, | 100 AppListViewDelegate* view_delegate, |
| 99 AppListView* app_list_view) | 101 AppListView* app_list_view) |
| 100 : app_list_main_view_(app_list_main_view), | 102 : app_list_main_view_(app_list_main_view), |
| 101 view_delegate_(view_delegate), | 103 view_delegate_(view_delegate), |
| 102 search_box_spacer_view_(new View()), | 104 search_box_spacer_view_(new View()), |
| 103 instant_container_(new views::View), | 105 instant_container_(new views::View), |
| 104 custom_launcher_page_background_(new CustomLauncherPageBackgroundView( | 106 custom_launcher_page_background_(new CustomLauncherPageBackgroundView( |
| 105 view_delegate_->GetModel()->custom_launcher_page_name())), | 107 view_delegate_->GetModel()->custom_launcher_page_name())), |
| 106 suggestions_container_(new SuggestionsContainerView( | |
| 107 app_list_main_view->contents_view(), | |
| 108 new AllAppsTileItemView(app_list_main_view_->contents_view(), | |
| 109 app_list_view))), | |
| 110 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) { | 108 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) { |
| 109 suggestions_container_ = new SuggestionsContainerView( |
| 110 app_list_main_view->contents_view(), |
| 111 is_fullscreen_app_list_enabled_ |
| 112 ? nullptr |
| 113 : new AllAppsTileItemView(app_list_main_view_->contents_view(), |
| 114 app_list_view)); |
| 115 |
| 111 search_box_spacer_view_->SetPreferredSize(gfx::Size( | 116 search_box_spacer_view_->SetPreferredSize(gfx::Size( |
| 112 is_fullscreen_app_list_enabled_ ? kStartPageSearchBoxWidthFullscreen | 117 is_fullscreen_app_list_enabled_ ? kStartPageSearchBoxWidthFullscreen |
| 113 : kStartPageSearchBoxWidth, | 118 : kStartPageSearchBoxWidth, |
| 114 app_list_main_view->search_box_view()->GetPreferredSize().height())); | 119 app_list_main_view->search_box_view()->GetPreferredSize().height())); |
| 115 | 120 |
| 116 // The view containing the start page WebContents and SearchBoxSpacerView. | 121 // The view containing the start page WebContents and SearchBoxSpacerView. |
| 117 InitInstantContainer(); | 122 InitInstantContainer(); |
| 118 AddChildView(instant_container_); | 123 AddChildView(instant_container_); |
| 119 | 124 |
| 120 if (is_fullscreen_app_list_enabled_) { | 125 if (is_fullscreen_app_list_enabled_) { |
| 121 indicator_ = new IndicatorChipView( | 126 indicator_ = new IndicatorChipView( |
| 122 l10n_util::GetStringUTF16(IDS_SUGGESTED_APPS_INDICATOR)); | 127 l10n_util::GetStringUTF16(IDS_SUGGESTED_APPS_INDICATOR)); |
| 123 AddChildView(indicator_); | 128 AddChildView(indicator_); |
| 124 } | 129 } |
| 125 | 130 |
| 126 // The view containing the start page tiles. | 131 // The view containing the start page tiles. |
| 127 AddChildView(suggestions_container_); | 132 AddChildView(suggestions_container_); |
| 133 if (is_fullscreen_app_list_enabled_) { |
| 134 expand_arrow_view_ = new ExpandArrowView( |
| 135 app_list_main_view_->contents_view(), app_list_view); |
| 136 AddChildView(expand_arrow_view_); |
| 137 } |
| 128 AddChildView(custom_launcher_page_background_); | 138 AddChildView(custom_launcher_page_background_); |
| 129 | 139 |
| 130 suggestions_container_->SetResults(view_delegate_->GetModel()->results()); | 140 suggestions_container_->SetResults(view_delegate_->GetModel()->results()); |
| 131 } | 141 } |
| 132 | 142 |
| 133 StartPageView::~StartPageView() = default; | 143 StartPageView::~StartPageView() = default; |
| 134 | 144 |
| 135 void StartPageView::InitInstantContainer() { | 145 void StartPageView::InitInstantContainer() { |
| 136 views::BoxLayout* instant_layout_manager = new views::BoxLayout( | 146 views::BoxLayout* instant_layout_manager = new views::BoxLayout( |
| 137 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing); | 147 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 bounds.Inset(0, indicator_->GetPreferredSize().height(), 0, 0); | 248 bounds.Inset(0, indicator_->GetPreferredSize().height(), 0, 0); |
| 239 } | 249 } |
| 240 bounds.set_height(suggestions_container_->GetHeightForWidth(bounds.width())); | 250 bounds.set_height(suggestions_container_->GetHeightForWidth(bounds.width())); |
| 241 if (is_fullscreen_app_list_enabled_) { | 251 if (is_fullscreen_app_list_enabled_) { |
| 242 bounds.Offset((bounds.width() - kGridTileWidth) / 2 - | 252 bounds.Offset((bounds.width() - kGridTileWidth) / 2 - |
| 243 (kGridTileWidth + kGridTileSpacing) * 2, | 253 (kGridTileWidth + kGridTileSpacing) * 2, |
| 244 0); | 254 0); |
| 245 } | 255 } |
| 246 suggestions_container_->SetBoundsRect(bounds); | 256 suggestions_container_->SetBoundsRect(bounds); |
| 247 | 257 |
| 258 if (expand_arrow_view_) { |
| 259 gfx::Rect expand_arrow_rect(GetContentsBounds()); |
| 260 int left_right_padding = |
| 261 (bounds.width() - expand_arrow_view_->GetPreferredSize().width()) / 2; |
| 262 |
| 263 expand_arrow_rect.Inset(left_right_padding, 0, left_right_padding, 0); |
| 264 expand_arrow_rect.set_y(bounds.bottom() + kExpandArrowTopPadding); |
| 265 expand_arrow_rect.set_height( |
| 266 expand_arrow_view_->GetPreferredSize().height()); |
| 267 expand_arrow_view_->SetBoundsRect(expand_arrow_rect); |
| 268 } |
| 269 |
| 248 CustomLauncherPageView* custom_launcher_page_view = | 270 CustomLauncherPageView* custom_launcher_page_view = |
| 249 app_list_main_view_->contents_view()->custom_page_view(); | 271 app_list_main_view_->contents_view()->custom_page_view(); |
| 250 if (!custom_launcher_page_view) | 272 if (!custom_launcher_page_view) |
| 251 return; | 273 return; |
| 252 | 274 |
| 253 bounds = app_list_main_view_->contents_view() | 275 bounds = app_list_main_view_->contents_view() |
| 254 ->custom_page_view() | 276 ->custom_page_view() |
| 255 ->GetCollapsedLauncherPageBounds(); | 277 ->GetCollapsedLauncherPageBounds(); |
| 256 bounds.Intersect(GetContentsBounds()); | 278 bounds.Intersect(GetContentsBounds()); |
| 257 bounds.ClampToCenteredSize( | 279 bounds.ClampToCenteredSize( |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // is enabled). | 406 // is enabled). |
| 385 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) | 407 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) |
| 386 MaybeOpenCustomLauncherPage(); | 408 MaybeOpenCustomLauncherPage(); |
| 387 } | 409 } |
| 388 | 410 |
| 389 TileItemView* StartPageView::GetTileItemView(size_t index) { | 411 TileItemView* StartPageView::GetTileItemView(size_t index) { |
| 390 return suggestions_container_->GetTileItemView(index); | 412 return suggestions_container_->GetTileItemView(index); |
| 391 } | 413 } |
| 392 | 414 |
| 393 } // namespace app_list | 415 } // namespace app_list |
| OLD | NEW |