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

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

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