aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/src/concepts/statesanimations/topic.qdoc
blob: ab91268d5ed11eacc7249867df6b275cd93ce7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page qtquick-statesanimations-topic.html
\title Important Concepts in Qt Quick - States, Transitions and Animations
\brief Description of the concepts of states, transitions and animations in Qt Quick

In any modern user-interface, transitioning between states and animating
the user-interface is highly beneficial.  These are first-class concepts in
Qt Quick.

This page describes the concept of states, state transitions, and property
animations.  It details which concepts are important and why, and how those
concepts interrelate.  It also provides links to in-depth detail about the QML
types that Qt Quick provides to implement those concepts.

\section1 States

The state of a particular visual item is the set of information which describes
how and where the individual component parts of the visual item are displayed
within it, and all the data associated with that state.  Most visual items in a
user-interface will have a limited number of states, each with well-defined
properties.

For example, an element in a list may be either selected or not, and if
selected, it may either be the currently active single selection or it may be
part of a selection group.

Each of those states may have certain associated visual appearance (neutral,
highlighted, expanded, and so forth).

Qt Quick provides a \c{State} type with properties which define its semantics
and can be used to trigger behavior or animations.  See the documentation about
\l{qtquick-statesanimations-states.html}{Qt Quick States} for more
information.

\section1 Transitions

When a visual item transitions from one state to another, the appearance of
that item will change.  A transition is an "edge" between two states.  It may
trigger other events to occur, as other parts of the application may have
behavior which is triggered when a certain state is entered or left.

Qt Quick provides the \c{Transition} type which has properties which define
what will occur when the application changes from one state to another.  See
the documentation on
\l{qtquick-statesanimations-animations.html#transitions-during-state-changes}
{Transitions during State Changes} for more information about transitions.

\section1 Animations

When transitioning between states, a fluid animation can be used to aid the
user during the transition.  Abrupt and unexpected changes to the visual
canvas result in a suboptimal user-experience and should be avoided.

If an element in a list becomes selected, the color change (from neutral to
highlighted) can be animated.  If the position of the element in the list is
changed, it can be moved in an fluidly animated fashion so that the eye of the
user can track the change.

These types of animations are supported in Qt Quick through various animation
and transition types.  See the documentation on
\l{qtquick-statesanimations-animations.html}
{Animations and Transitions In Qt Quick} for information about these types
and how to use them.


\section1 Animating Property Assignments

Animations are not only related to states and transitions between states.  For
example, an animation might be triggered by other events, which are not
associated with a distinct state.

It is often beneficial to always animate changes to certain properties of
visual items, regardless of the cause of the change (for example, opacity
effects).  Qt Quick provides the \l Behavior type which allows the client to
specify animation behavior for changes to properties.  The \l Behavior type
is an example of a QML object
\l{qtqml-cppintegration-definetypes.html#property-modifier-types}
{property modifier}.

Please see the documentation about
\l{qtquick-statesanimations-animations.html#default-animation-as-behaviors}
{default property animations} for more information about using the \l Behavior
type to provide default property change animations.

It is important to note, that using default property animations (via the
\l Behavior type) in combination with state-transition animations can sometimes
result in undefined behavior occurring.  Please see the documentation about
\l{qtquick-statesanimations-behaviors.html}
{using Qt Quick Behaviors with States} for more information about this topic.

\section1 Animators

The \l Animator types are a special type of animation which bypass
the QML objects and operate directly on the primitives in the
\l {Qt Quick Scene Graph}{scene graph}. This has the benefit that
the Animator based animations can be run on the scene graph's rendering thread
(when applicable) and can continue to animate even when UI is otherwise
blocked.

Qt Quick provides the following Animator types:
\list
\li \l {XAnimator} - Animates the horizontal position of an \l {Item}.
\li \l {YAnimator} - Animates the vertical position of an \l {Item}.
\li \l {ScaleAnimator} - Animates the scale factor of an \l {Item}.
\li \l {RotationAnimator} - Animates the rotation of an \l {Item}.
\li \l {OpacityAnimator} - Animates the opacity of an \l {Item}.
\li \l {UniformAnimator} - Animates a uniform in a \l {ShaderEffect}.
\endlist

\section1 Animated Sprites

The concept of animated sprites is separate to the concept of animations as
used elsewhere on this page.  If you want to create or use an animated image
or sprite, please see the documentation about
\l{qtquick-effects-sprites.html}{sprite animations}.

*/