| 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/contents_view.h" | 5 #include "ui/app_list/contents_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/app_list/app_list_view.h" | 9 #include "ui/app_list/app_list_view.h" |
| 10 #include "ui/app_list/apps_grid_view.h" | 10 #include "ui/app_list/apps_grid_view.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 int height = std::max(grid_size.height() + page_switcher_size.height(), | 184 int height = std::max(grid_size.height() + page_switcher_size.height(), |
| 185 results_size.height()); | 185 results_size.height()); |
| 186 return gfx::Size(width, height); | 186 return gfx::Size(width, height); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void ContentsView::Layout() { | 189 void ContentsView::Layout() { |
| 190 CalculateIdealBounds(); | 190 CalculateIdealBounds(); |
| 191 views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_); | 191 views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_); |
| 192 } | 192 } |
| 193 | 193 |
| 194 ui::GestureStatus ContentsView::OnGestureEvent( | 194 ui::EventResult ContentsView::OnGestureEvent( |
| 195 const ui::GestureEvent& event) { | 195 const ui::GestureEvent& event) { |
| 196 if (show_state_ != SHOW_APPS) | 196 if (show_state_ != SHOW_APPS) |
| 197 return ui::GESTURE_STATUS_UNKNOWN; | 197 return ui::ER_UNHANDLED; |
| 198 | 198 |
| 199 switch (event.type()) { | 199 switch (event.type()) { |
| 200 case ui::ET_GESTURE_SCROLL_BEGIN: | 200 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 201 pagination_model_->StartScroll(); | 201 pagination_model_->StartScroll(); |
| 202 return ui::GESTURE_STATUS_CONSUMED; | 202 return ui::ER_CONSUMED; |
| 203 case ui::ET_GESTURE_SCROLL_UPDATE: | 203 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 204 // event.details.scroll_x() > 0 means moving contents to right. That is, | 204 // event.details.scroll_x() > 0 means moving contents to right. That is, |
| 205 // transitioning to previous page. | 205 // transitioning to previous page. |
| 206 pagination_model_->UpdateScroll( | 206 pagination_model_->UpdateScroll( |
| 207 event.details().scroll_x() / GetContentsBounds().width()); | 207 event.details().scroll_x() / GetContentsBounds().width()); |
| 208 return ui::GESTURE_STATUS_CONSUMED; | 208 return ui::ER_CONSUMED; |
| 209 case ui::ET_GESTURE_SCROLL_END: | 209 case ui::ET_GESTURE_SCROLL_END: |
| 210 pagination_model_->EndScroll(pagination_model_-> | 210 pagination_model_->EndScroll(pagination_model_-> |
| 211 transition().progress < kFinishTransitionThreshold); | 211 transition().progress < kFinishTransitionThreshold); |
| 212 return ui::GESTURE_STATUS_CONSUMED; | 212 return ui::ER_CONSUMED; |
| 213 case ui::ET_SCROLL_FLING_START: { | 213 case ui::ET_SCROLL_FLING_START: { |
| 214 pagination_model_->EndScroll(true); | 214 pagination_model_->EndScroll(true); |
| 215 if (fabs(event.details().velocity_x()) > kMinHorizVelocityToSwitchPage) { | 215 if (fabs(event.details().velocity_x()) > kMinHorizVelocityToSwitchPage) { |
| 216 pagination_model_->SelectPageRelative( | 216 pagination_model_->SelectPageRelative( |
| 217 event.details().velocity_x() < 0 ? 1 : -1, | 217 event.details().velocity_x() < 0 ? 1 : -1, |
| 218 true); | 218 true); |
| 219 } | 219 } |
| 220 return ui::GESTURE_STATUS_CONSUMED; | 220 return ui::ER_CONSUMED; |
| 221 } | 221 } |
| 222 default: | 222 default: |
| 223 break; | 223 break; |
| 224 } | 224 } |
| 225 | 225 |
| 226 return ui::GESTURE_STATUS_UNKNOWN; | 226 return ui::ER_UNHANDLED; |
| 227 } | 227 } |
| 228 | 228 |
| 229 bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) { | 229 bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) { |
| 230 switch (show_state_) { | 230 switch (show_state_) { |
| 231 case SHOW_APPS: | 231 case SHOW_APPS: |
| 232 return GetAppsGridView(view_model_.get())->OnKeyPressed(event); | 232 return GetAppsGridView(view_model_.get())->OnKeyPressed(event); |
| 233 case SHOW_SEARCH_RESULTS: | 233 case SHOW_SEARCH_RESULTS: |
| 234 return GetSearchResultListView(view_model_.get())->OnKeyPressed(event); | 234 return GetSearchResultListView(view_model_.get())->OnKeyPressed(event); |
| 235 default: | 235 default: |
| 236 NOTREACHED() << "Unknown show state " << show_state_; | 236 NOTREACHED() << "Unknown show state " << show_state_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 260 pagination_model_->SelectPageRelative(event.x_offset() > 0 ? -1 : 1, | 260 pagination_model_->SelectPageRelative(event.x_offset() > 0 ? -1 : 1, |
| 261 true); | 261 true); |
| 262 } | 262 } |
| 263 return true; | 263 return true; |
| 264 } | 264 } |
| 265 | 265 |
| 266 return false; | 266 return false; |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace app_list | 269 } // namespace app_list |
| OLD | NEW |