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

Side by Side Diff: ui/views/controls/scroll_view.cc

Issue 10824295: Rid the world of the last of views::Event types: TouchEvent, GestureEvent, MouseWheelEvent, ScrollE… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | ui/views/controls/scrollbar/base_scroll_bar.h » ('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/views/controls/scroll_view.h" 5 #include "ui/views/controls/scroll_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/event.h" 8 #include "ui/base/event.h"
9 #include "ui/views/controls/scrollbar/native_scroll_bar.h" 9 #include "ui/views/controls/scrollbar/native_scroll_bar.h"
10 #include "ui/views/widget/root_view.h" 10 #include "ui/views/widget/root_view.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // Give vertical scrollbar priority 393 // Give vertical scrollbar priority
394 if (vert_sb_->visible()) 394 if (vert_sb_->visible())
395 processed = vert_sb_->OnKeyPressed(event); 395 processed = vert_sb_->OnKeyPressed(event);
396 396
397 if (!processed && horiz_sb_->visible()) 397 if (!processed && horiz_sb_->visible())
398 processed = horiz_sb_->OnKeyPressed(event); 398 processed = horiz_sb_->OnKeyPressed(event);
399 399
400 return processed; 400 return processed;
401 } 401 }
402 402
403 ui::GestureStatus ScrollView::OnGestureEvent(const GestureEvent& event) { 403 ui::GestureStatus ScrollView::OnGestureEvent(const ui::GestureEvent& event) {
404 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; 404 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN;
405 405
406 // If the event happened on one of the scrollbars, then those events are 406 // If the event happened on one of the scrollbars, then those events are
407 // sent directly to the scrollbars. Otherwise, only scroll events are sent to 407 // sent directly to the scrollbars. Otherwise, only scroll events are sent to
408 // the scrollbars. 408 // the scrollbars.
409 bool scroll_event = event.type() == ui::ET_GESTURE_SCROLL_UPDATE || 409 bool scroll_event = event.type() == ui::ET_GESTURE_SCROLL_UPDATE ||
410 event.type() == ui::ET_GESTURE_SCROLL_BEGIN || 410 event.type() == ui::ET_GESTURE_SCROLL_BEGIN ||
411 event.type() == ui::ET_GESTURE_SCROLL_END; 411 event.type() == ui::ET_GESTURE_SCROLL_END;
412 412
413 if (vert_sb_->visible()) { 413 if (vert_sb_->visible()) {
414 if (vert_sb_->bounds().Contains(event.location()) || scroll_event) 414 if (vert_sb_->bounds().Contains(event.location()) || scroll_event)
415 status = vert_sb_->OnGestureEvent(event); 415 status = vert_sb_->OnGestureEvent(event);
416 } 416 }
417 if (status == ui::GESTURE_STATUS_UNKNOWN && horiz_sb_->visible()) { 417 if (status == ui::GESTURE_STATUS_UNKNOWN && horiz_sb_->visible()) {
418 if (horiz_sb_->bounds().Contains(event.location()) || scroll_event) 418 if (horiz_sb_->bounds().Contains(event.location()) || scroll_event)
419 status = horiz_sb_->OnGestureEvent(event); 419 status = horiz_sb_->OnGestureEvent(event);
420 } 420 }
421 return status; 421 return status;
422 } 422 }
423 423
424 bool ScrollView::OnMouseWheel(const MouseWheelEvent& e) { 424 bool ScrollView::OnMouseWheel(const ui::MouseWheelEvent& e) {
425 bool processed = false; 425 bool processed = false;
426 // Give vertical scrollbar priority 426 // Give vertical scrollbar priority
427 if (vert_sb_->visible()) 427 if (vert_sb_->visible())
428 processed = vert_sb_->OnMouseWheel(e); 428 processed = vert_sb_->OnMouseWheel(e);
429 429
430 if (!processed && horiz_sb_->visible()) 430 if (!processed && horiz_sb_->visible())
431 processed = horiz_sb_->OnMouseWheel(e); 431 processed = horiz_sb_->OnMouseWheel(e);
432 432
433 return processed; 433 return processed;
434 } 434 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 512
513 VariableRowHeightScrollHelper::RowInfo 513 VariableRowHeightScrollHelper::RowInfo
514 FixedRowHeightScrollHelper::GetRowInfo(int y) { 514 FixedRowHeightScrollHelper::GetRowInfo(int y) {
515 if (y < top_margin_) 515 if (y < top_margin_)
516 return RowInfo(0, top_margin_); 516 return RowInfo(0, top_margin_);
517 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 517 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
518 row_height_); 518 row_height_);
519 } 519 }
520 520
521 } // namespace views 521 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | ui/views/controls/scrollbar/base_scroll_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698