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

Side by Side Diff: ui/events/android/motion_event_android.h

Issue 2896993002: Route OnDragEvent through ViewAndroid tree (Closed)
Patch Set: +ui/base Created 3 years, 7 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
« no previous file with comments | « ui/events/android/drag_event_android.cc ('k') | ui/events/android/motion_event_android.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ANDROID_MOTION_EVENT_ANDROID_H_ 5 #ifndef UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_
6 #define UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_ 6 #define UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 jint action_index, 61 jint action_index,
62 jint android_action_button, 62 jint android_action_button,
63 jint android_button_state, 63 jint android_button_state,
64 jint meta_state, 64 jint meta_state,
65 jfloat raw_offset_x_pixels, 65 jfloat raw_offset_x_pixels,
66 jfloat raw_offset_y_pixels, 66 jfloat raw_offset_y_pixels,
67 const Pointer* const pointer0, 67 const Pointer* const pointer0,
68 const Pointer* const pointer1); 68 const Pointer* const pointer1);
69 ~MotionEventAndroid() override; 69 ~MotionEventAndroid() override;
70 70
71 std::unique_ptr<MotionEventAndroid> Offset(float x, float y) const; 71 // Create a new instance from |this| with its cached pointers set
72 // to a given point.
73 std::unique_ptr<MotionEventAndroid> CreateFor(const gfx::PointF& point) const;
74
75 // Convenience method returning the pointer at index 0.
76 gfx::PointF GetPoint() const { return gfx::PointF(GetX(0), GetY(0)); }
72 77
73 // ui::MotionEvent methods. 78 // ui::MotionEvent methods.
74 uint32_t GetUniqueEventId() const override; 79 uint32_t GetUniqueEventId() const override;
75 Action GetAction() const override; 80 Action GetAction() const override;
76 int GetActionIndex() const override; 81 int GetActionIndex() const override;
77 size_t GetPointerCount() const override; 82 size_t GetPointerCount() const override;
78 int GetPointerId(size_t pointer_index) const override; 83 int GetPointerId(size_t pointer_index) const override;
79 float GetX(size_t pointer_index) const override; 84 float GetX(size_t pointer_index) const override;
80 float GetY(size_t pointer_index) const override; 85 float GetY(size_t pointer_index) const override;
81 float GetRawX(size_t pointer_index) const override; 86 float GetRawX(size_t pointer_index) const override;
(...skipping 24 matching lines...) Expand all
106 float time_sec() const { return time_sec_; } 111 float time_sec() const { return time_sec_; }
107 float GetTickMultiplier() const; 112 float GetTickMultiplier() const;
108 113
109 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() const; 114 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() const;
110 115
111 private: 116 private:
112 struct CachedPointer; 117 struct CachedPointer;
113 118
114 float ToDips(float pixels) const; 119 float ToDips(float pixels) const;
115 CachedPointer FromAndroidPointer(const Pointer& pointer) const; 120 CachedPointer FromAndroidPointer(const Pointer& pointer) const;
116 CachedPointer OffsetCachedPointer(const CachedPointer& pointer, 121 CachedPointer CreateCachedPointer(const CachedPointer& pointer,
117 float x, 122 const gfx::PointF& point) const;
118 float y) const;
119 123
120 // Cache pointer coords, id's and major lengths for the most common 124 // Cache pointer coords, id's and major lengths for the most common
121 // touch-related scenarios, i.e., scrolling and pinching. This prevents 125 // touch-related scenarios, i.e., scrolling and pinching. This prevents
122 // redundant JNI fetches for the same bits. 126 // redundant JNI fetches for the same bits.
123 enum { MAX_POINTERS_TO_CACHE = 2 }; 127 enum { MAX_POINTERS_TO_CACHE = 2 };
124 128
125 // The Java reference to the underlying MotionEvent. 129 // The Java reference to the underlying MotionEvent.
126 base::android::ScopedJavaGlobalRef<jobject> event_; 130 base::android::ScopedJavaGlobalRef<jobject> event_;
127 131
128 // Used to convert pixel coordinates from the Java-backed MotionEvent to 132 // Used to convert pixel coordinates from the Java-backed MotionEvent to
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 const uint32_t unique_event_id_; 164 const uint32_t unique_event_id_;
161 165
162 // Disallow copy/assign. 166 // Disallow copy/assign.
163 MotionEventAndroid(const MotionEventAndroid& e); // private ctor 167 MotionEventAndroid(const MotionEventAndroid& e); // private ctor
164 void operator=(const MotionEventAndroid&) = delete; 168 void operator=(const MotionEventAndroid&) = delete;
165 }; 169 };
166 170
167 } // namespace content 171 } // namespace content
168 172
169 #endif // UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_ 173 #endif // UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_
OLDNEW
« no previous file with comments | « ui/events/android/drag_event_android.cc ('k') | ui/events/android/motion_event_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698