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