Overte C++ Documentation
TouchEvent.h
1 //
2 // TouchEvent.h
3 // script-engine/src
4 //
5 // Created by Stephen Birarda on 2014-10-27.
6 // Copyright 2014 High Fidelity, Inc.
7 // Copyright 2023 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 // SPDX-License-Identifier: Apache-2.0
12 //
13 
16 
17 #ifndef hifi_TouchEvent_h
18 #define hifi_TouchEvent_h
19 
20 #include <glm/glm.hpp>
21 
22 #include <QVector>
23 #include <QTouchEvent>
24 
25 #include "ScriptValue.h"
26 
27 class ScriptEngine;
28 
30 class TouchEvent {
31 public:
32  TouchEvent();
33  TouchEvent(const QTouchEvent& event);
34  TouchEvent(const QTouchEvent& event, const TouchEvent& other);
35 
36  static ScriptValue toScriptValue(ScriptEngine* engine, const TouchEvent& event);
37  static bool fromScriptValue(const ScriptValue& object, TouchEvent& event);
38 
39  float x;
40  float y;
41  bool isPressed;
42  bool isMoved;
43  bool isStationary;
44  bool isReleased;
45  bool isShifted;
46  bool isControl;
47  bool isMeta;
48  bool isAlt;
49  int touchPoints;
50  QVector<glm::vec2> points;
51  float radius;
52  bool isPinching;
53  bool isPinchOpening;
54 
55  // angles are in degrees
56  QVector<float> angles; // angle from center to each point
57  float angle; // the average of the angles
58  float deltaAngle; // the change in average angle from last event
59  bool isRotating;
60  QString rotating;
61 
62 private:
63  void initWithQTouchEvent(const QTouchEvent& event);
64  void calculateMetaAttributes(const TouchEvent& other);
65 };
66 
67 Q_DECLARE_METATYPE(TouchEvent)
68 
69 #endif // hifi_TouchEvent_h
70 
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40
Represents a display or device event to the scripting engine. Exposed as TouchEvent
Definition: TouchEvent.h:30