1// Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net>
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QTUIOCURSOR_P_H
6#define QTUIOCURSOR_P_H
7
8#include <Qt>
9
10QT_BEGIN_NAMESPACE
11
12class QTuioCursor
13{
14public:
15 QTuioCursor(int id = -1)
16 : m_id(id)
17 , m_x(0)
18 , m_y(0)
19 , m_vx(0)
20 , m_vy(0)
21 , m_acceleration(0)
22 , m_state(QEventPoint::State::Pressed)
23 {
24 }
25
26 int id() const { return m_id; }
27
28 void setX(float x)
29 {
30 if (state() == QEventPoint::State::Stationary &&
31 !qFuzzyCompare(p1: m_x + 2.0, p2: x + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
32 setState(QEventPoint::State::Updated);
33 }
34 m_x = x;
35 }
36 float x() const { return m_x; }
37
38 void setY(float y)
39 {
40 if (state() == QEventPoint::State::Stationary &&
41 !qFuzzyCompare(p1: m_y + 2.0, p2: y + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
42 setState(QEventPoint::State::Updated);
43 }
44 m_y = y;
45 }
46 float y() const { return m_y; }
47
48 void setVX(float vx) { m_vx = vx; }
49 float vx() const { return m_vx; }
50
51 void setVY(float vy) { m_vy = vy; }
52 float vy() const { return m_vy; }
53
54 void setAcceleration(float acceleration) { m_acceleration = acceleration; }
55 float acceleration() const { return m_acceleration; }
56
57 void setState(const QEventPoint::State &state) { m_state = state; }
58 QEventPoint::State state() const { return m_state; }
59
60private:
61 int m_id;
62 float m_x;
63 float m_y;
64 float m_vx;
65 float m_vy;
66 float m_acceleration;
67 QEventPoint::State m_state;
68};
69Q_DECLARE_TYPEINFO(QTuioCursor, Q_RELOCATABLE_TYPE); // Q_PRIMITIVE_TYPE: not possible, m_state is = 1, not 0.
70
71QT_END_NAMESPACE
72
73#endif // QTUIOCURSOR_P_H
74

source code of qtbase/src/plugins/generic/tuiotouch/qtuiocursor_p.h