Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickdragaxis.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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#include "qquickdragaxis_p.h"
5#include <QtQuick/qquickitem.h>
6#include <limits>
7
9
10Q_LOGGING_CATEGORY(lcDragAxis, "qt.quick.pointer.dragaxis")
11
12QQuickDragAxis::QQuickDragAxis(QQuickPointerHandler *handler, const QString &propertyName, qreal initValue)
13 : QObject(handler), m_accumulatedValue(initValue), m_propertyName(propertyName)
14{
15}
16
18{
19 if (m_minimum == minimum)
20 return;
21
22 m_minimum = minimum;
24}
25
27{
28 if (m_maximum == maximum)
29 return;
30
31 m_maximum = maximum;
33}
34
36{
37 if (m_enabled == enabled)
38 return;
39
40 m_enabled = enabled;
42}
43
44void QQuickDragAxis::onActiveChanged(bool active, qreal initActiveValue)
45{
46 m_activeValue = initActiveValue;
47 m_startValue = m_accumulatedValue;
48 qCDebug(lcDragAxis) << parent() << m_propertyName << active << ": init active" << m_activeValue
49 << "target start" << m_startValue;
50}
51
52void QQuickDragAxis::updateValue(qreal activeValue, qreal accumulatedValue, qreal delta)
53{
54 if (!m_enabled)
55 return;
56
57 m_activeValue = activeValue;
58 m_accumulatedValue = qBound(m_minimum, accumulatedValue, m_maximum);
59 qCDebug(lcDragAxis) << parent() << m_propertyName << "values: active" << activeValue
60 << "accumulated" << m_accumulatedValue << "delta" << delta;
61 emit activeValueChanged(delta);
62}
63
65
66#include "moc_qquickdragaxis_p.cpp"
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
void maximumChanged()
void onActiveChanged(bool active, qreal initActiveValue)
void updateValue(qreal activeValue, qreal accumulatedValue, qreal delta=0)
void minimumChanged()
void setEnabled(bool enabled)
void setMinimum(qreal minimum)
void setMaximum(qreal maximum)
void enabledChanged()
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
GLenum GLenum GLsizei const GLuint GLboolean enabled
#define emit
double qreal
Definition qtypes.h:187