• 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 
24 namespace OHOS::MMI {
25 class PointerEvent;
26 }
27 
28 namespace OHOS::Ace {
29 enum class PointerAction : int32_t {
30     UNKNOWN = 0,
31     CANCEL = 1,
32     DOWN = 2,
33     MOVE = 3,
34     UP = 4,
35     AXIS_BEGIN = 5,
36     AXIS_UPDATE = 6,
37     AXIS_END = 7,
38     BUTTON_DOWN = 8,
39     BUTTON_UP = 9,
40     ENTER_WINDOW = 10,
41     LEAVE_WINDOW = 11,
42     PULL_DOWN = 12,
43     PULL_MOVE = 13,
44     PULL_UP = 14,
45     PULL_IN_WINDOW = 15,
46     PULL_OUT_WINDOW = 16,
47     SWIPE_BEGIN = 17,
48     SWIPE_UPDATE = 18,
49     SWIPE_END = 19,
50 };
51 
52 struct PointerEvent final {
53     int32_t pointerId = 0;
54     bool pressed = false;
55     int32_t windowX = 0;
56     int32_t windowY = 0;
57     int32_t displayX = 0;
58     int32_t displayY = 0;
59     double size = 0.0;
60     float force = 0.0f;
61     int32_t deviceId = 0;
62     TimeStamp downTime;
63     SourceTool sourceTool = SourceTool::UNKNOWN;
64     int32_t targetWindowId = -1;
65     int32_t x = 0;
66     int32_t y = 0;
67     std::shared_ptr<MMI::PointerEvent> rawPointerEvent;
68 
69     PointerEvent() = default;
PointerEventfinal70     PointerEvent(int32_t x, int32_t y) : x(x), y(y) {}
PointerEventfinal71     PointerEvent(int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY)
72         : windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY)
73     {}
74 
GetPointfinal75     Point GetPoint() const
76     {
77         if (!x && !y) {
78             return Point(windowX, windowY, displayX, displayY);
79         } else {
80             return Point(x, y, x, y);
81         }
82     }
83 };
84 } // namespace OHOS::Ace
85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_POINTER_EVENT_H