From 02c110e989c44dcc18c5f0498dbc01ead87e069f Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 21 Nov 2012 11:53:45 +0100 Subject: Prevent easing example warnings. examples/widgets/animation/easing was spitting out a lot of "QEasingCurve: Invalid tcb curve" warnings. The reason was that in case of the TCP curve we do not provide defaults. The function createEasingCurve() now provides reasonable values for the custom curves to show what is possible and how to use them. Change-Id: I880d8d0f0ce2872ce2019f7d2e000f4c4ce136e2 Reviewed-by: Mitch Curtis Reviewed-by: Alessandro Portale --- examples/widgets/animation/easing/window.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'examples/widgets') diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp index f5ff43905c..0a9df0f27e 100644 --- a/examples/widgets/animation/easing/window.cpp +++ b/examples/widgets/animation/easing/window.cpp @@ -75,6 +75,23 @@ Window::Window(QWidget *parent) startAnimation(); } +QEasingCurve createEasingCurve(QEasingCurve::Type curveType) +{ + QEasingCurve curve(curveType); + + if (curveType == QEasingCurve::BezierSpline) { + curve.addCubicBezierSegment(QPointF(0.4, 0.1), QPointF(0.6, 0.9), QPointF(1.0, 1.0)); + + } else if (curveType == QEasingCurve::TCBSpline) { + curve.addTCBSegment(QPointF(0.0, 0.0), 0, 0, 0); + curve.addTCBSegment(QPointF(0.3, 0.4), 0.2, 1, -0.2); + curve.addTCBSegment(QPointF(0.7, 0.6), -0.2, 1, 0.2); + curve.addTCBSegment(QPointF(1.0, 1.0), 0, 0, 0); + } + + return curve; +} + void Window::createCurveIcons() { QPixmap pix(m_iconSize); @@ -88,7 +105,7 @@ void Window::createCurveIcons() // Skip QEasingCurve::Custom for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush); - QEasingCurve curve((QEasingCurve::Type)i); + QEasingCurve curve = createEasingCurve((QEasingCurve::Type) i); painter.setPen(QColor(0, 0, 255, 64)); qreal xAxis = m_iconSize.height()/1.5; qreal yAxis = m_iconSize.width()/3; @@ -139,7 +156,7 @@ void Window::startAnimation() void Window::curveChanged(int row) { QEasingCurve::Type curveType = (QEasingCurve::Type)row; - m_anim->setEasingCurve(curveType); + m_anim->setEasingCurve(createEasingCurve(curveType)); m_anim->setCurrentTime(0); bool isElastic = curveType >= QEasingCurve::InElastic && curveType <= QEasingCurve::OutInElastic; -- cgit v1.2.3