diff options
author | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2012-11-21 11:53:45 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-23 17:04:00 +0100 |
commit | 02c110e989c44dcc18c5f0498dbc01ead87e069f (patch) | |
tree | 60bb42d01c158a101183b0495772ff9e15f327e7 /examples/widgets/animation/easing | |
parent | 601d99d062951f48d17ec0695189038cf80ad797 (diff) |
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 <mitch.curtis@digia.com>
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
Diffstat (limited to 'examples/widgets/animation/easing')
-rw-r--r-- | examples/widgets/animation/easing/window.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
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; |