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
qvariantanimation_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QVARIANTANIMATION_P_H
6#define QVARIANTANIMATION_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
20#include <QtCore/qeasingcurve.h>
21#include <QtCore/qmetaobject.h>
22
23#include "private/qabstractanimation_p.h"
24#include "private/qproperty_p.h"
25
26#include <type_traits>
27
29
30QT_BEGIN_NAMESPACE
31
32class QVariantAnimationPrivate : public QAbstractAnimationPrivate
33{
34 Q_DECLARE_PUBLIC(QVariantAnimation)
35public:
36
37 QVariantAnimationPrivate();
38 ~QVariantAnimationPrivate() override;
39
40 static QVariantAnimationPrivate *get(QVariantAnimation *q)
41 {
42 return q->d_func();
43 }
44
45 void setDefaultStartEndValue(const QVariant &value);
46
47
48 QVariant currentValue;
49 QVariant defaultStartEndValue;
50
51 //this is used to keep track of the KeyValue interval in which we currently are
52 struct
53 {
54 QVariantAnimation::KeyValue start, end;
55 } currentInterval;
56
57 void setEasingCurve(const QEasingCurve &easing) { q_func()->setEasingCurve(easing); }
58 Q_OBJECT_COMPAT_PROPERTY(QVariantAnimationPrivate, QEasingCurve, easing,
59 &QVariantAnimationPrivate::setEasingCurve)
60
61 void setDuration(int msecs) { q_func()->setDuration(msecs); }
62 Q_OBJECT_COMPAT_PROPERTY(QVariantAnimationPrivate, int, duration,
63 &QVariantAnimationPrivate::setDuration)
64
65 QVariantAnimation::KeyValues keyValues;
66 QVariantAnimation::Interpolator interpolator;
67
68 void setCurrentValueForProgress(const qreal progress);
69 void recalculateCurrentInterval(bool force=false);
70 void setValueAt(qreal, const QVariant &);
71 QVariant valueAt(qreal step) const;
72 void convertValues(int t);
73
74 void updateInterpolator();
75
76 //XXX this is needed by dui
77 static Q_CORE_EXPORT QVariantAnimation::Interpolator getInterpolator(int interpolationType);
78};
79
80//this should make the interpolation faster
81template<typename T>
82typename std::enable_if<std::is_unsigned<T>::value, T>::type
83_q_interpolate(const T &f, const T &t, qreal progress)
84{
85 return T(f + t * progress - f * progress);
86}
87
88// the below will apply also to all non-arithmetic types
89template<typename T>
90typename std::enable_if<!std::is_unsigned<T>::value, T>::type
91_q_interpolate(const T &f, const T &t, qreal progress)
92{
93 return T(f + (t - f) * progress);
94}
95
96template<typename T > inline QVariant _q_interpolateVariant(const T &from, const T &to, qreal progress)
97{
98 return _q_interpolate(from, to, progress);
99}
100
101
102QT_END_NAMESPACE
103
104#endif //QVARIANTANIMATION_P_H
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
Definition qline.h:193
\inmodule QtCore\compares equality \compareswith equality QLineF \endcompareswith
Definition qline.h:19
\inmodule QtCore\reentrant
Definition qrect.h:509
\inmodule QtCore\reentrant
Definition qrect.h:31
\inmodule QtCore
QT_REQUIRE_CONFIG(animation)
static bool animationValueLessThan(const QVariantAnimation::KeyValue &p1, const QVariantAnimation::KeyValue &p2)
static QVariant defaultInterpolator(const void *, const void *, qreal)
QList< QVariantAnimation::Interpolator > QInterpolatorVector
static QVariantAnimation::Interpolator castToInterpolator(QVariant(*func)(const T &from, const T &to, qreal progress))
void qRegisterAnimationInterpolator(QVariant(*func)(const T &from, const T &to, qreal progress))
QVariant _q_interpolateVariant(const T &from, const T &to, qreal progress)
std::enable_if<!std::is_unsigned< T >::value, T >::type _q_interpolate(const T &f, const T &t, qreal progress)
std::enable_if< std::is_unsigned< T >::value, T >::type _q_interpolate(const T &f, const T &t, qreal progress)