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