Chromium Code Reviews| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
| 9 #include "ui/app_list/app_list_item.h" | 9 #include "ui/app_list/app_list_item.h" |
| 10 #include "ui/app_list/app_list_model.h" | 10 #include "ui/app_list/app_list_model.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 } | 225 } |
| 226 | 226 |
| 227 void StartPageView::Reset() { | 227 void StartPageView::Reset() { |
| 228 tiles_container_->Update(); | 228 tiles_container_->Update(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void StartPageView::UpdateForTesting() { | 231 void StartPageView::UpdateForTesting() { |
| 232 tiles_container_->Update(); | 232 tiles_container_->Update(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void StartPageView::OpenCustomLauncherPage() { | |
| 236 // Switch to the custom page. | |
| 237 ContentsView* contents_view = app_list_main_view_->contents_view(); | |
| 238 int custom_page_index = contents_view->GetPageIndexForState( | |
| 239 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); | |
| 240 contents_view->SetActivePage(custom_page_index); | |
| 241 } | |
| 242 | |
| 235 const std::vector<SearchResultTileItemView*>& StartPageView::tile_views() | 243 const std::vector<SearchResultTileItemView*>& StartPageView::tile_views() |
| 236 const { | 244 const { |
| 237 return tiles_container_->tile_views(); | 245 return tiles_container_->tile_views(); |
| 238 } | 246 } |
| 239 | 247 |
| 240 TileItemView* StartPageView::all_apps_button() const { | 248 TileItemView* StartPageView::all_apps_button() const { |
| 241 return tiles_container_->all_apps_button(); | 249 return tiles_container_->all_apps_button(); |
| 242 } | 250 } |
| 243 | 251 |
| 244 void StartPageView::OnShow() { | 252 void StartPageView::OnShow() { |
| 245 UpdateCustomPageClickzoneVisibility(); | |
| 246 tiles_container_->Update(); | 253 tiles_container_->Update(); |
| 247 tiles_container_->ClearSelectedIndex(); | 254 tiles_container_->ClearSelectedIndex(); |
| 248 } | 255 } |
| 249 | 256 |
| 250 void StartPageView::OnHide() { | |
| 251 UpdateCustomPageClickzoneVisibility(); | |
| 252 } | |
| 253 | |
| 254 void StartPageView::Layout() { | 257 void StartPageView::Layout() { |
| 255 gfx::Rect bounds(GetContentsBounds()); | 258 gfx::Rect bounds(GetContentsBounds()); |
| 256 bounds.set_height(instant_container_->GetHeightForWidth(bounds.width())); | 259 bounds.set_height(instant_container_->GetHeightForWidth(bounds.width())); |
| 257 instant_container_->SetBoundsRect(bounds); | 260 instant_container_->SetBoundsRect(bounds); |
| 258 | 261 |
| 259 // Tiles begin where the instant container ends. | 262 // Tiles begin where the instant container ends. |
| 260 bounds.set_y(bounds.bottom()); | 263 bounds.set_y(bounds.bottom()); |
| 261 bounds.set_height(tiles_container_->GetHeightForWidth(bounds.width())); | 264 bounds.set_height(tiles_container_->GetHeightForWidth(bounds.width())); |
| 262 tiles_container_->SetBoundsRect(bounds); | 265 tiles_container_->SetBoundsRect(bounds); |
| 263 } | 266 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 | 302 |
| 300 int selection_index = selected_index + dir; | 303 int selection_index = selected_index + dir; |
| 301 if (tiles_container_->IsValidSelectionIndex(selection_index)) { | 304 if (tiles_container_->IsValidSelectionIndex(selection_index)) { |
| 302 tiles_container_->SetSelectedIndex(selection_index); | 305 tiles_container_->SetSelectedIndex(selection_index); |
| 303 return true; | 306 return true; |
| 304 } | 307 } |
| 305 | 308 |
| 306 return false; | 309 return false; |
| 307 } | 310 } |
| 308 | 311 |
| 312 bool StartPageView::OnMousePressed(const ui::MouseEvent& event) { | |
| 313 ContentsView* contents_view = app_list_main_view_->contents_view(); | |
| 314 if (!contents_view->GetCustomPageCollapsedBounds().Contains(event.location())) | |
| 315 return false; | |
| 316 | |
| 317 OpenCustomLauncherPage(); | |
| 318 return true; | |
| 319 } | |
| 320 | |
| 321 bool StartPageView::OnMouseWheel(const ui::MouseWheelEvent& event) { | |
| 322 if (event.y_offset() > 0) { | |
|
calamity
2015/02/12 04:32:24
I don't know if we want mousewheel/gesture everywh
tapted
2015/02/13 04:18:41
Done.
| |
| 323 OpenCustomLauncherPage(); | |
| 324 return true; | |
| 325 } | |
| 326 return false; | |
| 327 } | |
| 328 | |
| 329 void StartPageView::OnGestureEvent(ui::GestureEvent* event) { | |
| 330 if (event->details().scroll_y() > 0) | |
| 331 OpenCustomLauncherPage(); | |
| 332 } | |
|
calamity
2015/02/12 04:32:24
I think these all need to be gated by
app_list_ma
tapted
2015/02/13 04:18:41
Done.
| |
| 333 | |
| 309 gfx::Rect StartPageView::GetSearchBoxBounds() const { | 334 gfx::Rect StartPageView::GetSearchBoxBounds() const { |
| 310 return search_box_spacer_view_->bounds(); | 335 return search_box_spacer_view_->bounds(); |
| 311 } | 336 } |
| 312 | 337 |
| 313 void StartPageView::UpdateCustomPageClickzoneVisibility() { | |
| 314 // This can get called before InitWidgets(), so we cannot guarantee that | |
| 315 // custom_page_clickzone_ will not be null. | |
| 316 views::Widget* custom_page_clickzone = | |
| 317 app_list_main_view_->GetCustomPageClickzone(); | |
| 318 if (!custom_page_clickzone) | |
| 319 return; | |
| 320 | |
| 321 if (app_list_main_view_->contents_view()->ShouldShowCustomPageClickzone()) { | |
| 322 custom_page_clickzone->ShowInactive(); | |
| 323 return; | |
| 324 } | |
| 325 | |
| 326 custom_page_clickzone->Hide(); | |
| 327 } | |
| 328 | |
| 329 TileItemView* StartPageView::GetTileItemView(size_t index) { | 338 TileItemView* StartPageView::GetTileItemView(size_t index) { |
| 330 return tiles_container_->GetTileItemView(index); | 339 return tiles_container_->GetTileItemView(index); |
| 331 } | 340 } |
| 332 | 341 |
| 333 } // namespace app_list | 342 } // namespace app_list |
| OLD | NEW |