• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_POINTER_EVENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_POINTER_EVENT_H
18 
19 #include <map>
20 
21 #include "base/geometry/point.h"
22 #include "core/event/ace_events.h"
23 #include "core/event/axis_event.h"
24 
25 namespace OHOS::MMI {
26 class PointerEvent;
27 }
28 
29 namespace OHOS::Ace {
30 
31 enum class KeyCode : int32_t;
32 
33 enum class PointerAction : int32_t {
34     UNKNOWN = 0,
35     CANCEL = 1,
36     DOWN = 2,
37     MOVE = 3,
38     UP = 4,
39     AXIS_BEGIN = 5,
40     AXIS_UPDATE = 6,
41     AXIS_END = 7,
42     BUTTON_DOWN = 8,
43     BUTTON_UP = 9,
44     ENTER_WINDOW = 10,
45     LEAVE_WINDOW = 11,
46     PULL_DOWN = 12,
47     PULL_MOVE = 13,
48     PULL_UP = 14,
49     PULL_IN_WINDOW = 15,
50     PULL_OUT_WINDOW = 16,
51     SWIPE_BEGIN = 17,
52     SWIPE_UPDATE = 18,
53     SWIPE_END = 19,
54     POINTER_ACTION_ROTATE_BEGIN = 20,
55     POINTER_ACTION_ROTATE_UPDATE = 21,
56     POINTER_ACTION_ROTATE_END = 22,
57 };
58 
59 struct DragPointerEvent final : public PointerEvent {
60     int32_t pointerEventId = 0;
61     int32_t pointerId = 0;
62     int32_t pullId = -1;
63     bool pressed = false;
64     int32_t windowX = 0;
65     int32_t windowY = 0;
66     int32_t displayX = 0;
67     int32_t displayY = 0;
68     double size = 0.0;
69     float force = 0.0f;
70     int32_t deviceId = 0;
71     TimeStamp downTime;
72     SourceTool sourceTool = SourceTool::UNKNOWN;
73     int32_t targetWindowId = -1;
74     std::shared_ptr<MMI::PointerEvent> rawPointerEvent;
75     PointerAction action = PointerAction::UNKNOWN;
76     std::vector<KeyCode> pressedKeyCodes_;
77     int32_t displayId = 0;
78     int32_t sourceType = 0;
79 
80     DragPointerEvent() = default;
DragPointerEventfinal81     DragPointerEvent(float x, float y)
82         :PointerEvent(x, y)
83     {}
DragPointerEventfinal84     DragPointerEvent(int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY)
85         : windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY)
86     {}
DragPointerEventfinal87     DragPointerEvent(int32_t pointerEventId, int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY)
88         : pointerEventId(pointerEventId), windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY)
89     {}
90 
GetPointfinal91     Point GetPoint() const
92     {
93         if (!x && !y) {
94             return Point(windowX, windowY, displayX, displayY);
95         } else {
96             return Point(x, y, x, y);
97         }
98     }
99 
GetDisplayXfinal100     int32_t GetDisplayX() const
101     {
102         return displayX;
103     }
104 
GetDisplayYfinal105     int32_t GetDisplayY() const
106     {
107         return displayY;
108     }
109 };
110 } // namespace OHOS::Ace
111 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_POINTER_EVENT_H