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
qeasingcurve.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 QEASINGCURVE_H
6#define QEASINGCURVE_H
7
8#include <QtCore/qglobal.h>
9
11
12#include <QtCore/qcompare.h>
13#include <QtCore/qlist.h>
14#include <QtCore/qobjectdefs.h>
15
16QT_BEGIN_NAMESPACE
17
18class QEasingCurvePrivate;
19class QPointF;
20class Q_CORE_EXPORT QEasingCurve
21{
22 Q_GADGET
23public:
24 enum Type {
25 Linear,
26 InQuad, OutQuad, InOutQuad, OutInQuad,
27 InCubic, OutCubic, InOutCubic, OutInCubic,
28 InQuart, OutQuart, InOutQuart, OutInQuart,
29 InQuint, OutQuint, InOutQuint, OutInQuint,
30 InSine, OutSine, InOutSine, OutInSine,
31 InExpo, OutExpo, InOutExpo, OutInExpo,
32 InCirc, OutCirc, InOutCirc, OutInCirc,
33 InElastic, OutElastic, InOutElastic, OutInElastic,
34 InBack, OutBack, InOutBack, OutInBack,
35 InBounce, OutBounce, InOutBounce, OutInBounce,
36 InCurve, OutCurve, SineCurve, CosineCurve,
37 BezierSpline, TCBSpline, Custom, NCurveTypes
38 };
39 Q_ENUM(Type)
40
41 QEasingCurve(Type type = Linear);
42 QEasingCurve(const QEasingCurve &other);
43 ~QEasingCurve();
44
45 QEasingCurve &operator=(const QEasingCurve &other)
46 { if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; }
47 QEasingCurve(QEasingCurve &&other) noexcept : d_ptr(other.d_ptr) { other.d_ptr = nullptr; }
48 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QEasingCurve)
49
50 void swap(QEasingCurve &other) noexcept { qt_ptr_swap(d_ptr, other.d_ptr); }
51
52#if QT_CORE_REMOVED_SINCE(6, 8)
53 bool operator==(const QEasingCurve &other) const;
54 inline bool operator!=(const QEasingCurve &other) const
55 { return !(this->operator==(other)); }
56#endif
57
58 qreal amplitude() const;
59 void setAmplitude(qreal amplitude);
60
61 qreal period() const;
62 void setPeriod(qreal period);
63
64 qreal overshoot() const;
65 void setOvershoot(qreal overshoot);
66
67 void addCubicBezierSegment(const QPointF &c1, const QPointF &c2, const QPointF &endPoint);
68 void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b);
69 QList<QPointF> toCubicSpline() const;
70
71 Type type() const;
72 void setType(Type type);
73 typedef qreal (*EasingFunction)(qreal progress);
74 void setCustomType(EasingFunction func);
75 EasingFunction customType() const;
76
77 qreal valueForProgress(qreal progress) const;
78
79private:
80 QEasingCurvePrivate *d_ptr;
81#ifndef QT_NO_DEBUG_STREAM
82 friend Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
83#endif
84#ifndef QT_NO_DATASTREAM
85 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve &);
86 friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
87#endif
88 friend Q_CORE_EXPORT bool
89 comparesEqual(const QEasingCurve &lhs, const QEasingCurve &rhs);
90#if !QT_CORE_REMOVED_SINCE(6, 8)
91 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QEasingCurve)
92#endif
93};
95
96#ifndef QT_NO_DEBUG_STREAM
97Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
98#endif
99
100#ifndef QT_NO_DATASTREAM
101Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve &);
102Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
103#endif
104
105QT_END_NAMESPACE
106
107#endif
\inmodule QtCore\reentrant
Definition qdatastream.h:50
virtual ~QEasingCurveFunction()
QEasingCurveFunction(QEasingCurve::Type type, qreal period=0.3, qreal amplitude=1.0, qreal overshoot=1.70158)
virtual qreal value(qreal t)
QList< QPointF > _bezierCurves
bool fuzzyCompare(const QEasingCurveFunction &other) const noexcept
QEasingCurveFunction(const QEasingCurveFunction &)=default
virtual QEasingCurveFunction * clone() const
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qpoint.h:232
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
static QList< QPointF > tcbToBezier(const TCBPoints &tcbPoints)
static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve)
Q_DECLARE_TYPEINFO(TCBPoint, Q_PRIMITIVE_TYPE)
static QT_BEGIN_NAMESPACE constexpr bool isConfigFunction(QEasingCurve::Type type)
QDataStream & operator<<(QDataStream &stream, QEasingCurveFunction *func)
QList< TCBPoint > TCBPoints
QDataStream & operator>>(QDataStream &stream, QEasingCurveFunction *func)
QDataStream & operator>>(QDataStream &stream, TCBPoint &point)
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
QDataStream & operator<<(QDataStream &stream, const TCBPoint &point)
QT_REQUIRE_CONFIG(easingcurve)
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
bool comparesEqual(const QFileInfo &lhs, const QFileInfo &rhs)
#define M_PI
Definition qmath.h:200
QDataStream & operator<<(QDataStream &stream, const QImage &image)
[0]
Definition qimage.cpp:4009
QDataStream & operator>>(QDataStream &stream, QImage &image)
Definition qimage.cpp:4035
qreal value(qreal t) override
BackEase * clone() const override
BackEase(QEasingCurve::Type type)
static float _fast_cbrt(float x)
static qreal evaluateDerivateForX(const SingleCubicBezier &singleCubicBezier, qreal t)
static qreal evaluateForX(const SingleCubicBezier &singleCubicBezier, qreal t)
static qreal _acos(qreal x)
static void cosacos(qreal x, qreal &s1, qreal &s2, qreal &s3)
static qreal _cos(qreal x)
static qreal _cbrt(qreal d)
static qreal newtonIteration(const SingleCubicBezier &singleCubicBezier, qreal t, qreal x)
static qreal evaluateSegmentForY(const SingleCubicBezier &singleCubicBezier, qreal t)
QList< SingleCubicBezier > _curves
static qreal singleRealSolutionForCubic(qreal a, qreal b, qreal c)
qreal value(qreal x) override
void getBezierSegment(SingleCubicBezier *&singleCubicBezier, qreal x)
static qreal findTForX(const SingleCubicBezier &singleCubicBezier, qreal x)
BezierEase(QEasingCurve::Type type=QEasingCurve::BezierSpline)
BezierEase * clone() const override
QList< qreal > _intervals
static double _fast_cbrt(double d)
static bool inRange(qreal f)
static bool almostZero(qreal value)
BounceEase(QEasingCurve::Type type)
BounceEase * clone() const override
qreal value(qreal t) override
ElasticEase * clone() const override
qreal value(qreal t) override
ElasticEase(QEasingCurve::Type type)
TCBEase * clone() const override
qreal value(qreal x) override
friend bool operator==(const TCBPoint &lhs, const TCBPoint &rhs) noexcept
QPointF _point