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

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

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: Removed header include in shell.h that was causing gn check failure. 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') | no next file » | 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_item.h" 17 #include "ui/app_list/app_list_item.h"
17 #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"
18 #include "ui/app_list/app_list_view_delegate.h" 20 #include "ui/app_list/app_list_view_delegate.h"
19 #include "ui/app_list/search_result.h" 21 #include "ui/app_list/search_result.h"
20 #include "ui/app_list/views/all_apps_tile_item_view.h" 22 #include "ui/app_list/views/all_apps_tile_item_view.h"
21 #include "ui/app_list/views/app_list_main_view.h" 23 #include "ui/app_list/views/app_list_main_view.h"
22 #include "ui/app_list/views/contents_view.h" 24 #include "ui/app_list/views/contents_view.h"
23 #include "ui/app_list/views/custom_launcher_page_view.h" 25 #include "ui/app_list/views/custom_launcher_page_view.h"
24 #include "ui/app_list/views/search_box_view.h" 26 #include "ui/app_list/views/search_box_view.h"
25 #include "ui/app_list/views/search_result_container_view.h" 27 #include "ui/app_list/views/search_result_container_view.h"
26 #include "ui/app_list/views/search_result_tile_item_view.h" 28 #include "ui/app_list/views/search_result_tile_item_view.h"
27 #include "ui/app_list/views/tile_item_view.h" 29 #include "ui/app_list/views/tile_item_view.h"
(...skipping 17 matching lines...) Expand all
45 constexpr int kStartPageSearchBoxWidth = 480; 47 constexpr int kStartPageSearchBoxWidth = 480;
46 48
47 // WebView constants. 49 // WebView constants.
48 constexpr int kWebViewWidth = 700; 50 constexpr int kWebViewWidth = 700;
49 constexpr int kWebViewHeight = 224; 51 constexpr int kWebViewHeight = 224;
50 52
51 // Tile container constants. 53 // Tile container constants.
52 constexpr int kTileSpacing = 7; 54 constexpr int kTileSpacing = 7;
53 constexpr int kNumStartPageTilesCols = 5; 55 constexpr int kNumStartPageTilesCols = 5;
54 constexpr int kTilesHorizontalMarginLeft = 145; 56 constexpr int kTilesHorizontalMarginLeft = 145;
57 constexpr int kCenterColumnOfStartPageAppGrid = 3;
55 58
56 constexpr int kLauncherPageBackgroundWidth = 400; 59 constexpr int kLauncherPageBackgroundWidth = 400;
57 60
58 } // namespace 61 } // namespace
59 62
60 class CustomLauncherPageBackgroundView : public views::View { 63 class CustomLauncherPageBackgroundView : public views::View {
61 public: 64 public:
62 explicit CustomLauncherPageBackgroundView( 65 explicit CustomLauncherPageBackgroundView(
63 const std::string& custom_launcher_page_name) 66 const std::string& custom_launcher_page_name)
64 : selected_(false), 67 : selected_(false),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 StartPageView::StartPageTilesContainer::StartPageTilesContainer( 133 StartPageView::StartPageTilesContainer::StartPageTilesContainer(
131 ContentsView* contents_view, 134 ContentsView* contents_view,
132 AllAppsTileItemView* all_apps_button, 135 AllAppsTileItemView* all_apps_button,
133 AppListViewDelegate* view_delegate) 136 AppListViewDelegate* view_delegate)
134 : contents_view_(contents_view), 137 : contents_view_(contents_view),
135 view_delegate_(view_delegate), 138 view_delegate_(view_delegate),
136 all_apps_button_(all_apps_button) { 139 all_apps_button_(all_apps_button) {
137 SetBackground(views::CreateSolidBackground(kLabelBackgroundColor)); 140 SetBackground(views::CreateSolidBackground(kLabelBackgroundColor));
138 all_apps_button_->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW); 141 all_apps_button_->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW);
139 all_apps_button_->SetParentBackgroundColor(kLabelBackgroundColor); 142 all_apps_button_->SetParentBackgroundColor(kLabelBackgroundColor);
140 CreateAppsGrid(kNumStartPageTiles); 143
144 CreateAppsGrid(features::IsFullscreenAppListEnabled()
145 ? kNumStartPageTilesFullscreen
146 : kNumStartPageTiles);
141 } 147 }
142 148
143 StartPageView::StartPageTilesContainer::~StartPageTilesContainer() { 149 StartPageView::StartPageTilesContainer::~StartPageTilesContainer() {
144 } 150 }
145 151
146 TileItemView* StartPageView::StartPageTilesContainer::GetTileItemView( 152 TileItemView* StartPageView::StartPageTilesContainer::GetTileItemView(
147 int index) { 153 int index) {
148 DCHECK_GT(num_results(), index); 154 DCHECK_GT(num_results(), index);
149 if (index == num_results() - 1) 155 if (index == num_results() - 1)
150 return all_apps_button_; 156 return all_apps_button_;
(...skipping 13 matching lines...) Expand all
164 170
165 std::vector<SearchResult*> display_results = 171 std::vector<SearchResult*> display_results =
166 AppListModel::FilterSearchResultsByDisplayType( 172 AppListModel::FilterSearchResultsByDisplayType(
167 results(), SearchResult::DISPLAY_RECOMMENDATION, kNumStartPageTiles); 173 results(), SearchResult::DISPLAY_RECOMMENDATION, kNumStartPageTiles);
168 if (display_results.size() != search_result_tile_views_.size()) { 174 if (display_results.size() != search_result_tile_views_.size()) {
169 // We should recreate the grid layout in this case. 175 // We should recreate the grid layout in this case.
170 for (size_t i = 0; i < search_result_tile_views_.size(); ++i) 176 for (size_t i = 0; i < search_result_tile_views_.size(); ++i)
171 delete search_result_tile_views_[i]; 177 delete search_result_tile_views_[i];
172 search_result_tile_views_.clear(); 178 search_result_tile_views_.clear();
173 RemoveChildView(all_apps_button_); 179 RemoveChildView(all_apps_button_);
174 CreateAppsGrid(std::min(kNumStartPageTiles, display_results.size())); 180
181 CreateAppsGrid(features::IsFullscreenAppListEnabled()
182 ? kNumStartPageTilesFullscreen
183 : std::min(kNumStartPageTiles, display_results.size()));
175 } 184 }
176 185
177 // Update the tile item results. 186 // Update the tile item results.
178 for (size_t i = 0; i < search_result_tile_views_.size(); ++i) { 187 for (size_t i = 0; i < search_result_tile_views_.size(); ++i) {
179 SearchResult* item = nullptr; 188 SearchResult* item = nullptr;
180 if (i < display_results.size()) 189 if (i < display_results.size())
181 item = display_results[i]; 190 item = display_results[i];
182 search_result_tile_views_[i]->SetSearchResult(item); 191 search_result_tile_views_[i]->SetSearchResult(item);
183 search_result_tile_views_[i]->SetEnabled(true); 192 search_result_tile_views_[i]->SetEnabled(true);
184 } 193 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 new SearchResultTileItemView(this, view_delegate_); 244 new SearchResultTileItemView(this, view_delegate_);
236 if (i % kNumStartPageTilesCols == 0) 245 if (i % kNumStartPageTilesCols == 0)
237 tiles_layout_manager->StartRow(0, 0); 246 tiles_layout_manager->StartRow(0, 0);
238 tiles_layout_manager->AddView(tile_item); 247 tiles_layout_manager->AddView(tile_item);
239 AddChildView(tile_item); 248 AddChildView(tile_item);
240 tile_item->SetParentBackgroundColor(kLabelBackgroundColor); 249 tile_item->SetParentBackgroundColor(kLabelBackgroundColor);
241 tile_item->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW); 250 tile_item->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW);
242 search_result_tile_views_.emplace_back(tile_item); 251 search_result_tile_views_.emplace_back(tile_item);
243 } 252 }
244 253
245 // Also add a special "all apps" button to the end of the container.
246 all_apps_button_->UpdateIcon(); 254 all_apps_button_->UpdateIcon();
247 if (i % kNumStartPageTilesCols == 0) 255 if (features::IsFullscreenAppListEnabled()) {
256 // Also add a special "all apps" button to the middle of the next row of the
257 // container.
248 tiles_layout_manager->StartRow(0, 0); 258 tiles_layout_manager->StartRow(0, 0);
259 tiles_layout_manager->SkipColumns(kCenterColumnOfStartPageAppGrid);
260 } else {
261 // Also add a special "all apps" button to the end of the next row of the
262 // container.
263 if (i % kNumStartPageTilesCols == 0)
264 tiles_layout_manager->StartRow(0, 0);
265 }
266
249 tiles_layout_manager->AddView(all_apps_button_); 267 tiles_layout_manager->AddView(all_apps_button_);
250 AddChildView(all_apps_button_); 268 AddChildView(all_apps_button_);
251 } 269 }
252 270
253 //////////////////////////////////////////////////////////////////////////////// 271 ////////////////////////////////////////////////////////////////////////////////
254 // StartPageView implementation: 272 // StartPageView implementation:
255 StartPageView::StartPageView(AppListMainView* app_list_main_view, 273 StartPageView::StartPageView(AppListMainView* app_list_main_view,
256 AppListViewDelegate* view_delegate) 274 AppListViewDelegate* view_delegate,
275 AppListView* app_list_view)
257 : app_list_main_view_(app_list_main_view), 276 : app_list_main_view_(app_list_main_view),
258 view_delegate_(view_delegate), 277 view_delegate_(view_delegate),
259 search_box_spacer_view_(new View()), 278 search_box_spacer_view_(new View()),
260 instant_container_(new views::View), 279 instant_container_(new views::View),
261 custom_launcher_page_background_(new CustomLauncherPageBackgroundView( 280 custom_launcher_page_background_(new CustomLauncherPageBackgroundView(
262 view_delegate_->GetModel()->custom_launcher_page_name())), 281 view_delegate_->GetModel()->custom_launcher_page_name())),
263 tiles_container_(new StartPageTilesContainer( 282 tiles_container_(new StartPageTilesContainer(
264 app_list_main_view->contents_view(), 283 app_list_main_view->contents_view(),
265 new AllAppsTileItemView(app_list_main_view_->contents_view()), 284 new AllAppsTileItemView(app_list_main_view_->contents_view(),
285 app_list_view),
266 view_delegate)) { 286 view_delegate)) {
267 search_box_spacer_view_->SetPreferredSize(gfx::Size( 287 search_box_spacer_view_->SetPreferredSize(gfx::Size(
268 kStartPageSearchBoxWidth, 288 kStartPageSearchBoxWidth,
269 app_list_main_view->search_box_view()->GetPreferredSize().height())); 289 app_list_main_view->search_box_view()->GetPreferredSize().height()));
270 290
271 // The view containing the start page WebContents and SearchBoxSpacerView. 291 // The view containing the start page WebContents and SearchBoxSpacerView.
272 InitInstantContainer(); 292 InitInstantContainer();
273 AddChildView(instant_container_); 293 AddChildView(instant_container_);
274 294
275 // The view containing the start page tiles. 295 // The view containing the start page tiles.
276 AddChildView(tiles_container_); 296 AddChildView(tiles_container_);
277
278 AddChildView(custom_launcher_page_background_); 297 AddChildView(custom_launcher_page_background_);
279 298
280 tiles_container_->SetResults(view_delegate_->GetModel()->results()); 299 tiles_container_->SetResults(view_delegate_->GetModel()->results());
281 } 300 }
282 301
283 StartPageView::~StartPageView() { 302 StartPageView::~StartPageView() {
284 } 303 }
285 304
286 void StartPageView::InitInstantContainer() { 305 void StartPageView::InitInstantContainer() {
287 views::BoxLayout* instant_layout_manager = new views::BoxLayout( 306 views::BoxLayout* instant_layout_manager = new views::BoxLayout(
288 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing); 307 views::BoxLayout::kVertical, gfx::Insets(), kInstantContainerSpacing);
289 instant_layout_manager->set_inside_border_insets( 308 instant_layout_manager->set_inside_border_insets(
290 gfx::Insets(0, 0, kSearchBoxAndTilesSpacing, 0)); 309 gfx::Insets(0, 0, kSearchBoxAndTilesSpacing, 0));
291 instant_layout_manager->set_main_axis_alignment( 310 instant_layout_manager->set_main_axis_alignment(
292 views::BoxLayout::MAIN_AXIS_ALIGNMENT_END); 311 views::BoxLayout::MAIN_AXIS_ALIGNMENT_END);
293 instant_layout_manager->set_cross_axis_alignment( 312 instant_layout_manager->set_cross_axis_alignment(
294 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 313 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
295 instant_container_->SetLayoutManager(instant_layout_manager); 314 instant_container_->SetLayoutManager(instant_layout_manager);
296 315
297 views::View* web_view = view_delegate_->CreateStartPageWebView( 316 // Create the view for the Google Doodle if the fullscreen launcher is not
298 gfx::Size(kWebViewWidth, kWebViewHeight)); 317 // enabled.
299 if (web_view) { 318 if (!features::IsFullscreenAppListEnabled()) {
300 web_view->SetFocusBehavior(FocusBehavior::NEVER); 319 views::View* web_view = view_delegate_->CreateStartPageWebView(
301 instant_container_->AddChildView(web_view); 320 gfx::Size(kWebViewWidth, kWebViewHeight));
321
322 if (web_view) {
323 web_view->SetFocusBehavior(FocusBehavior::NEVER);
324 instant_container_->AddChildView(web_view);
325 }
302 } 326 }
303 327
304 instant_container_->AddChildView(search_box_spacer_view_); 328 instant_container_->AddChildView(search_box_spacer_view_);
305 } 329 }
306 330
307 void StartPageView::MaybeOpenCustomLauncherPage() { 331 void StartPageView::MaybeOpenCustomLauncherPage() {
308 // Switch to the custom page. 332 // Switch to the custom page.
309 ContentsView* contents_view = app_list_main_view_->contents_view(); 333 ContentsView* contents_view = app_list_main_view_->contents_view();
310 if (!app_list_main_view_->ShouldShowCustomLauncherPage()) 334 if (!app_list_main_view_->ShouldShowCustomLauncherPage())
311 return; 335 return;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // is enabled). 534 // is enabled).
511 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) 535 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0)
512 MaybeOpenCustomLauncherPage(); 536 MaybeOpenCustomLauncherPage();
513 } 537 }
514 538
515 TileItemView* StartPageView::GetTileItemView(size_t index) { 539 TileItemView* StartPageView::GetTileItemView(size_t index) {
516 return tiles_container_->GetTileItemView(index); 540 return tiles_container_->GetTileItemView(index);
517 } 541 }
518 542
519 } // namespace app_list 543 } // namespace app_list
OLDNEW
« no previous file with comments | « 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