API Documentation
Loading...
Searching...
No Matches
ResizeVisibleAnimation.h
Go to the documentation of this file.
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;
44 /**--------------------------------------------------------------------------------------------------
45 \brief Resposible for animating widgets by having them grown as they become visible, or shrink as
46 they become invisible. For some operating systems will also apply a fade effect.
47 **/
48 class NDEVR_WIDGETS_API ResizeVisibleAnimation : public QPropertyAnimation
49 {
50 Q_OBJECT
51 Q_PROPERTY(double visible_size READ activeSize WRITE setActiveSize)
52 protected:
53 ResizeVisibleAnimation(QWidget* widget, bool visible, bool vertical, int duration = 300, int delay = 0);
54 ResizeVisibleAnimation(QWidget* widget, bool visible, PopupInfo start_location, PopupInfo end_location, int duration = 300, int delay = 0);
55 public:
57 void setActiveSize(double size);
58 void setDeleteWidgetOnEnd(bool delete_widget) { m_delete_on_end = delete_widget; }
59 void setup(int duration, int start_delay, bool ignore_max_min_size);
60 void reverse();
61 double activeSize() const
62 {
63 return m_active_size;
64 }
65 static ResizeVisibleAnimation* run(QWidget* widget, bool visible, bool vertical, int duration = -1, int delay = 0);
66 static ResizeVisibleAnimation* run(QWidget* widget, bool visible, const PopupInfo& start_location, const PopupInfo& end_location, int duration = -1, int delay = 0);
67 bool eventFilter(QObject* object, QEvent* event) override;
68 static ResizeVisibleAnimation* runRemove(QWidget* widget, bool vertical, int duration = -1, int delay = 0);
69 static void setTopLevelWidget(QWidget* top_widget);
70 static ResizeVisibleAnimation* ActiveAnimation(QWidget* widget);
71 private slots:
72 void onFinishedSlot();
73 private:
74 void setupSourceWidget(QWidget* source_widget, QSize size);
75 void createFadeInAnimation(int msec);
76 QRect getGeometry(double percent);
77 protected slots:
79 private:
80 fltp08 m_active_size;
81 int m_widget_size;
82 QSize m_restore_max_widget_size;
83 QSize m_restore_min_widget_size;
84 QPointer<QPropertyAnimation> m_primary_animation = nullptr;
85 QPointer<QGraphicsOpacityEffect> m_fade_primary_effect;
86 QPointer<ImageView> m_primary_image_view;
87 QPointer<QWidget> m_widget;
88 QPointer<QWidget> m_animation_widget;
89 PopupInfo m_start_size;
90 PopupInfo m_end_size;
91 bool m_is_vertical;
92 bool m_make_visible;
93 bool m_delete_on_end;
94 Qt::WindowFlags m_original_flags;
95 static Dictionary<QWidget*, ResizeVisibleAnimation*> s_active_resize_effects;
96 static QWidget* s_top_level_widget;
97 };
98}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:59
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Resposible for animating widgets by having them grown as they become visible, or shrink as they becom...
Definition ResizeVisibleAnimation.h:49
bool eventFilter(QObject *object, QEvent *event) override
static ResizeVisibleAnimation * run(QWidget *widget, bool visible, bool vertical, int duration=-1, int delay=0)
ResizeVisibleAnimation(QWidget *widget, bool visible, PopupInfo start_location, PopupInfo end_location, int duration=300, int delay=0)
static ResizeVisibleAnimation * run(QWidget *widget, bool visible, const PopupInfo &start_location, const PopupInfo &end_location, int duration=-1, int delay=0)
void setActiveSize(double size)
static void setTopLevelWidget(QWidget *top_widget)
double activeSize() const
Definition ResizeVisibleAnimation.h:61
void setup(int duration, int start_delay, bool ignore_max_min_size)
static ResizeVisibleAnimation * runRemove(QWidget *widget, bool vertical, int duration=-1, int delay=0)
void setDeleteWidgetOnEnd(bool delete_widget)
Definition ResizeVisibleAnimation.h:58
static ResizeVisibleAnimation * ActiveAnimation(QWidget *widget)
ResizeVisibleAnimation(QWidget *widget, bool visible, bool vertical, int duration=300, int delay=0)
Definition ACIColor.h:37
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Class which is used to pass arguments and requests for creating a popup dialog or widget....
Definition PopupInfo.h:15