void QEasingCurvePrivate::setType_helper(QEasingCurve::Type newType) { qreal amp = -1.0; qreal period = -1.0; qreal overshoot = -1.0; if (config) { amp = config->_a; period = config->_p; overshoot = config->_o; delete config; config = 0; } if (isConfigFunction(newType) || (amp != -1.0) || (period != -1.0) || (overshoot != -1.0)) { config = curveToFunctionObject(newType); if (amp != -1.0) config->_a = amp; if (period != -1.0) config->_p = period; if (overshoot != -1.0) config->_o = overshoot; func = 0; } else if (newType != QEasingCurve::Custom) { func = curveToFunc(newType); } Q_ASSERT((func == 0) == (config != 0)); type = newType; }
/*! Sets the type of the easing curve to \a type. */ void QtEasingCurve::setType(Type type) { qreal amp = -1.0; qreal period = -1.0; if (d_ptr->config) { amp = d_ptr->config->_a; period = d_ptr->config->_p; delete d_ptr->config; d_ptr->config = 0; } if (isConfigFunction(type) || (amp != -1.0) || (period != -1.0)) { d_ptr->config = curveToFunctionObject(type); if (amp) d_ptr->config->_a = amp; if (period) d_ptr->config->_p = period; } else { d_ptr->func = curveToFunc(type); if (!d_ptr->func) { qWarning("QtEasingCurve: Invalid curve type %d", type); return; } } d_ptr->type = type; }
qreal QEasingCurveFunction::value(qreal t) { QEasingCurve::EasingFunction func = curveToFunc(_t); return func(t); }