OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |
| 6 #define CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |
| 7 |
| 8 #include "base/logging.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "content/common/input/input_param_traits.h" |
| 11 #include "content/common/input/synthetic_gesture_params.h" |
| 12 #include "ui/gfx/geometry/point_f.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 struct CONTENT_EXPORT SyntheticPointerActionParams |
| 17 : public SyntheticGestureParams { |
| 18 public: |
| 19 // Actions are queued up until we receive a PROCESS action, at which point |
| 20 // we'll dispatch all queued events. |
| 21 enum class PointerActionType { |
| 22 NOT_INITIALIZED, |
| 23 PRESS, |
| 24 MOVE, |
| 25 RELEASE, |
| 26 PROCESS, |
| 27 POINTER_ACTION_TYPE_MAX = PROCESS |
| 28 }; |
| 29 |
| 30 SyntheticPointerActionParams(); |
| 31 explicit SyntheticPointerActionParams(PointerActionType type); |
| 32 SyntheticPointerActionParams(const SyntheticPointerActionParams& other); |
| 33 ~SyntheticPointerActionParams() override; |
| 34 |
| 35 GestureType GetGestureType() const override; |
| 36 |
| 37 static const SyntheticPointerActionParams* Cast( |
| 38 const SyntheticGestureParams* gesture_params); |
| 39 |
| 40 void set_pointer_action_type(PointerActionType pointer_action_type) { |
| 41 pointer_action_type_ = pointer_action_type; |
| 42 } |
| 43 |
| 44 void set_index(int index) { |
| 45 DCHECK(pointer_action_type_ != PointerActionType::PROCESS); |
| 46 index_ = index; |
| 47 } |
| 48 |
| 49 void set_position(const gfx::PointF& position) { |
| 50 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 51 pointer_action_type_ == PointerActionType::MOVE); |
| 52 position_ = position; |
| 53 } |
| 54 |
| 55 PointerActionType pointer_action_type() const { return pointer_action_type_; } |
| 56 |
| 57 int index() const { |
| 58 DCHECK(pointer_action_type_ != PointerActionType::PROCESS); |
| 59 return index_; |
| 60 } |
| 61 |
| 62 gfx::PointF position() const { |
| 63 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 64 pointer_action_type_ == PointerActionType::MOVE); |
| 65 return position_; |
| 66 } |
| 67 |
| 68 private: |
| 69 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; |
| 70 |
| 71 PointerActionType pointer_action_type_; |
| 72 // Pass a position value when sending a press or move action. |
| 73 gfx::PointF position_; |
| 74 // Pass an index value except if the pointer_action_type_ is PROCESS. |
| 75 int index_; |
| 76 }; |
| 77 |
| 78 } // namespace content |
| 79 |
| 80 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |
OLD | NEW |