SlideShare una empresa de Scribd logo
1 de 31
Animation Framework
                            3/4/2010
A step towards modern UIs
Leonardo Sobral Cunha


• AA troll
   – widgets team

• before, 3 years in INdT
   – Nokia Technology Institute in Brazil

   – various projects on embedded
       • maemo: Canola, QEdje

       • together with a big team of designers




                                                 1
Thierry Bastian


• Software engineer

• Moved to Oslo in 2006

• Member of the widget team

• Participations in
   – Animation API

   – Multimedia Framework




                              2
Animation Agenda


• Introduction

• Architecture

• Usage
   – QGraphicsView

   – States & Transitions

• Conclusion




                            3
Introduction: animations in Qt < 4.6


• What do we have today in Qt?
   – QTimer / QTimeLine

   – QGraphicsItemAnimation

   – QMainWindow

   – Different animations in the QStyles

   – ...




                                           4
Introduction: why?


              “Simplify the creation of dynamic UIs

         by improving the support for animations in Qt”




• New feature of Qt 4.6
   – part of Qt Kinetic




                                                          5
Introduction: what is it all about?


• Goals
   – Good API

   – Simplify animations

   – Focus on performance

• Animates
   – QWidgets (QObjects)

   – QGraphicsItems




                                      6
Animation Agenda


• Introduction

• Architecture

• Usage
   – QGraphicsView

   – States & Transitions

• Conclusion




                            7
Animation classes

                     QAbstractAnimation




                                   QVariantAnimation
       QAnimationGroup




                                  QPropertyAnimation
                                          animates




                                          Qobject
                                            …


                                                       8
Animations: QAbstractAnimation


• base-class for the animations

• completely abstracts the timer/timerEvent

• synchronized

• has all the basic controls: start, stop, pause




                                                   9
Animations: QAbstractAnimation


• Properties
   – Loop count

   – Duration

   – Direction

   – Current time


      0 (start)                  duration (end)
                                                  time




                    looping


                                                         10
Animations: QVariantAnimation


• QVariant-based

• has startValue and endValue
   – and key frames

• does the linear interpolation
   – Also allows to set your own interpolator

• easingCurve

• reimplement this class to animate non-QObject classes




                                                          11
Animations: QPropertyAnimation


• Works on Qt properties
    – target property of an object

    – picks up automatically the start value

    – dynamic properties are also supported

• This is the class you want to use!

QPropertyAnimation *anim = new QPropertyAnimation(item, “opacity”);
anim->setEndValue(0);
anim->start(QPropertyAnimation::DeleteWhenStopped);




                                                                      12
Animations: QEasingCurve


• Property of variant animation

• Many default curves are provided

• You can define your own curves



QPropertyAnimation *anim = new QPropertyAnimation(item, “opacity”);
anim->setEasingCurve(QEasingCurve::InOutSine);




                                                                      13
Animations: QAnimationGroup


• Container for animations

• parallel or sequential

• Duration defined by the content

       Sequential group
                           Parallel Group

                           Animation
         Animation                          Animation

                             Animation




                                                        14
Animations: managing memory


• We use parent-child relationship of QObject

• Group takes ownership of child animations

• Animation can autodelete
    – through deletePolicy




QPropertyAnimation *anim = new QPropertyAnimation(item, “opacity”);
anim->setEndValue(0);
anim->start(QPropertyAnimation::DeleteWhenStopped);




                                                                      15
Demo animations




                  16
Animation Agenda


• Introduction

• Architecture

• Usage
   – QGraphicsView

   – States & Transitions

• Conclusion




                            17
Usage: QGraphicsView


• How do we animate QGraphicsItem?
  – QGraphicsItem doesn’t have a property system

• Options
  – QGraphicsObject

  – Inherit from QObject

  – Use QGraphicsTransform




                                                   18
Animations: QGraphicsItem


• New class QGraphicsObject
    – inherits from QObject and QGraphicsItem

    – got basic properties for animations

• QGraphicsItemAnimation is deprecated



QGraphicsObject *item = …
…
QPropertyAnimation *anim = new QPropertyAnimation(item, “rotation”);
anim->setTargetValue(360);
anim->start(QPropertyAnimation::DeleteWhenFinished);




                                                                       19
Animations : QGraphicsTransform


• For more complex 3D (2.5D) animations

• QObject-based

• Each QGraphicsItem has a list of QGraphicsTransform

 QGraphicsItem *item = …
 QGraphicsRotation *rotation = new QGraphicsRotation(Qt::YAxis);
 item->setTransformations(…);
 …
 QPropertyAnimation *anim =
                    new QPropertyAnimation(rotation, “angle”);
 anim->setTargetValue(360);
 anim->start(QPropertyAnimation::DeleteWhenStopped);




                                                                   20
Usage: QGraphicsView


