VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIAnimationFramework.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1/* $Id: UIAnimationFramework.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIAnimationFramework class declaration.
4 */
5
6/*
7 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_globals_UIAnimationFramework_h
29#define FEQT_INCLUDED_SRC_globals_UIAnimationFramework_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QObject>
36
37/* GUI includes: */
38#include "UILibraryDefs.h"
39
40/* Forward declaration: */
41class QPropertyAnimation;
42class QState;
43class QStateMachine;
44
45
46/** QObject subclass used as animation factory. */
47class SHARED_LIBRARY_STUFF UIAnimation : public QObject
48{
49 Q_OBJECT;
50
51signals:
52
53 /** Notifies listener about 'Start' state entered. */
54 void sigStateEnteredStart();
55 /** Notifies listener about 'Final' state entered. */
56 void sigStateEnteredFinal();
57
58public:
59
60 /** Installs property animation.
61 * @param pTarget Brings the object being animated.
62 * @param pszPropertyName Brings the name of property being animated.
63 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value.
64 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value.
65 * @param pszSignalForward Brings the signal to start forward animation.
66 * @param pszSignalReverse Brings the signal to start reverse animation.
67 * @param fReverse Brings whether the animation should be inverted.
68 * @param iAnimationDuration Brings the animation duration. */
69 static UIAnimation *installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName,
70 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
71 const char *pszSignalForward, const char *pszSignalReverse,
72 bool fReverse = false, int iAnimationDuration = 300);
73
74 /** Updates the animation, fetching new initial values. */
75 void update();
76
77private:
78
79 /** Constructs animation. Doesn't mean to be used directly.
80 * @param pParent Brings the object animation being applied to.
81 * @param pszPropertyName Brings the name of property being animated.
82 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value.
83 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value.
84 * @param pszSignalForward Brings the signal to start forward animation.
85 * @param pszSignalReverse Brings the signal to start reverse animation.
86 * @param fReverse Brings whether the animation should be inverted.
87 * @param iAnimationDuration Brings the animation duration. */
88 UIAnimation(QWidget *pParent, const char *pszPropertyName,
89 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
90 const char *pszSignalForward, const char *pszSignalReverse,
91 bool fReverse, int iAnimationDuration);
92
93 /** Prepares all. */
94 void prepare();
95
96 /** Holds the name of property being animated. */
97 const char *m_pszPropertyName;
98
99 /** Holds the name of the property holding 'start' value. */
100 const char *m_pszValuePropertyNameStart;
101 /** Holds the name of the property holding 'final' value. */
102 const char *m_pszValuePropertyNameFinal;
103
104 /** Holds the signal to start forward animation. */
105 const char *m_pszSignalForward;
106 /** Holds the signal to start reverse animation. */
107 const char *m_pszSignalReverse;
108
109 /** Holds whether the animation should be inverted. */
110 bool m_fReverse;
111
112 /** Holds the animation duration. */
113 int m_iAnimationDuration;
114
115 /** Holds the animation machine instance. */
116 QStateMachine *m_pAnimationMachine;
117 /** Holds the instance of the animation 'Start' state. */
118 QState *m_pStateStart;
119 /** Holds the instance of the animation 'Final' state. */
120 QState *m_pStateFinal;
121 /** Holds the instance of the 'Forward' animation. */
122 QPropertyAnimation *m_pForwardAnimation;
123 /** Holds the instance of the 'Reverse' animation. */
124 QPropertyAnimation *m_pReverseAnimation;
125};
126
127
128/** QObject subclass used as animation loop factory. */
129class SHARED_LIBRARY_STUFF UIAnimationLoop : public QObject
130{
131 Q_OBJECT;
132
133public:
134
135 /** Installs property animation.
136 * @param pTarget Brings the object being animated.
137 * @param pszPropertyName Brings the name of property being animated.
138 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value.
139 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value.
140 * @param iAnimationDuration Brings the animation duration. */
141 static UIAnimationLoop *installAnimationLoop(QWidget *pTarget, const char *pszPropertyName,
142 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
143 int iAnimationDuration = 300);
144
145 /** Updates the animation, fetching new initial values. */
146 void update();
147
148 /** Starts the loop. */
149 void start();
150 /** Stops the loop. */
151 void stop();
152
153private:
154
155 /** Constructs animation loop. Doesn't mean to be used directly.
156 * @param pParent Brings the object animation being applied to.
157 * @param pszPropertyName Brings the name of property being animated.
158 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value.
159 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value.
160 * @param iAnimationDuration Brings the animation duration. */
161 UIAnimationLoop(QWidget *pParent, const char *pszPropertyName,
162 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
163 int iAnimationDuration);
164
165 /** Prepares all. */
166 void prepare();
167
168 /** Holds the name of property being animated. */
169 const char *m_pszPropertyName;
170
171 /** Holds the name of the property holding 'start' value. */
172 const char *m_pszValuePropertyNameStart;
173 /** Holds the name of the property holding 'final' value. */
174 const char *m_pszValuePropertyNameFinal;
175
176 /** Holds the animation duration. */
177 int m_iAnimationDuration;
178
179 /** Holds the instance of the animation. */
180 QPropertyAnimation *m_pAnimation;
181};
182
183
184#endif /* !FEQT_INCLUDED_SRC_globals_UIAnimationFramework_h */
185
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use