File indexing completed on 2026-09-18 09:24:39
0001
0002
0003
0004
0005 #ifndef QEASINGCURVE_H
0006 #define QEASINGCURVE_H
0007
0008 #include <QtCore/qglobal.h>
0009
0010 QT_REQUIRE_CONFIG(easingcurve);
0011
0012 #include <QtCore/qcompare.h>
0013 #include <QtCore/qlist.h>
0014 #include <QtCore/qobjectdefs.h>
0015
0016 QT_BEGIN_NAMESPACE
0017
0018 class QEasingCurvePrivate;
0019 class QPointF;
0020 class Q_CORE_EXPORT QEasingCurve
0021 {
0022 Q_GADGET
0023 public:
0024 enum Type {
0025 Linear,
0026 InQuad, OutQuad, InOutQuad, OutInQuad,
0027 InCubic, OutCubic, InOutCubic, OutInCubic,
0028 InQuart, OutQuart, InOutQuart, OutInQuart,
0029 InQuint, OutQuint, InOutQuint, OutInQuint,
0030 InSine, OutSine, InOutSine, OutInSine,
0031 InExpo, OutExpo, InOutExpo, OutInExpo,
0032 InCirc, OutCirc, InOutCirc, OutInCirc,
0033 InElastic, OutElastic, InOutElastic, OutInElastic,
0034 InBack, OutBack, InOutBack, OutInBack,
0035 InBounce, OutBounce, InOutBounce, OutInBounce,
0036 InCurve, OutCurve, SineCurve, CosineCurve,
0037 BezierSpline, TCBSpline, Custom, NCurveTypes
0038 };
0039 Q_ENUM(Type)
0040
0041 QEasingCurve(Type type = Linear);
0042 QEasingCurve(const QEasingCurve &other);
0043 ~QEasingCurve();
0044
0045 QEasingCurve &operator=(const QEasingCurve &other)
0046 { if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; }
0047 QEasingCurve(QEasingCurve &&other) noexcept : d_ptr(other.d_ptr) { other.d_ptr = nullptr; }
0048 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QEasingCurve)
0049
0050 void swap(QEasingCurve &other) noexcept { qt_ptr_swap(d_ptr, other.d_ptr); }
0051
0052 #if QT_CORE_REMOVED_SINCE(6, 8)
0053 bool operator==(const QEasingCurve &other) const;
0054 inline bool operator!=(const QEasingCurve &other) const
0055 { return !(this->operator==(other)); }
0056 #endif
0057
0058 qreal amplitude() const;
0059 void setAmplitude(qreal amplitude);
0060
0061 qreal period() const;
0062 void setPeriod(qreal period);
0063
0064 qreal overshoot() const;
0065 void setOvershoot(qreal overshoot);
0066
0067 void addCubicBezierSegment(const QPointF &c1, const QPointF &c2, const QPointF &endPoint);
0068 void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b);
0069 QList<QPointF> toCubicSpline() const;
0070
0071 Type type() const;
0072 void setType(Type type);
0073 typedef qreal (*EasingFunction)(qreal progress);
0074 void setCustomType(EasingFunction func);
0075 EasingFunction customType() const;
0076
0077 qreal valueForProgress(qreal progress) const;
0078
0079 private:
0080 QEasingCurvePrivate *d_ptr;
0081 #ifndef QT_NO_DEBUG_STREAM
0082 friend Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
0083 #endif
0084 #ifndef QT_NO_DATASTREAM
0085 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve &);
0086 friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
0087 #endif
0088 friend Q_CORE_EXPORT bool
0089 comparesEqual(const QEasingCurve &lhs, const QEasingCurve &rhs);
0090 #if !QT_CORE_REMOVED_SINCE(6, 8)
0091 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QEasingCurve)
0092 #endif
0093 };
0094 Q_DECLARE_SHARED(QEasingCurve)
0095
0096 #ifndef QT_NO_DEBUG_STREAM
0097 Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
0098 #endif
0099
0100 #ifndef QT_NO_DATASTREAM
0101 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve &);
0102 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
0103 #endif
0104
0105 QT_END_NAMESPACE
0106
0107 #endif