• Preferred solution is to use QGraphicsObject
   – common base class for all graphical items

   – we are doing that too!




                                                 21
Animations : demo




                    22
Animation Agenda


• Introduction

• Architecture

• Usage
   – QGraphicsView

   – States & Transitions

• Conclusion




                            23
Using a statemachine for your UI



• Each state defines a set of property values on items
   – position, scale, rotation, opacity, …
• A transition between states can be animated




                                                         24
States & Transitions


• Define states for components of your application




           State 1                           State 2




                                                       25
Animated transitions


                        addAnimation()
     QTransition                         QAbstractAnimation




      addTransition()
                              QAnimationGroup         QPropertyAnimation


                                                              animates


       QState
                                                          QObject
                                                       QGraphicsObject
                                                             …



                                                                           26
States & Transitions : demo


• Almost all animation examples use states and transitions




                                                             27
Animation Agenda


• Introduction

• Architecture

• Usage
   – QGraphicsView

   – States & Transitions

• Conclusion




                            28
Conclusion


• Part of 4.6

• Good integration with statemachine API

• Used by declarative UI

• Ongoing work to animate layouts




                                           29
Thanks for you attention




                    Q&A



                           30

Más contenido relacionado

La actualidad más candente

Real-Time 3D Programming in Scala
Real-Time 3D Programming in ScalaReal-Time 3D Programming in Scala
Real-Time 3D Programming in Scala
Hideyuki Takeuchi
 

La actualidad más candente (20)

Qt on Real Time Operating Systems
Qt on Real Time Operating SystemsQt on Real Time Operating Systems
Qt on Real Time Operating Systems
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2
 
Qt State Machine Framework
Qt State Machine FrameworkQt State Machine Framework
Qt State Machine Framework
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
 
Petri Niemi Qt Advanced Part 1
Petri Niemi Qt Advanced Part 1Petri Niemi Qt Advanced Part 1
Petri Niemi Qt Advanced Part 1
 
Qt Graphics View Framework (Qt Developers Meetup Isreal)
Qt Graphics View Framework (Qt Developers Meetup Isreal)Qt Graphics View Framework (Qt Developers Meetup Isreal)
Qt Graphics View Framework (Qt Developers Meetup Isreal)
 
Graphics programming in open gl
Graphics programming in open glGraphics programming in open gl
Graphics programming in open gl
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL Transformation
 
Open gl
Open glOpen gl
Open gl
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
 
OpenGL L02-Transformations
OpenGL L02-TransformationsOpenGL L02-Transformations
OpenGL L02-Transformations
 
The Next Generation Qt Item Views
The Next Generation Qt Item ViewsThe Next Generation Qt Item Views
The Next Generation Qt Item Views
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
iOS OpenGL
iOS OpenGLiOS OpenGL
iOS OpenGL
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
 
Real-Time 3D Programming in Scala
Real-Time 3D Programming in ScalaReal-Time 3D Programming in Scala
Real-Time 3D Programming in Scala
 
OpenGL Basics
OpenGL BasicsOpenGL Basics
OpenGL Basics
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threads
 

Destacado

Destacado (6)

Shipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for SymbianShipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for Symbian
 
The Future of Qt Widgets
The Future of Qt WidgetsThe Future of Qt Widgets
The Future of Qt Widgets
 
Meet Qt
Meet QtMeet Qt
Meet Qt
 
KDE Plasma for Mobile Phones
KDE Plasma for Mobile PhonesKDE Plasma for Mobile Phones
KDE Plasma for Mobile Phones
 
Usage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP LanguagesUsage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP Languages
 
Sap Business Objects solutioning Framework architecture
Sap Business Objects solutioning Framework architectureSap Business Objects solutioning Framework architecture
Sap Business Objects solutioning Framework architecture
 

Similar a Animation Framework: A Step Towards Modern UIs

Qt Itemviews, The Next Generation
Qt Itemviews, The Next GenerationQt Itemviews, The Next Generation
Qt Itemviews, The Next Generation
Marius Bugge Monsen
 
Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)
Marakana Inc.
 
下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development
csdnmobile
 
Qt Itemviews, The Next Generation (Bossa09)
Qt Itemviews, The Next Generation (Bossa09)Qt Itemviews, The Next Generation (Bossa09)
Qt Itemviews, The Next Generation (Bossa09)
Marius Bugge Monsen
 
Core animation taobao
Core animation taobaoCore animation taobao
Core animation taobao
yarshure Kong
 

Similar a Animation Framework: A Step Towards Modern UIs (20)

Starting Core Animation
Starting Core AnimationStarting Core Animation
Starting Core Animation
 
Witekio custom modern qt quick components
Witekio custom modern qt quick componentsWitekio custom modern qt quick components
Witekio custom modern qt quick components
 
