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
9QT_REQUIRE_CONFIG(easingcurve);
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(other&: 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(lhs&: d_ptr, rhs&: 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};
93Q_DECLARE_SHARED(QEasingCurve)
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
107

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/corelib/tools/qeasingcurve.h