1 | /* $Id: UISlidingAnimation.h 76581 2019-01-01 06:24:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISlidingAnimation class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2017-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_widgets_UISlidingAnimation_h
|
---|
19 | #define FEQT_INCLUDED_SRC_widgets_UISlidingAnimation_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QWidget>
|
---|
26 |
|
---|
27 | /* Forward declarations: */
|
---|
28 | class QLabel;
|
---|
29 | class QRect;
|
---|
30 | class QWidget;
|
---|
31 | class UIAnimation;
|
---|
32 |
|
---|
33 |
|
---|
34 | /** Sliding direction. */
|
---|
35 | enum SlidingDirection
|
---|
36 | {
|
---|
37 | SlidingDirection_Forward,
|
---|
38 | SlidingDirection_Reverse
|
---|
39 | };
|
---|
40 |
|
---|
41 |
|
---|
42 | /** QWidget extension which renders a sliding animation
|
---|
43 | * while transiting from one widget to another. */
|
---|
44 | class UISlidingAnimation : public QWidget
|
---|
45 | {
|
---|
46 | Q_OBJECT;
|
---|
47 | Q_PROPERTY(QRect widgetGeometry READ widgetGeometry WRITE setWidgetGeometry);
|
---|
48 | Q_PROPERTY(QRect startWidgetGeometry READ startWidgetGeometry);
|
---|
49 | Q_PROPERTY(QRect finalWidgetGeometry READ finalWidgetGeometry);
|
---|
50 |
|
---|
51 | signals:
|
---|
52 |
|
---|
53 | /** Commands to move animation in forward direction. */
|
---|
54 | void sigForward();
|
---|
55 | /** Commands to move animation in reverse direction. */
|
---|
56 | void sigReverse();
|
---|
57 |
|
---|
58 | /** Notifies listeners about animation in specified @a enmDirection is complete. */
|
---|
59 | void sigAnimationComplete(SlidingDirection enmDirection);
|
---|
60 |
|
---|
61 | public:
|
---|
62 |
|
---|
63 | /** Constructs sliding animation passing @a pParent to the base-class.
|
---|
64 | * @param enmOrientation Brings the widget orientation.
|
---|
65 | * @param fReverse Brings whether the animation should be initially reversed. */
|
---|
66 | UISlidingAnimation(Qt::Orientation enmOrientation, bool fReverse, QWidget *pParent = 0);
|
---|
67 |
|
---|
68 | /** Defines @a pWidget1 and @a pWidget2. */
|
---|
69 | void setWidgets(QWidget *pWidget1, QWidget *pWidget2);
|
---|
70 |
|
---|
71 | /** Animates cached pWidget1 and pWidget2 in passed @a enmDirection. */
|
---|
72 | void animate(SlidingDirection enmDirection);
|
---|
73 |
|
---|
74 | private slots:
|
---|
75 |
|
---|
76 | /** Handles entering for 'Start' state. */
|
---|
77 | void sltHandleStateEnteredStart();
|
---|
78 | /** Handles entering for 'Final' state. */
|
---|
79 | void sltHandleStateEnteredFinal();
|
---|
80 |
|
---|
81 | private:
|
---|
82 |
|
---|
83 | /** Prepares all. */
|
---|
84 | void prepare();
|
---|
85 |
|
---|
86 | /** Defines sub-window geometry. */
|
---|
87 | void setWidgetGeometry(const QRect &rect);
|
---|
88 | /** Returns sub-window geometry. */
|
---|
89 | QRect widgetGeometry() const;
|
---|
90 | /** Returns sub-window start-geometry. */
|
---|
91 | QRect startWidgetGeometry() const { return m_startWidgetGeometry; }
|
---|
92 | /** Returns sub-window final-geometry. */
|
---|
93 | QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; }
|
---|
94 |
|
---|
95 | /** Holds the widget orientation. */
|
---|
96 | Qt::Orientation m_enmOrientation;
|
---|
97 | /** Holds whether the animation should be initially reversed. */
|
---|
98 | bool m_fReverse;
|
---|
99 | /** Holds the animation instance. */
|
---|
100 | UIAnimation *m_pAnimation;
|
---|
101 | /** Holds whether animation is in progress. */
|
---|
102 | bool m_fIsInProgress;
|
---|
103 | /** Holds sub-window start-geometry. */
|
---|
104 | QRect m_startWidgetGeometry;
|
---|
105 | /** Holds sub-window final-geometry. */
|
---|
106 | QRect m_finalWidgetGeometry;
|
---|
107 |
|
---|
108 | /** Holds the sliding widget instance. */
|
---|
109 | QWidget *m_pWidget;
|
---|
110 | /** Holds the 1st label instance. */
|
---|
111 | QLabel *m_pLabel1;
|
---|
112 | /** Holds the 2nd label instance. */
|
---|
113 | QLabel *m_pLabel2;
|
---|
114 |
|
---|
115 | /** Holds the 1st rendered-widget reference. */
|
---|
116 | QWidget *m_pWidget1;
|
---|
117 | /** Holds the 2nd rendered-widget reference. */
|
---|
118 | QWidget *m_pWidget2;
|
---|
119 | };
|
---|
120 |
|
---|
121 | #endif /* !FEQT_INCLUDED_SRC_widgets_UISlidingAnimation_h */
|
---|