OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_ANDROID_VIEW_CLIENT_H_ |
| 6 #define UI_ANDROID_VIEW_CLIENT_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "ui/android/ui_android_export.h" |
| 11 |
| 12 namespace ui { |
| 13 |
| 14 // Container of motion event data. Used when traversing views along their |
| 15 // hierarchy. Actual motion event object will be constructed right before |
| 16 // it is used in the |ViewClient| implementation to avoid creating multiple |
| 17 // |MotionEventAndroid| instances. |
| 18 struct MotionEventData { |
| 19 MotionEventData(float dip_scale, |
| 20 jobject jevent, |
| 21 long time, |
| 22 int action, |
| 23 int pointer_count, |
| 24 int history_size, |
| 25 int action_index, |
| 26 float pos_x0, |
| 27 float pos_y0, |
| 28 float pos_x1, |
| 29 float pos_y1, |
| 30 int pointer_id_0, |
| 31 int pointer_id_1, |
| 32 float touch_major_0, |
| 33 float touch_major_1, |
| 34 float touch_minor_0, |
| 35 float touch_minor_1, |
| 36 float orientation_0, |
| 37 float orientation_1, |
| 38 float tilt_0, |
| 39 float tilt_1, |
| 40 float raw_pos_x, |
| 41 float raw_pos_y, |
| 42 int tool_type_0, |
| 43 int tool_type_1, |
| 44 int button_state, |
| 45 int meta_state, |
| 46 bool is_touch_handle_event); |
| 47 |
| 48 MotionEventData(const MotionEventData& other); |
| 49 |
| 50 // Returns a new |MotionEventData| object whose position is offset |
| 51 // by a given delta. |
| 52 MotionEventData Offset(float delta_x, float delta_y) const; |
| 53 |
| 54 float GetX() const { return pos_x0_ / dip_scale_; } |
| 55 float GetY() const { return pos_y0_ / dip_scale_; } |
| 56 |
| 57 const float dip_scale_; |
| 58 const jobject jevent_; |
| 59 const long time_; // ms |
| 60 const int action_; |
| 61 const int pointer_count_; |
| 62 const int history_size_; |
| 63 const int action_index_; |
| 64 |
| 65 const float pos_x0_; // in pixel unit |
| 66 const float pos_y0_; |
| 67 const float pos_x1_; |
| 68 const float pos_y1_; |
| 69 |
| 70 const int pointer_id_0_; |
| 71 const int pointer_id_1_; |
| 72 const float touch_major_0_; |
| 73 const float touch_major_1_; |
| 74 const float touch_minor_0_; |
| 75 const float touch_minor_1_; |
| 76 const float orientation_0_; |
| 77 const float orientation_1_; |
| 78 const float tilt_0_; |
| 79 const float tilt_1_; |
| 80 const float raw_pos_x_; |
| 81 const float raw_pos_y_; |
| 82 const int tool_type_0_; |
| 83 const int tool_type_1_; |
| 84 const int button_state_; |
| 85 const int meta_state_; |
| 86 const bool is_touch_handle_event_; |
| 87 }; |
| 88 |
| 89 // Client interface used to forward events from Java to native views. |
| 90 // Calls are dispatched to its children along the hierarchy of ViewAndroid. |
| 91 // Use bool return type to stop propagating the call i.e. overriden method |
| 92 // should return true to indicate that the event was handled and stop |
| 93 // the processing. |
| 94 // Note: Not in use yet. Will be hooked up together with ViewRoot. |
| 95 // See https://crbug.com/671401. |
| 96 class UI_ANDROID_EXPORT ViewClient { |
| 97 public: |
| 98 virtual bool OnTouchEvent(const MotionEventData& event); |
| 99 }; |
| 100 |
| 101 } // namespace ui |
| 102 |
| 103 #endif // UI_ANDROID_VIEW_CLIENT_H_ |
OLD | NEW |