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
qquickdragaxis_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKDRAGAXIS_P_H
6#define QQUICKDRAGAXIS_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQml/qqml.h>
20#include <QtQml/qqmlproperty.h>
21#include <private/qtquickglobal_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class QQuickItem;
26class QQuickPointerHandler;
27
28class Q_QUICK_EXPORT QQuickDragAxis : public QObject
29{
30 Q_OBJECT
31 Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
32 Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
33 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
34 Q_PROPERTY(qreal activeValue READ activeValue NOTIFY activeValueChanged REVISION(6, 5))
35 QML_NAMED_ELEMENT(DragAxis)
36 QML_ADDED_IN_VERSION(2, 12)
37 QML_UNCREATABLE("DragAxis is only available as a grouped property of DragHandler or PinchHandler.")
38
39public:
40 QQuickDragAxis(QQuickPointerHandler *handler, const QString &propertyName,
41 qreal initValue = 0);
42
43 qreal minimum() const { return m_minimum; }
44 void setMinimum(qreal minimum);
45
46 qreal maximum() const { return m_maximum; }
47 void setMaximum(qreal maximum);
48
49 bool enabled() const { return m_enabled; }
50 void setEnabled(bool enabled);
51
52 qreal activeValue() const { return m_activeValue; }
53
54 qreal persistentValue() const { return m_accumulatedValue; }
55
56protected:
57 void onActiveChanged(bool active, qreal initActiveValue);
58 qreal targetValue();
59 void updateValue(qreal activeValue, qreal accumulatedValue, qreal delta = 0);
60
61Q_SIGNALS:
62 void minimumChanged();
63 void maximumChanged();
64 void enabledChanged();
65 Q_REVISION(6, 5) void activeValueChanged(qreal delta);
66
67private:
68 qreal m_minimum = std::numeric_limits<qreal>::lowest();
69 qreal m_maximum = std::numeric_limits<qreal>::max();
70 qreal m_startValue = 0;
71 qreal m_activeValue = 0;
72 qreal m_accumulatedValue = 0;
73 QString m_propertyName;
74 bool m_enabled = true;
75
76 friend class QQuickDragHandler;
77 friend class QQuickPinchHandler;
78};
79
80QT_END_NAMESPACE
81
82#endif // QQUICKDRAGAXIS_P_H
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")