API Documentation
Loading...
Searching...
No Matches
QCustomStackedWidget.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: QCustomStackedWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/PopupInfo.h>
35#include <NDEVR/ApplicationOptions.h>
36#include <NDEVR/Buffer.h>
37#include <QEasingCurve>
38#include <QWidget>
39#include <QPropertyAnimation>
40#include <QPointer>
41namespace NDEVR
42{
43 class ImageView;
44
45 /**--------------------------------------------------------------------------------------------------
46 \brief A base class for a series of widgets where all widgets occupy the same same and only one widget
47 is shown at a time.
48 **/
50 {
51 Q_OBJECT
52 Q_PROPERTY(double animation_percent READ animationPercent WRITE setAnimationPercent)
53 public:
54 // This enumeration is used to define the animation direction
63 void setSpeed(int speed); // animation duration in milliseconds
64 void setAnimation(enum QEasingCurve::Type animationtype); // check out the QEasingCurve documentation for different styles
65 void setVerticalMode(bool vertical = true);
66 void setWrap(bool wrap); // wrapping is related to slideInNext/Prev;it defines the behaviour when reaching last/first page
67 void setCustomPixmap(QPixmap* pixmap);
68 protected:
69 // The Constructor and Destructor
70 explicit QCustomStackedWidgetBase(QWidget *parent = nullptr);
72 void resizeEvent(QResizeEvent* event) override;
73 void showEvent(QShowEvent* event) override;
74 void setAnimationPercent(double animation_percent);
75 double animationPercent() const { return m_animation_percent; }
76 void paintEvent(QPaintEvent*) override;
77 virtual void swapIndices(uint04 a, uint04 b);
78 virtual void moveContent(uint04 from, uint04 to);
79 virtual uint04 addWidget(QWidget* w);
80 void insertWidget(uint04 index, QWidget *w);
81 void removeWidget(QWidget* widget);
82 void removeWidget(QWidget* widget, QWidget* slide_to_if_active);
83 bool eventFilter(QObject* object, QEvent* event) override;
85 QWidget* activeWidget() const;
86
87 QWidget* currentWidget() const;
88 QSize sizeHint() const override;
89 QSize minimumSizeHint() const override;
90 QWidget* widget(uint04 index) const;
91
92 uint04 indexOf(QWidget* widget) const;
93
94 uint04 currentIndex() const { return m_current_index; }
95 uint04 count() const;
96 virtual void setCurrentIdx(uint04 current_index);
97 virtual void slideInNext();
98 virtual void slideInPrev();
99 virtual void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time = 0, enum StackAnimationDirection direction = e_automatic);
100 virtual void slideInIdx(uint04 idx, int delay_time = 0, enum StackAnimationDirection direction = e_automatic);
101 virtual void slideInIdx(uint04 idx, enum StackAnimationDirection direction);
102 virtual void slideInAnimation(PopupInfo origin_rect, enum StackAnimationDirection direction = e_automatic, bool cache_in_image = false);
103 virtual void slideInAnimation(enum StackAnimationDirection direction = e_automatic, bool cache_in_image = false);
104 virtual void slideInWgt(QWidget* widget, enum StackAnimationDirection direction = e_automatic, bool force_slide = false);
105 public:
106 static ApplicationOption<sint04> default_stack_animation_speed;//default time in milliseconds to animate a slide transition
107 signals:
108 // this is used for internal purposes in the class engine
110
111 protected slots:
112 void childDestroyedSlot(QObject* widget);
113 // this is used for internal purposes in the class engine
115
116 protected:
117 // this is used for internal purposes in the class engine
118
120 enum QEasingCurve::Type m_animationtype;
125 QPoint m_offset;
127
131 //QGraphicsOpacityEffect* m_primary_image_view;
132 //QGraphicsOpacityEffect* m_fade_out;
133 QPointer<QPropertyAnimation> m_move_animation;
136 bool m_wrap = false;
137 private:
138 QPixmap* m_cached_resize_image_out;
139 QPixmap* m_cached_resize_image_in;
140 QPixmap* m_resize_image_in_blend;
141 QPixmap* m_custom_pixmap;
142 };
143
144 /**--------------------------------------------------------------------------------------------------
145 \brief The main class for a layout where all widgets occupy the same same and only one widget
146 is shown at a time.
147 **/
149 {
150 public:
151 explicit QCustomStackedWidget(QWidget* parent = nullptr)
153 {}
154 virtual uint04 addWidget(QWidget* w) override
155 {
157 };
158
159 virtual void slideInNext() override {
161 }
162 virtual void slideInPrev() override {
164 }
169 void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time = 0, enum StackAnimationDirection direction = e_automatic) override
170 {
171 QCustomStackedWidgetBase::slideInIdx(idx, origin_rect, delay_time, direction);
172 }
173 void slideInIdx(uint04 idx, int delay_time = 0, enum StackAnimationDirection direction = e_automatic) override {
174 QCustomStackedWidgetBase::slideInIdx(idx, delay_time, direction);
175 }
176 void slideInIdx(uint04 idx, enum StackAnimationDirection direction) override {
178 }
179 void slideInAnimation(PopupInfo origin_rect, enum StackAnimationDirection direction = e_automatic, bool cache_in_image = false)override {
180 QCustomStackedWidgetBase::slideInAnimation(origin_rect, direction, cache_in_image);
181 }
182 void slideInAnimation(enum StackAnimationDirection direction = e_automatic, bool cache_in_image = false) override {
183 QCustomStackedWidgetBase::slideInAnimation(direction, cache_in_image);
184 }
185 void slideInWgt(QWidget* widget, enum StackAnimationDirection direction = e_automatic, bool force_slide = false) override {
186 QCustomStackedWidgetBase::slideInWgt(widget, direction, force_slide);
187 }
195 QWidget* activeWidget() const {
197 }
198 uint04 count() const {
200 }
201 bool hasWidget(QWidget* widget) const
202 {
204 }
208 };
209}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:59
The default object to store data of any type that should persist through sessions of the application.
Definition Button.h:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A base class for a series of widgets where all widgets occupy the same same and only one widget is sh...
Definition QCustomStackedWidget.h:50
void setAnimationPercent(double animation_percent)
QWidget * currentWidget() const
QSize minimumSizeHint() const override
void removeWidget(QWidget *widget, QWidget *slide_to_if_active)
void paintEvent(QPaintEvent *) override
void insertWidget(uint04 index, QWidget *w)
uint04 m_current_index
Definition QCustomStackedWidget.h:129
virtual void slideInAnimation(PopupInfo origin_rect, enum StackAnimationDirection direction=e_automatic, bool cache_in_image=false)
void showEvent(QShowEvent *event) override
QSize sizeHint() const override
void setCustomPixmap(QPixmap *pixmap)
double m_animation_percent
Definition QCustomStackedWidget.h:128
uint04 currentIndex() const
Definition QCustomStackedWidget.h:94
virtual void moveContent(uint04 from, uint04 to)
bool eventFilter(QObject *object, QEvent *event) override
QPointer< QPropertyAnimation > m_move_animation
Definition QCustomStackedWidget.h:133
QPoint m_offset
Definition QCustomStackedWidget.h:125
static ApplicationOption< sint04 > default_stack_animation_speed
Definition QCustomStackedWidget.h:106
virtual void setCurrentIdx(uint04 current_index)
uint04 m_next
Definition QCustomStackedWidget.h:122
StackAnimationDirection
Definition QCustomStackedWidget.h:56
@ e_automatic
Definition QCustomStackedWidget.h:61
@ e_bottom_to_top
Definition QCustomStackedWidget.h:60
@ e_left_to_right
Definition QCustomStackedWidget.h:57
@ e_top_to_bottom
Definition QCustomStackedWidget.h:59
@ e_right_to_left
Definition QCustomStackedWidget.h:58
PopupInfo m_popup_info
Definition QCustomStackedWidget.h:126
virtual void slideInWgt(QWidget *widget, enum StackAnimationDirection direction=e_automatic, bool force_slide=false)
virtual void slideInAnimation(enum StackAnimationDirection direction=e_automatic, bool cache_in_image=false)
int m_last_animation_time
Definition QCustomStackedWidget.h:124
bool m_is_animating
Definition QCustomStackedWidget.h:134
virtual void swapIndices(uint04 a, uint04 b)
int m_speed
Definition QCustomStackedWidget.h:119
virtual void slideInIdx(uint04 idx, enum StackAnimationDirection direction)
void resizeEvent(QResizeEvent *event) override
double animationPercent() const
Definition QCustomStackedWidget.h:75
QCustomStackedWidgetBase(QWidget *parent=nullptr)
QWidget * activeWidget() const
bool m_vertical
Definition QCustomStackedWidget.h:135
void setVerticalMode(bool vertical=true)
void setAnimation(enum QEasingCurve::Type animationtype)
uint04 m_now
Definition QCustomStackedWidget.h:121
Buffer< QWidget * > m_child_widgets
Definition QCustomStackedWidget.h:130
virtual void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time=0, enum StackAnimationDirection direction=e_automatic)
uint04 m_last
Definition QCustomStackedWidget.h:123
void childDestroyedSlot(QObject *widget)
enum QEasingCurve::Type m_animationtype
Definition QCustomStackedWidget.h:120
virtual uint04 addWidget(QWidget *w)
void removeWidget(QWidget *widget)
QWidget * widget(uint04 index) const
uint04 indexOf(QWidget *widget) const
virtual void slideInIdx(uint04 idx, int delay_time=0, enum StackAnimationDirection direction=e_automatic)
The main class for a layout where all widgets occupy the same same and only one widget is shown at a ...
Definition QCustomStackedWidget.h:149
void slideInIdx(uint04 idx, int delay_time=0, enum StackAnimationDirection direction=e_automatic) override
Definition QCustomStackedWidget.h:173
QWidget * currentWidget() const
Definition QCustomStackedWidget.h:207
uint04 currentIndex() const
Definition QCustomStackedWidget.h:205
void slideInIdx(uint04 idx, enum StackAnimationDirection direction) override
Definition QCustomStackedWidget.h:176
void slideInWgt(QWidget *widget, enum StackAnimationDirection direction=e_automatic, bool force_slide=false) override
Definition QCustomStackedWidget.h:185
void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time=0, enum StackAnimationDirection direction=e_automatic) override
Definition QCustomStackedWidget.h:169
void slideInAnimation(PopupInfo origin_rect, enum StackAnimationDirection direction=e_automatic, bool cache_in_image=false) override
Definition QCustomStackedWidget.h:179
void setCurrentIndex(uint04 idx)
Definition QCustomStackedWidget.h:165
virtual void slideInNext() override
Definition QCustomStackedWidget.h:159
virtual uint04 addWidget(QWidget *w) override
Definition QCustomStackedWidget.h:154
bool hasWidget(QWidget *widget) const
Definition QCustomStackedWidget.h:201
QWidget * activeWidget() const
Definition QCustomStackedWidget.h:195
void slideInAnimation(enum StackAnimationDirection direction=e_automatic, bool cache_in_image=false) override
Definition QCustomStackedWidget.h:182
uint04 activeIndex() const
Definition QCustomStackedWidget.h:192
QCustomStackedWidget(QWidget *parent=nullptr)
Definition QCustomStackedWidget.h:151
uint04 count() const
Definition QCustomStackedWidget.h:198
void removeWidget(QWidget *widget)
Definition QCustomStackedWidget.h:188
uint04 indexOf(QWidget *widget) const
Definition QCustomStackedWidget.h:206
virtual void slideInPrev() override
Definition QCustomStackedWidget.h:162
Definition ACIColor.h:37
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Class which is used to pass arguments and requests for creating a popup dialog or widget....
Definition PopupInfo.h:15