Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtuiocursor_p.h
Go to the documentation of this file.
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
11
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)
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(m_x + 2.0, 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(m_y + 2.0, 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
bool isValid() const
void setX(float x)
void setVY(float vy)
float acceleration() const
void setVX(float vx)
float vx() const
void setAcceleration(float acceleration)
QEventPoint::State state() const
void setState(const QEventPoint::State &state)
float vy() const
int id() const
float x() const
void setY(float y)
float y() const
QTuioCursor(int id=-1)
virtual ~QTuioHandler()
QTuioToken(int id=-1)
void setAngularAcceleration(float angularAcceleration)
void setX(float x)
void setAcceleration(float acceleration)
float y() const
float vy() const
int id() const
int classId() const
void setVY(float vy)
void setAngle(float angle)
void setClassId(int classId)
void setY(float y)
float angle() const
void setAngularVelocity(float angularVelocity)
float x() const
float vx() const
void setVX(float vx)
constexpr float qRadiansToDegrees(float radians)
Definition qmath.h:272
Q_DECLARE_TYPEINFO(QTuioCursor, Q_RELOCATABLE_TYPE)