Example #1
0
/*!
    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;
}
Example #2
0
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;
}
Example #3
0
/*!
    Sets the period to \a period.
    
    \sa period()
*/
void QtEasingCurve::setPeriod(qreal period)
{
    if (!d_ptr->config)
        d_ptr->config = curveToFunctionObject(d_ptr->type);        
    d_ptr->config->_p = period;
}
Example #4
0
/*!
    Sets the amplitude to \a amplitude.
    
    \sa amplitude()
*/
void QtEasingCurve::setAmplitude(qreal amplitude)
{
    if (!d_ptr->config)
        d_ptr->config = curveToFunctionObject(d_ptr->type);        
    d_ptr->config->_a = amplitude;
}
Example #5
0
/*!
    Sets the overshoot to \a overshoot.

    0 produces no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent.

    \sa overshoot()
*/
void QEasingCurve::setOvershoot(qreal overshoot)
{
    if (!d_ptr->config)
        d_ptr->config = curveToFunctionObject(d_ptr->type);
    d_ptr->config->_o = overshoot;
}