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

Side by Side Diff: ui/events/event.h

Issue 2256343003: Update ui::PointerEvent to support mouse wheel and capture change events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
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 #ifndef UI_EVENTS_EVENT_H_ 5 #ifndef UI_EVENTS_EVENT_H_
6 #define UI_EVENTS_EVENT_H_ 6 #define UI_EVENTS_EVENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 bool IsTouchEvent() const { 124 bool IsTouchEvent() const {
125 return type_ == ET_TOUCH_RELEASED || 125 return type_ == ET_TOUCH_RELEASED ||
126 type_ == ET_TOUCH_PRESSED || 126 type_ == ET_TOUCH_PRESSED ||
127 type_ == ET_TOUCH_MOVED || 127 type_ == ET_TOUCH_MOVED ||
128 type_ == ET_TOUCH_CANCELLED; 128 type_ == ET_TOUCH_CANCELLED;
129 } 129 }
130 130
131 bool IsPointerEvent() const { 131 bool IsPointerEvent() const {
132 return type_ == ET_POINTER_DOWN || type_ == ET_POINTER_MOVED || 132 return type_ == ET_POINTER_DOWN || type_ == ET_POINTER_MOVED ||
133 type_ == ET_POINTER_UP || type_ == ET_POINTER_CANCELLED || 133 type_ == ET_POINTER_UP || type_ == ET_POINTER_CANCELLED ||
134 type_ == ET_POINTER_ENTERED || type_ == ET_POINTER_EXITED; 134 type_ == ET_POINTER_ENTERED || type_ == ET_POINTER_EXITED ||
135 type_ == ET_POINTER_WHEEL_CHANGED ||
136 type_ == ET_POINTER_CAPTURE_CHANGED;
135 } 137 }
136 138
137 // Convenience methods to check pointer type of |this|. Returns false if 139 // Convenience methods to check pointer type of |this|. Returns false if
138 // |this| is not a PointerEvent. 140 // |this| is not a PointerEvent.
139 bool IsMousePointerEvent() const; 141 bool IsMousePointerEvent() const;
140 bool IsTouchPointerEvent() const; 142 bool IsTouchPointerEvent() const;
141 143
142 bool IsGestureEvent() const { 144 bool IsGestureEvent() const {
143 switch (type_) { 145 switch (type_) {
144 case ET_GESTURE_SCROLL_BEGIN: 146 case ET_GESTURE_SCROLL_BEGIN:
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 float tilt_x, 407 float tilt_x,
406 float tilt_y) 408 float tilt_y)
407 : pointer_type(pointer_type), 409 : pointer_type(pointer_type),
408 // If we aren't provided with a radius on one axis, use the 410 // If we aren't provided with a radius on one axis, use the
409 // information from the other axis. 411 // information from the other axis.
410 radius_x(radius_x > 0 ? radius_x : radius_y), 412 radius_x(radius_x > 0 ? radius_x : radius_y),
411 radius_y(radius_y > 0 ? radius_y : radius_x), 413 radius_y(radius_y > 0 ? radius_y : radius_x),
412 force(force), 414 force(force),
413 tilt_x(tilt_x), 415 tilt_x(tilt_x),
414 tilt_y(tilt_y) {} 416 tilt_y(tilt_y) {}
417 PointerDetails(EventPointerType pointer_type, gfx::Vector2d offset)
sadrul 2016/08/19 16:38:59 const gfx::Vector2d&
riajiang 2016/08/22 16:03:05 Done.
418 : pointer_type(pointer_type),
419 force(std::numeric_limits<float>::quiet_NaN()),
420 offset(offset) {}
415 421
416 bool operator==(const PointerDetails& other) const { 422 bool operator==(const PointerDetails& other) const {
417 return pointer_type == other.pointer_type && 423 return pointer_type == other.pointer_type && radius_x == other.radius_x &&
418 radius_x == other.radius_x &&
419 radius_y == other.radius_y && 424 radius_y == other.radius_y &&
420 (force == other.force || 425 (force == other.force ||
421 (std::isnan(force) && std::isnan(other.force))) && 426 (std::isnan(force) && std::isnan(other.force))) &&
422 tilt_x == other.tilt_x && 427 tilt_x == other.tilt_x && tilt_y == other.tilt_y &&
423 tilt_y == other.tilt_y; 428 offset == other.offset;
424 } 429 }
425 430
426 // The type of pointer device. 431 // The type of pointer device.
427 EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN; 432 EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN;
428 433
429 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. 434 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown.
430 float radius_x = 0.0; 435 float radius_x = 0.0;
431 436
432 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. 437 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown.
433 float radius_y = 0.0; 438 float radius_y = 0.0;
434 439
435 // Force (pressure) of the touch. Normalized to be [0, 1] except NaN means 440 // Force (pressure) of the touch. Normalized to be [0, 1] except NaN means
436 // pressure is not supported by the input device. 441 // pressure is not supported by the input device.
437 float force = 0.0; 442 float force = 0.0;
438 443
439 // Tilt of a pen/stylus from surface normal as plane angle in degrees, values 444 // Tilt of a pen/stylus from surface normal as plane angle in degrees, values
440 // lie in [-90,90]. A positive tilt_x is to the right and a positive tilt_y 445 // lie in [-90,90]. A positive tilt_x is to the right and a positive tilt_y
441 // is towards the user. 0.0 if unknown. 446 // is towards the user. 0.0 if unknown.
442 float tilt_x = 0.0; 447 float tilt_x = 0.0;
443 float tilt_y = 0.0; 448 float tilt_y = 0.0;
449
450 // Only used by mouse wheel events. The amount to scroll. This is in multiples
451 // of kWheelDelta.
452 // Note: offset_.x() > 0/offset_.y() > 0 means scroll left/up.
453 gfx::Vector2d offset = gfx::Vector2d();
sadrul 2016/08/19 16:38:59 Don't need this. Just 'gfx::Vector2d offset;' (alt
riajiang 2016/08/19 17:23:42 https://cs.chromium.org/chromium/src/ui/events/eve
riajiang 2016/08/22 16:03:05 Changed to gfx::Vector2d offset;
444 }; 454 };
445 455
446 class EVENTS_EXPORT MouseEvent : public LocatedEvent { 456 class EVENTS_EXPORT MouseEvent : public LocatedEvent {
447 public: 457 public:
448 explicit MouseEvent(const base::NativeEvent& native_event); 458 explicit MouseEvent(const base::NativeEvent& native_event);
449 459
450 // |pointer_event.IsMousePointerEvent()| must be true. 460 // |pointer_event.IsMousePointerEvent()| must be true.
451 explicit MouseEvent(const PointerEvent& pointer_event); 461 explicit MouseEvent(const PointerEvent& pointer_event);
452 462
453 // Create a new MouseEvent based on the provided model. 463 // Create a new MouseEvent based on the provided model.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 bool should_remove_native_touch_id_mapping_; 716 bool should_remove_native_touch_id_mapping_;
707 717
708 // Structure for holding pointer details for implementing PointerEvents API. 718 // Structure for holding pointer details for implementing PointerEvents API.
709 PointerDetails pointer_details_; 719 PointerDetails pointer_details_;
710 }; 720 };
711 721
712 class EVENTS_EXPORT PointerEvent : public LocatedEvent { 722 class EVENTS_EXPORT PointerEvent : public LocatedEvent {
713 public: 723 public:
714 static const int32_t kMousePointerId; 724 static const int32_t kMousePointerId;
715 725
716 // Returns true if a PointerEvent can be constructed from the given mouse or 726 // Returns true if a PointerEvent can be constructed from |event|. Currently,
717 // touch event. For example, PointerEvent does not support ET_MOUSEWHEEL or 727 // only mouse and touch events can be converted to pointer events.
718 // ET_MOUSE_CAPTURE_CHANGED.
719 static bool CanConvertFrom(const Event& event); 728 static bool CanConvertFrom(const Event& event);
720 729
721 PointerEvent(const PointerEvent& pointer_event); 730 PointerEvent(const PointerEvent& pointer_event);
722 explicit PointerEvent(const MouseEvent& mouse_event); 731 explicit PointerEvent(const MouseEvent& mouse_event);
723 explicit PointerEvent(const TouchEvent& touch_event); 732 explicit PointerEvent(const TouchEvent& touch_event);
724 733
725 PointerEvent(EventType type, 734 PointerEvent(EventType type,
726 const gfx::Point& location, 735 const gfx::Point& location,
727 const gfx::Point& root_location, 736 const gfx::Point& root_location,
728 int flags, 737 int flags,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 // dispatched. This field gets a non-zero value only for gestures that are 1011 // dispatched. This field gets a non-zero value only for gestures that are
1003 // released through TouchDispositionGestureFilter::SendGesture. The gesture 1012 // released through TouchDispositionGestureFilter::SendGesture. The gesture
1004 // events that aren't fired directly in response to processing a touch-event 1013 // events that aren't fired directly in response to processing a touch-event
1005 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. 1014 // (e.g. timer fired ones), this id is zero. See crbug.com/618738.
1006 uint32_t unique_touch_event_id_; 1015 uint32_t unique_touch_event_id_;
1007 }; 1016 };
1008 1017
1009 } // namespace ui 1018 } // namespace ui
1010 1019
1011 #endif // UI_EVENTS_EVENT_H_ 1020 #endif // UI_EVENTS_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698