blob: 84b1b7ee072de3d4bf69ccdb678354b79b302b3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qquickdragaxis_p.h"
#include "qquickpointerhandler_p.h"
#include <QtQuick/qquickitem.h>
#include <limits>
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcDragAxis, "qt.quick.pointer.dragaxis")
QQuickDragAxis::QQuickDragAxis(QQuickPointerHandler *handler, const QString &propertyName, qreal initValue)
: QObject(handler), m_accumulatedValue(initValue), m_propertyName(propertyName)
{
}
void QQuickDragAxis::setMinimum(qreal minimum)
{
if (m_minimum == minimum)
return;
m_minimum = minimum;
emit minimumChanged();
}
void QQuickDragAxis::setMaximum(qreal maximum)
{
if (m_maximum == maximum)
return;
m_maximum = maximum;
emit maximumChanged();
}
void QQuickDragAxis::setEnabled(bool enabled)
{
if (m_enabled == enabled)
return;
m_enabled = enabled;
emit enabledChanged();
}
void QQuickDragAxis::onActiveChanged(bool active, qreal initActiveValue)
{
m_activeValue = initActiveValue;
m_startValue = m_accumulatedValue;
qCDebug(lcDragAxis) << parent() << m_propertyName << active << ": init active" << m_activeValue
<< "target start" << m_startValue;
}
void QQuickDragAxis::updateValue(qreal activeValue, qreal accumulatedValue, qreal delta)
{
if (!m_enabled)
return;
m_activeValue = activeValue;
m_accumulatedValue = qBound(m_minimum, accumulatedValue, m_maximum);
qCDebug(lcDragAxis) << parent() << m_propertyName << "values: active" << activeValue
<< "accumulated" << m_accumulatedValue << "delta" << delta;
emit activeValueChanged(delta);
}
QT_END_NAMESPACE
#include "moc_qquickdragaxis_p.cpp"
|