| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/apps_grid_view.h" | 5 #include "ui/app_list/apps_grid_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/app_list/app_list_item_view.h" | 9 #include "ui/app_list/app_list_item_view.h" |
| 10 #include "ui/app_list/pagination_model.h" | 10 #include "ui/app_list/pagination_model.h" |
| 11 #include "ui/base/event.h" |
| 11 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Padding space in pixels for fixed layout. | 16 // Padding space in pixels for fixed layout. |
| 16 const int kLeftRightPadding = 20; | 17 const int kLeftRightPadding = 20; |
| 17 const int kTopPadding = 1; | 18 const int kTopPadding = 1; |
| 18 | 19 |
| 19 // Padding space in pixels between pages. | 20 // Padding space in pixels between pages. |
| 20 const int kPagePadding = 40; | 21 const int kPagePadding = 40; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 tile_slot.Offset(tile_size.width(), 0); | 162 tile_slot.Offset(tile_size.width(), 0); |
| 162 if ((i + 1) % tiles_per_page() == 0) { | 163 if ((i + 1) % tiles_per_page() == 0) { |
| 163 tile_slot.set_origin(grid_rect.origin()); | 164 tile_slot.set_origin(grid_rect.origin()); |
| 164 } else if ((i + 1) % cols_ == 0) { | 165 } else if ((i + 1) % cols_ == 0) { |
| 165 tile_slot.set_x(grid_rect.x()); | 166 tile_slot.set_x(grid_rect.x()); |
| 166 tile_slot.set_y(tile_slot.y() + tile_size.height()); | 167 tile_slot.set_y(tile_slot.y() + tile_size.height()); |
| 167 } | 168 } |
| 168 } | 169 } |
| 169 } | 170 } |
| 170 | 171 |
| 171 bool AppsGridView::OnKeyPressed(const views::KeyEvent& event) { | 172 bool AppsGridView::OnKeyPressed(const ui::KeyEvent& event) { |
| 172 bool handled = false; | 173 bool handled = false; |
| 173 if (selected_item_index_ >= 0) | 174 if (selected_item_index_ >= 0) |
| 174 handled = GetItemViewAtIndex(selected_item_index_)->OnKeyPressed(event); | 175 handled = GetItemViewAtIndex(selected_item_index_)->OnKeyPressed(event); |
| 175 | 176 |
| 176 if (!handled) { | 177 if (!handled) { |
| 177 switch (event.key_code()) { | 178 switch (event.key_code()) { |
| 178 case ui::VKEY_LEFT: | 179 case ui::VKEY_LEFT: |
| 179 SetSelectedItemByIndex(std::max(selected_item_index_ - 1, 0)); | 180 SetSelectedItemByIndex(std::max(selected_item_index_ - 1, 0)); |
| 180 return true; | 181 return true; |
| 181 case ui::VKEY_RIGHT: | 182 case ui::VKEY_RIGHT: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 default: | 213 default: |
| 213 break; | 214 break; |
| 214 } | 215 } |
| 215 } | 216 } |
| 216 | 217 |
| 217 return handled; | 218 return handled; |
| 218 } | 219 } |
| 219 | 220 |
| 220 bool AppsGridView::OnKeyReleased(const views::KeyEvent& event) { | 221 bool AppsGridView::OnKeyReleased(const ui::KeyEvent& event) { |
| 221 bool handled = false; | 222 bool handled = false; |
| 222 if (selected_item_index_ >= 0) | 223 if (selected_item_index_ >= 0) |
| 223 handled = GetItemViewAtIndex(selected_item_index_)->OnKeyReleased(event); | 224 handled = GetItemViewAtIndex(selected_item_index_)->OnKeyReleased(event); |
| 224 | 225 |
| 225 return handled; | 226 return handled; |
| 226 } | 227 } |
| 227 | 228 |
| 228 void AppsGridView::OnPaintFocusBorder(gfx::Canvas* canvas) { | 229 void AppsGridView::OnPaintFocusBorder(gfx::Canvas* canvas) { |
| 229 // Override to not paint focus frame. | 230 // Override to not paint focus frame. |
| 230 } | 231 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 312 |
| 312 void AppsGridView::SelectedPageChanged(int old_selected, int new_selected) { | 313 void AppsGridView::SelectedPageChanged(int old_selected, int new_selected) { |
| 313 Layout(); | 314 Layout(); |
| 314 } | 315 } |
| 315 | 316 |
| 316 void AppsGridView::TransitionChanged() { | 317 void AppsGridView::TransitionChanged() { |
| 317 Layout(); | 318 Layout(); |
| 318 } | 319 } |
| 319 | 320 |
| 320 } // namespace app_list | 321 } // namespace app_list |
| OLD | NEW |