NDEVR
API Documentation
ResizeVisibleAnimation.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: ResizeVisibleAnimation
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/PopupInfo.h>
35#include <NDEVR/Dictionary.h>
36#include <QWidget>
37#include <QPropertyAnimation>
38#include <QGraphicsOpacityEffect>
39#include <QRect>
40#include <QPointer>
41namespace NDEVR
42{
43 class ImageView;
48 class NDEVR_WIDGETS_API ResizeVisibleAnimation : public QPropertyAnimation
49 {
50 Q_OBJECT
51 Q_PROPERTY(double visible_size READ activeSize WRITE setActiveSize)
52 protected:
61 ResizeVisibleAnimation(QWidget* widget, bool visible, bool vertical, int duration = 300, int delay = 0);
71 ResizeVisibleAnimation(QWidget* widget, bool visible, PopupInfo start_location, PopupInfo end_location, int duration = 300, int delay = 0);
72 public:
78 void setActiveSize(double size);
83 void setDeleteWidgetOnEnd(bool delete_widget) { m_delete_on_end = delete_widget; }
90 void setup(int duration, int start_delay, bool ignore_max_min_size);
94 void reverse();
99 double activeSize() const
100 {
101 return m_active_size;
102 }
103
112 static ResizeVisibleAnimation* run(QWidget* widget, bool visible, bool vertical, int duration = -1, int delay = 0);
123 static ResizeVisibleAnimation* run(QWidget* widget, bool visible, const PopupInfo& start_location, const PopupInfo& end_location, int duration = -1, int delay = 0);
124 bool eventFilter(QObject* object, QEvent* event) override;
133 static ResizeVisibleAnimation* runRemove(QWidget* widget, bool vertical, int duration = -1, int delay = 0);
138 static void setTopLevelWidget(QWidget* top_widget);
144 static ResizeVisibleAnimation* ActiveAnimation(QWidget* widget);
145 signals:
148 private slots:
152 void onFinishedSlot();
153 private:
154 void setupSourceWidget(QWidget* source_widget, QSize size);
155 void createFadeInAnimation(int msec);
156 QRect getGeometry(double percent);
157 protected slots:
162 private:
163 fltp08 m_active_size;
164 int m_widget_size;
165 QSize m_restore_max_widget_size;
166 QSize m_restore_min_widget_size;
167 QPointer<QPropertyAnimation> m_primary_animation = nullptr;
168 QPointer<QGraphicsOpacityEffect> m_fade_primary_effect;
169 QPointer<ImageView> m_primary_image_view;
170 QPointer<QWidget> m_widget;
171 QPointer<QWidget> m_animation_widget;
172 QWidget* m_widget_key = nullptr;
173 PopupInfo m_start_size;
174 PopupInfo m_end_size;
175 bool m_is_vertical;
176 bool m_make_visible;
177 bool m_delete_on_end;
178 Qt::WindowFlags m_original_flags;
179 static Dictionary<QWidget*, ResizeVisibleAnimation*> s_active_resize_effects;
180 static QWidget* s_top_level_widget;
181 };
182}
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
A widget that shows a raster image or icon.
Definition ImageView.h:44
ResizeVisibleAnimation(QWidget *widget, bool visible, PopupInfo start_location, PopupInfo end_location, int duration=300, int delay=0)
Constructs a resize animation that animates a widget between two popup locations.
static ResizeVisibleAnimation * runRemove(QWidget *widget, bool vertical, int duration=-1, int delay=0)
Creates and runs a hide-then-remove animation for a widget.
void startAnimation()
Slot that starts the animation after any configured delay.
static ResizeVisibleAnimation * run(QWidget *widget, bool visible, bool vertical, int duration=-1, int delay=0)
Creates and runs a resize animation for showing or hiding a widget.
void finishedSignal()
Signal emitted when the animation finishes.
void setDeleteWidgetOnEnd(bool delete_widget)
Sets whether the widget should be deleted when the animation finishes.
static ResizeVisibleAnimation * run(QWidget *widget, bool visible, const PopupInfo &start_location, const PopupInfo &end_location, int duration=-1, int delay=0)
Creates and runs a resize animation between two popup locations.
void setActiveSize(double size)
Sets the current animated size value, driving the animation progress.
static ResizeVisibleAnimation * ActiveAnimation(QWidget *widget)
Returns the currently active resize animation for a widget, if any.
static void setTopLevelWidget(QWidget *top_widget)
Sets the top-level widget used as a reference for popup animations.
void setup(int duration, int start_delay, bool ignore_max_min_size)
Configures the animation timing and size constraints.
ResizeVisibleAnimation(QWidget *widget, bool visible, bool vertical, int duration=300, int delay=0)
Constructs a resize animation for showing or hiding a widget vertically or horizontally.
double activeSize() const
Returns the current animated size value.
void reverse()
Reverses the animation direction.
void updatedSignal()
Signal emitted when the animation value is updated.
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.
Class which is used to pass arguments and requests for creating a popup dialog or widget.
Definition PopupInfo.h:16