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

Side by Side Diff: ui/app_list/contents_view.cc

Issue 11280290: events: Change gesture-event handler in EventHandler to not return any values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/app_list/contents_view.h ('k') | ui/aura/demo/demo_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_constants.h" 9 #include "ui/app_list/app_list_constants.h"
10 #include "ui/app_list/app_list_view.h" 10 #include "ui/app_list/app_list_view.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 if (abs(event.offset()) > kMinMouseWheelToSwitchPage) { 179 if (abs(event.offset()) > kMinMouseWheelToSwitchPage) {
180 if (!pagination_model_->has_transition()) 180 if (!pagination_model_->has_transition())
181 pagination_model_->SelectPageRelative(event.offset() > 0 ? -1 : 1, true); 181 pagination_model_->SelectPageRelative(event.offset() > 0 ? -1 : 1, true);
182 return true; 182 return true;
183 } 183 }
184 184
185 return false; 185 return false;
186 } 186 }
187 187
188 ui::EventResult ContentsView::OnGestureEvent(ui::GestureEvent* event) { 188 void ContentsView::OnGestureEvent(ui::GestureEvent* event) {
189 if (show_state_ != SHOW_APPS) 189 if (show_state_ != SHOW_APPS)
190 return ui::ER_UNHANDLED; 190 return;
191 191
192 switch (event->type()) { 192 switch (event->type()) {
193 case ui::ET_GESTURE_SCROLL_BEGIN: 193 case ui::ET_GESTURE_SCROLL_BEGIN:
194 pagination_model_->StartScroll(); 194 pagination_model_->StartScroll();
195 return ui::ER_CONSUMED; 195 event->SetHandled();
196 return;
196 case ui::ET_GESTURE_SCROLL_UPDATE: 197 case ui::ET_GESTURE_SCROLL_UPDATE:
197 // event->details.scroll_x() > 0 means moving contents to right. That is, 198 // event->details.scroll_x() > 0 means moving contents to right. That is,
198 // transitioning to previous page. 199 // transitioning to previous page.
199 pagination_model_->UpdateScroll( 200 pagination_model_->UpdateScroll(
200 event->details().scroll_x() / GetContentsBounds().width()); 201 event->details().scroll_x() / GetContentsBounds().width());
201 return ui::ER_CONSUMED; 202 event->SetHandled();
203 return;
202 case ui::ET_GESTURE_SCROLL_END: 204 case ui::ET_GESTURE_SCROLL_END:
203 pagination_model_->EndScroll(pagination_model_-> 205 pagination_model_->EndScroll(pagination_model_->
204 transition().progress < kFinishTransitionThreshold); 206 transition().progress < kFinishTransitionThreshold);
205 return ui::ER_CONSUMED; 207 event->SetHandled();
208 return;
206 case ui::ET_SCROLL_FLING_START: { 209 case ui::ET_SCROLL_FLING_START: {
207 pagination_model_->EndScroll(true); 210 pagination_model_->EndScroll(true);
208 if (fabs(event->details().velocity_x()) > kMinHorizVelocityToSwitchPage) { 211 if (fabs(event->details().velocity_x()) > kMinHorizVelocityToSwitchPage) {
209 pagination_model_->SelectPageRelative( 212 pagination_model_->SelectPageRelative(
210 event->details().velocity_x() < 0 ? 1 : -1, 213 event->details().velocity_x() < 0 ? 1 : -1,
211 true); 214 true);
212 } 215 }
213 return ui::ER_CONSUMED; 216 event->SetHandled();
217 return;
214 } 218 }
215 default: 219 default:
216 break; 220 break;
217 } 221 }
218
219 return ui::ER_UNHANDLED;
220 } 222 }
221 223
222 ui::EventResult ContentsView::OnScrollEvent(ui::ScrollEvent* event) { 224 ui::EventResult ContentsView::OnScrollEvent(ui::ScrollEvent* event) {
223 if (show_state_ != SHOW_APPS || 225 if (show_state_ != SHOW_APPS ||
224 event->type() == ui::ET_SCROLL_FLING_CANCEL || 226 event->type() == ui::ET_SCROLL_FLING_CANCEL ||
225 abs(event->x_offset()) < kMinScrollToSwitchPage) { 227 abs(event->x_offset()) < kMinScrollToSwitchPage) {
226 return ui::ER_UNHANDLED; 228 return ui::ER_UNHANDLED;
227 } 229 }
228 230
229 if (!pagination_model_->has_transition()) { 231 if (!pagination_model_->has_transition()) {
230 pagination_model_->SelectPageRelative(event->x_offset() > 0 ? -1 : 1, 232 pagination_model_->SelectPageRelative(event->x_offset() > 0 ? -1 : 1,
231 true); 233 true);
232 } 234 }
233 return ui::ER_HANDLED; 235 return ui::ER_HANDLED;
234 } 236 }
235 237
236 } // namespace app_list 238 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/contents_view.h ('k') | ui/aura/demo/demo_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698