7#include <QtCore/qrect.h>
8#include <QtCore/qline.h>
9#include <QtCore/qmutex.h>
10#include <QtCore/private/qlocking_p.h>
114 return p1.first <
p2.first;
159 for (
int i = 0;
i < keyValues.size(); ++
i) {
161 pair.second.convert(
type);
205 keyValues.constEnd(),
206 std::pair{progress, QVariant{}},
210 if (
it->first == 0 && keyValues.
size() > 1) {
219 if (
it->first == 1 && keyValues.
size() > 1) {
236 setCurrentValueForProgress(progress);
245 const qreal localProgress =
246 qIsNull(progress - startProgress) ? 0.0
247 : (progress - startProgress) / (endProgress - startProgress);
255 if (!changedSignalIndex.loadRelaxed()) {
257 changedSignalIndex.testAndSetRelaxed(0,
signalIndex(
"valueChanged(QVariant)"));
267 const auto sought = std::pair{step,
QVariant()};
268 const auto result = std::lower_bound(keyValues.cbegin(), keyValues.cend(), sought,
279 qWarning(
"QVariantAnimation::setValueAt: invalid step = %f", step);
286 if (
result == keyValues.end() ||
result->first != step) {
287 keyValues.insert(
result, pair);
357 d->easing.removeBindingUnlessInWrapper();
359 d->easing.setValueBypassingBindings(
easing);
360 d->recalculateCurrentInterval();
410 if (interpolationType >= interpolators->size())
411 interpolators->resize(interpolationType + 1);
412 interpolators->replace(interpolationType,
func);
428 if (interpolationType < interpolators->
size()) {
429 ret = interpolators->at(interpolationType);
434 switch(interpolationType)
438 case QMetaType::UInt:
440 case QMetaType::Double:
442 case QMetaType::Float:
444 case QMetaType::QLine:
446 case QMetaType::QLineF:
448 case QMetaType::QPoint:
450 case QMetaType::QPointF:
452 case QMetaType::QSize:
454 case QMetaType::QSizeF:
456 case QMetaType::QRect:
458 case QMetaType::QRectF:
484 qWarning(
"QVariantAnimation::setDuration: cannot set a negative duration");
487 d->duration.removeBindingUnlessInWrapper();
488 if (
d->duration.valueBypassingBindings() != msecs) {
489 d->duration.setValueBypassingBindings(msecs);
490 d->recalculateCurrentInterval();
491 d->duration.notify();
550 return d_func()->valueAt(step);
572 d_func()->setValueAt(step,
value);
582 return d_func()->keyValues;
596 d->recalculateCurrentInterval(
true);
620 if (!
d->currentValue.isValid())
673 d_func()->recalculateCurrentInterval();
678#include "moc_qvariantanimation.cpp"
State
This enum describes the state of the animation.
bool event(QEvent *event) override
\reimp
qreal valueForProgress(qreal progress) const
Return the effective progress for the easing curve at progress.
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
\inmodule QtCore\compares equality \compareswith equality QLineF \endcompareswith
bool isSignalConnected(uint signalIdx, bool checkDeclarative=true) const
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr void setCoords(int x1, int y1, int x2, int y2) noexcept
Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its botto...
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
QVariantAnimationPrivate()
void setCurrentValueForProgress(const qreal progress)
void updateInterpolator()
Q_OBJECT_COMPAT_PROPERTY(QVariantAnimationPrivate, int, duration, &QVariantAnimationPrivate::setDuration) QVariantAnimation QVariantAnimation::Interpolato interpolator)
void recalculateCurrentInterval(bool force=false)
void setValueAt(qreal, const QVariant &)
struct QVariantAnimationPrivate::@3 currentInterval
QVariant valueAt(qreal step) const
void setDefaultStartEndValue(const QVariant &value)
static Q_CORE_EXPORT QVariantAnimation::Interpolator getInterpolator(int interpolationType)
void convertValues(int t)
QVariant defaultStartEndValue
int duration
the duration of the animation
KeyValues keyValues() const
Returns the key frames of this animation.
void setStartValue(const QVariant &value)
void setEasingCurve(const QEasingCurve &easing)
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override
\reimp
QVariant(* Interpolator)(const void *from, const void *to, qreal progress)
QEasingCurve easingCurve
the easing curve of the animation
QVariant currentValue
the current value of the animation.
virtual void updateCurrentValue(const QVariant &value)
This virtual function is called every time the animation's current value changes.
QVariant keyValueAt(qreal step) const
Returns the key frame value for the given step.
void setKeyValues(const KeyValues &values)
Replaces the current set of key frames with the given keyValues.
void valueChanged(const QVariant &value)
QVariantAnimation emits this signal whenever the current value changes.
QVariantAnimation(QObject *parent=nullptr)
Construct a QVariantAnimation object.
QVariant startValue
the optional start value of the animation
QBindable< int > bindableDuration()
void updateCurrentTime(int) override
\reimp
void setDuration(int msecs)
std::pair< qreal, QVariant > KeyValue
This is a typedef for std::pair<qreal, QVariant>.
virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const
This virtual function returns the linear interpolation between variants from and to,...
QVariant endValue
the end value of the animation
bool event(QEvent *event) override
\reimp
void setKeyValueAt(qreal step, const QVariant &value)
Creates a key frame at the given step with the given value.
QBindable< QEasingCurve > bindableEasingCurve()
~QVariantAnimation()
Destroys the animation.
void setEndValue(const QVariant &value)
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
const void * constData() const
QSet< QString >::iterator it
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qIsNull(qfloat16 f) noexcept
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
GLfixed GLfixed GLfixed y2
GLdouble GLdouble GLdouble GLdouble q
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
static double currentTime()
Q_INLINE_TEMPLATE QRect _q_interpolate(const QRect &f, const QRect &t, qreal progress)
static bool animationValueLessThan(const QVariantAnimation::KeyValue &p1, const QVariantAnimation::KeyValue &p2)
static QVariant defaultInterpolator(const void *, const void *, qreal)
static Q_CONSTINIT QBasicMutex registeredInterpolatorsMutex
static QVariantAnimation::Interpolator castToInterpolator(QVariant(*func)(const T &from, const T &to, qreal progress))
QList< QVariantAnimation::Interpolator > QInterpolatorVector