Core Animation
Core AnimationCore Animation
Core Animation
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part I
 
Qt Itemviews, The Next Generation
Qt Itemviews, The Next GenerationQt Itemviews, The Next Generation
Qt Itemviews, The Next Generation
 
Core animation
Core animationCore animation
Core animation
 
Advanced Visualization with OpenGL in Oil & Gas
Advanced Visualization with OpenGL in Oil & GasAdvanced Visualization with OpenGL in Oil & Gas
Advanced Visualization with OpenGL in Oil & Gas
 
Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)
 
下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4
 
CocoaHeads Paris - CATransaction: What the flush?!
CocoaHeads Paris - CATransaction: What the flush?!CocoaHeads Paris - CATransaction: What the flush?!
CocoaHeads Paris - CATransaction: What the flush?!
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
 
Qt Itemviews, The Next Generation (Bossa09)
Qt Itemviews, The Next Generation (Bossa09)Qt Itemviews, The Next Generation (Bossa09)
Qt Itemviews, The Next Generation (Bossa09)
 
Iagc2
Iagc2Iagc2
Iagc2
 
Petri Niemi Qt Web Kit
Petri Niemi Qt Web KitPetri Niemi Qt Web Kit
Petri Niemi Qt Web Kit
 
QtQuick Day 2
QtQuick Day 2QtQuick Day 2
QtQuick Day 2
 
Core animation taobao
Core animation taobaoCore animation taobao
Core animation taobao
 
iOS Core Animation
iOS Core AnimationiOS Core Animation
iOS Core Animation
 
Enhancing UI/UX using Java animations
Enhancing UI/UX using Java animationsEnhancing UI/UX using Java animations
Enhancing UI/UX using Java animations
 
Optimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based ApplicationsOptimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based Applications
 

Más de account inactive

Más de account inactive (17)

Developments in The Qt WebKit Integration
Developments in The Qt WebKit IntegrationDevelopments in The Qt WebKit Integration
Developments in The Qt WebKit Integration
 
Qt Kwan-Do
Qt Kwan-DoQt Kwan-Do
Qt Kwan-Do
 
Development with Qt for Windows CE
Development with Qt for Windows CEDevelopment with Qt for Windows CE
Development with Qt for Windows CE
 
Translating Qt Applications
Translating Qt ApplicationsTranslating Qt Applications
Translating Qt Applications
 
Qt Creator Bootcamp
Qt Creator BootcampQt Creator Bootcamp
Qt Creator Bootcamp
 
Mobile Development with Qt for Symbian
Mobile Development with Qt for SymbianMobile Development with Qt for Symbian
Mobile Development with Qt for Symbian
 
How to Make Your Qt App Look Native
How to Make Your Qt App Look NativeHow to Make Your Qt App Look Native
How to Make Your Qt App Look Native
 
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
 
The Mobility Project
The Mobility ProjectThe Mobility Project
The Mobility Project
 
Qt Licensing Explained
Qt Licensing ExplainedQt Licensing Explained
Qt Licensing Explained
 
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization SoftwareCase Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
 
Case Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded ProcessorsCase Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded Processors
 
OGRE: Qt & OGRE for Multimedia Creation
OGRE: Qt & OGRE for Multimedia CreationOGRE: Qt & OGRE for Multimedia Creation
OGRE: Qt & OGRE for Multimedia Creation
 
HGZ Kaffeemaschinen & Qt Speak Coffee
HGZ Kaffeemaschinen & Qt Speak CoffeeHGZ Kaffeemaschinen & Qt Speak Coffee
HGZ Kaffeemaschinen & Qt Speak Coffee
 
Discover Qt Learning and Certification
Discover Qt Learning and CertificationDiscover Qt Learning and Certification
Discover Qt Learning and Certification
 
Accelerating performance on Qt and WebKit for the MIPS architecture
Accelerating performance on Qt and WebKit for the MIPS architectureAccelerating performance on Qt and WebKit for the MIPS architecture
Accelerating performance on Qt and WebKit for the MIPS architecture
 
