Chromium Code Reviews| Index: ui/android/view_client.h |
| diff --git a/ui/android/view_client.h b/ui/android/view_client.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bb3fb015744d8f6b819b9ccb5af900bb7e15545e |
| --- /dev/null |
| +++ b/ui/android/view_client.h |
| @@ -0,0 +1,149 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_ANDROID_VIEW_CLIENT_H_ |
| +#define UI_ANDROID_VIEW_CLIENT_H_ |
| + |
| +#include <jni.h> |
| + |
| +#include "ui/android/ui_android_export.h" |
| + |
| +namespace ui { |
| + |
| +// Container of motion event data. Used when traversing views along their |
| +// hierarchy. Actual motion event object will be constructed right before |
| +// it is used in the |ViewClient| implementation to avoid creating multiple |
| +// |MotionEventAndroid| instances. |
| +struct MotionEventData { |
|
boliu
2017/02/28 22:44:54
so why do we need a new struct if MotionEventAndro
Jinsuk Kim
2017/03/02 04:08:35
Because
- MEA creates and assigns a unique id for
aelias_OOO_until_Jul13
2017/03/02 04:17:42
I tend to agree with Bo.
aelias_OOO_until_Jul13
2017/03/02 04:21:46
In the long run, C++ touch handles could be child
Jinsuk Kim
2017/03/03 06:29:21
Thanks for the input. Done. Added another ctor to
Jinsuk Kim
2017/03/03 06:29:21
Acknowledged. Left a TODO in rwhva about removing
|
| + MotionEventData(float dip_scale, |
| + jobject jevent, |
| + long time_ms, |
| + int android_action, |
| + int pointer_count, |
| + int history_size, |
| + int action_index, |
| + float pos_x0, |
| + float pos_y0, |
| + float pos_x1, |
| + float pos_y1, |
| + int pointer_id_0, |
| + int pointer_id_1, |
| + float touch_major_0, |
| + float touch_major_1, |
| + float touch_minor_0, |
| + float touch_minor_1, |
| + float orientation_0, |
| + float orientation_1, |
| + float tilt_0, |
| + float tilt_1, |
| + float raw_pos_x, |
| + float raw_pos_y, |
| + float pressure, |
| + int android_tool_type_0, |
| + int android_tool_type_1, |
| + int android_action_button, |
| + int android_button_state, |
| + int android_meta_state, |
| + bool is_touch_handle_event); |
| + |
| + MotionEventData(const MotionEventData& other); |
| + |
| + // Returns a new |MotionEventData| object whose position is offset |
| + // by a given delta. |
| + MotionEventData Offset(float delta_x, float delta_y) const; |
| + |
| + static MotionEventData ForTouch(float dip_scale, |
| + jobject jevent, |
| + long time, |
| + int action, |
| + int pointer_count, |
| + int history_size, |
| + int action_index, |
| + float pos_x0, |
| + float pos_y0, |
| + float pos_x1, |
| + float pos_y1, |
| + int pointer_id_0, |
| + int pointer_id_1, |
| + float touch_major_0, |
| + float touch_major_1, |
| + float touch_minor_0, |
| + float touch_minor_1, |
| + float orientation_0, |
| + float orientation_1, |
| + float tilt_0, |
| + float tilt_1, |
| + float raw_pos_x, |
| + float raw_pos_y, |
| + int tool_type_0, |
| + int tool_type_1, |
| + int button_state, |
| + int meta_state, |
| + bool is_touch_handle_event); |
| + |
| + static MotionEventData ForMouse(float dip_scale, |
| + long time_ms, |
| + int android_action, |
| + float pos_x, |
| + float pos_y, |
| + int pointer_id, |
| + float orientation, |
| + float pressure, |
| + float tilt, |
| + int android_tool_type, |
| + int android_action_button, |
| + int android_button_state, |
| + int android_meta_state); |
| + |
| + float GetX() const { return pos_x_0 / dip_scale; } |
| + float GetY() const { return pos_y_0 / dip_scale; } |
| + |
| + const float dip_scale; |
| + const jobject jevent; |
| + const long time_ms; |
| + const int android_action; |
| + const int pointer_count; |
| + const int history_size; |
| + const int action_index; |
| + |
| + const float pos_x_0; // in pixel unit |
| + const float pos_y_0; |
| + const float pos_x_1; |
| + const float pos_y_1; |
| + |
| + const int pointer_id_0; |
| + const int pointer_id_1; |
| + const float touch_major_0; |
| + const float touch_major_1; |
| + const float touch_minor_0; |
| + const float touch_minor_1; |
| + const float orientation_0; |
| + const float orientation_1; |
| + const float tilt_0; |
| + const float tilt_1; |
| + const float raw_pos_x; |
| + const float raw_pos_y; |
| + const float pressure; |
| + const int android_tool_type_0; |
| + const int android_tool_type_1; |
| + const int android_action_button; |
| + const int android_button_state; |
| + const int android_meta_state; |
| + const bool is_touch_handle_event; |
| +}; |
| + |
| +// Client interface used to forward events from Java to native views. |
| +// Calls are dispatched to its children along the hierarchy of ViewAndroid. |
| +// Use bool return type to stop propagating the call i.e. overriden method |
| +// should return true to indicate that the event was handled and stop |
| +// the processing. |
| +class UI_ANDROID_EXPORT ViewClient { |
| + public: |
| + virtual bool OnTouchEvent(const MotionEventData& m); |
| + virtual bool OnMouseEvent(const MotionEventData& m); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_ANDROID_VIEW_CLIENT_H_ |