Qt Experiences on NXP's Connetcted TV Platforms
Qt Experiences on NXP's Connetcted TV PlatformsQt Experiences on NXP's Connetcted TV Platforms
Qt Experiences on NXP's Connetcted TV Platforms
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Animation Framework: A Step Towards Modern UIs

  • 1. Animation Framework 3/4/2010 A step towards modern UIs
  • 2. Leonardo Sobral Cunha • AA troll – widgets team • before, 3 years in INdT – Nokia Technology Institute in Brazil – various projects on embedded • maemo: Canola, QEdje • together with a big team of designers 1
  • 3. Thierry Bastian • Software engineer • Moved to Oslo in 2006 • Member of the widget team • Participations in – Animation API – Multimedia Framework 2
  • 4. Animation Agenda • Introduction • Architecture • Usage – QGraphicsView – States & Transitions • Conclusion 3
  • 5. Introduction: animations in Qt < 4.6 • What do we have today in Qt? – QTimer / QTimeLine – QGraphicsItemAnimation – QMainWindow – Different animations in the QStyles – ... 4
  • 6. Introduction: why? “Simplify the creation of dynamic UIs by improving the support for animations in Qt” • New feature of Qt 4.6 – part of Qt Kinetic 5
  • 7. Introduction: what is it all about? • Goals – Good API – Simplify animations – Focus on performance • Animates – QWidgets (QObjects) – QGraphicsItems 6
  • 8. Animation Agenda • Introduction • Architecture • Usage – QGraphicsView – States & Transitions • Conclusion 7
  • 9. Animation classes QAbstractAnimation QVariantAnimation QAnimationGroup QPropertyAnimation animates Qobject … 8
  • 10. Animations: QAbstractAnimation • base-class for the animations • completely abstracts the timer/timerEvent • synchronized • has all the basic controls: start, stop, pause 9
  • 11. Animations: QAbstractAnimation • Properties – Loop count – Duration – Direction – Current time 0 (start) duration (end) time looping 10
  • 12. Animations: QVariantAnimation • QVariant-based • has startValue and endValue – and key frames • does the linear interpolation – Also allows to set your own interpolator • easingCurve • reimplement this class to animate non-QObject classes 11
  • 13. Animations: QPropertyAnimation • Works on Qt properties – target property of an object – picks up automatically the start value – dynamic properties are also supported • This is the class you want to use! QPropertyAnimation *anim = new QPropertyAnimation(item, “opacity”); anim->setEndValue(0); anim->start(QPropertyAnimation::DeleteWhenStopped); 12
  • 14. Animations: QEasingCurve • Property of variant animation • Many default curves are provided • You can define your own curves QPropertyAnimation *anim = new QPropertyAnimation(item, “opacity”); anim->setEasingCurve(QEasingCurve::InOutSine); 13
  • 15. Animations: QAnimationGroup • Container for animations • parallel or sequential • Duration defined by the content Sequential group Parallel Group Animation Animation Animation Animation 14
  • 16. Animations: managing memory • We use parent-child relationship of QObject • Group takes ownership of child animations • Animation can autodelete – through deletePolicy QPropertyAnimation *anim = new QPropertyAnimation(item, “opacity”); anim->setEndValue(0); anim->start(QPropertyAnimation::DeleteWhenStopped); 15
  • 18. Animation Agenda • Introduction • Architecture • Usage – QGraphicsView – States & Transitions • Conclusion 17
  • 19. Usage: QGraphicsView • How do we animate QGraphicsItem? – QGraphicsItem doesn’t have a property system • Options – QGraphicsObject – Inherit from QObject – Use QGraphicsTransform 18
  • 20. Animations: QGraphicsItem • New class QGraphicsObject – inherits from QObject and QGraphicsItem – got basic properties for animations • QGraphicsItemAnimation is deprecated QGraphicsObject *item = … … QPropertyAnimation *anim = new QPropertyAnimation(item, “rotation”); anim->setTargetValue(360); anim->start(QPropertyAnimation::DeleteWhenFinished); 19
  • 21. Animations : QGraphicsTransform • For more complex 3D (2.5D) animations • QObject-based • Each QGraphicsItem has a list of QGraphicsTransform QGraphicsItem *item = … QGraphicsRotation *rotation = new QGraphicsRotation(Qt::YAxis); item->setTransformations(…); … QPropertyAnimation *anim = new QPropertyAnimation(rotation, “angle”); anim->setTargetValue(360); anim->start(QPropertyAnimation::DeleteWhenStopped); 20
  • 22. Usage: QGraphicsView • Preferred solution is to use QGraphicsObject – common base class for all graphical items – we are doing that too! 21
  • 24. Animation Agenda • Introduction • Architecture • Usage – QGraphicsView – States & Transitions • Conclusion 23
  • 25. Using a statemachine for your UI • Each state defines a set of property values on items – position, scale, rotation, opacity, … • A transition between states can be animated 24
  • 26. States & Transitions • Define states for components of your application State 1 State 2 25
  • 27. Animated transitions addAnimation() QTransition QAbstractAnimation addTransition() QAnimationGroup QPropertyAnimation animates QState QObject QGraphicsObject … 26
  • 28. States & Transitions : demo • Almost all animation examples use states and transitions 27
  • 29. Animation Agenda • Introduction • Architecture • Usage – QGraphicsView – States & Transitions • Conclusion 28
  • 30. Conclusion • Part of 4.6 • Good integration with statemachine API • Used by declarative UI • Ongoing work to animate layouts 29
  • 31. Thanks for you attention Q&A 30