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;
45 {
46 Q_OBJECT
47 Q_PROPERTY(double animation_percent READ animationPercent WRITE setAnimationPercent)
48 public:
49 // This enumeration is used to define the animation direction
57 void setSpeed(int speed); // animation duration in milliseconds
58 void setAnimation(enum QEasingCurve::Type animationtype); // check out the QEasingCurve documentation for different styles
59 void setVerticalMode(bool vertical = true);
60 void setWrap(bool wrap); // wrapping is related to slideInNext/Prev;it defines the behaviour when reaching last/first page
61 void setCustomPixmap(QPixmap* pixmap);
62 protected:
63 // The Constructor and Destructor
64 explicit QCustomStackedWidgetBase(QWidget *parent = nullptr);
66 void resizeEvent(QResizeEvent* event) override;
67 void showEvent(QShowEvent* event) override;
68 void setAnimationPercent(double animation_percent);
69 double animationPercent() const { return m_animation_percent; }
70 void paintEvent(QPaintEvent*) override;
71 virtual void swapIndices(uint04 a, uint04 b);
72 virtual void moveContent(uint04 from, uint04 to);
73 virtual uint04 addWidget(QWidget* w);
74 void insertWidget(uint04 index, QWidget *w);
75 void removeWidget(QWidget* widget);
76 void removeWidget(QWidget* widget, QWidget* slide_to_if_active);
77 bool eventFilter(QObject* object, QEvent* event) override;
78 uint04 activeIndex() const;
79 QWidget* activeWidget() const;
80
81 QWidget* currentWidget() const;
82 QSize sizeHint() const override;
83 QSize minimumSizeHint() const override;
84 QWidget* widget(uint04 index) const;
85
86 uint04 indexOf(QWidget* widget) const;
87
88 uint04 currentIndex() const { return m_current_index; }
89 uint04 count() const;
90 virtual void setCurrentIdx(uint04 current_index);
91 virtual void slideInNext();
92 virtual void slideInPrev();
93 virtual void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time = 0, enum t_direction direction = AUTOMATIC);
94 virtual void slideInIdx(uint04 idx, int delay_time = 0, enum t_direction direction = AUTOMATIC);
95 virtual void slideInIdx(uint04 idx, enum t_direction direction);
96 virtual void slideInAnimation(PopupInfo origin_rect, enum t_direction direction = AUTOMATIC, bool cache_in_image = false);
97 virtual void slideInAnimation(enum t_direction direction = AUTOMATIC, bool cache_in_image = false);
98 virtual void slideInWgt(QWidget* widget, enum t_direction direction = AUTOMATIC, bool force_slide = false);
99
100 public:
102 // The Animation / Page Change API
103
104 signals:
105 // this is used for internal purposes in the class engine
107
108 protected slots:
109 void childDestroyedSlot(QObject* widget);
110 // this is used for internal purposes in the class engine
111 void animationDoneSlot();
112
113 protected:
114 // this is used for internal purposes in the class engine
115
117 enum QEasingCurve::Type m_animationtype;
122 QPoint m_offset;
124
128 //QGraphicsOpacityEffect* m_primary_image_view;
129 //QGraphicsOpacityEffect* m_fade_out;
130 QPointer<QPropertyAnimation> m_move_animation;
133 bool m_wrap = false;
134 private:
135 QPixmap* m_cached_resize_image_out;
136 QPixmap* m_cached_resize_image_in;
137 QPixmap* m_resize_image_in_blend;
138 QPixmap* m_custom_pixmap;
139 };
140
142 {
143 public:
144 explicit QCustomStackedWidget(QWidget* parent = nullptr)
146 {}
147 virtual uint04 addWidget(QWidget* w) override
148 {
150 };
151
152 virtual void slideInNext() override {
154 }
155 virtual void slideInPrev() override {
157 }
162 void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time = 0, enum t_direction direction = AUTOMATIC) override
163 {
164 QCustomStackedWidgetBase::slideInIdx(idx, origin_rect, delay_time, direction);
165 }
166 void slideInIdx(uint04 idx, int delay_time = 0, enum t_direction direction = AUTOMATIC) override {
167 QCustomStackedWidgetBase::slideInIdx(idx, delay_time, direction);
168 }
169 void slideInIdx(uint04 idx, enum t_direction direction) override {
171 }
172 void slideInAnimation(PopupInfo origin_rect, enum t_direction direction = AUTOMATIC, bool cache_in_image = false)override {
173 QCustomStackedWidgetBase::slideInAnimation(origin_rect, direction, cache_in_image);
174 }
175 void slideInAnimation(enum t_direction direction = AUTOMATIC, bool cache_in_image = false) override {
176 QCustomStackedWidgetBase::slideInAnimation(direction, cache_in_image);
177 }
178 void slideInWgt(QWidget* widget, enum t_direction direction = AUTOMATIC, bool force_slide = false) override {
179 QCustomStackedWidgetBase::slideInWgt(widget, direction, force_slide);
180 }
188 QWidget* activeWidget() const {
190 }
191 uint04 count() const {
193 }
194 bool hasWidget(QWidget* widget) const
195 {
197 }
201 };
202}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
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:64
Definition QCustomStackedWidget.h:45
virtual void slideInWgt(QWidget *widget, enum t_direction direction=AUTOMATIC, bool force_slide=false)
Definition QCustomStackedWidget.cpp:681
virtual void slideInNext()
Definition QCustomStackedWidget.cpp:596
QWidget * currentWidget() const
Definition QCustomStackedWidget.cpp:495
virtual uint04 addWidget(QWidget *w)
Definition QCustomStackedWidget.cpp:390
uint04 m_current_index
Definition QCustomStackedWidget.h:126
double m_animation_percent
Definition QCustomStackedWidget.h:125
uint04 currentIndex() const
Definition QCustomStackedWidget.h:88
QPointer< QPropertyAnimation > m_move_animation
Definition QCustomStackedWidget.h:130
QPoint m_offset
Definition QCustomStackedWidget.h:122
virtual void slideInPrev()
Definition QCustomStackedWidget.cpp:603
uint04 m_next
Definition QCustomStackedWidget.h:119
PopupInfo m_popup_info
Definition QCustomStackedWidget.h:123
int m_last_animation_time
Definition QCustomStackedWidget.h:121
bool m_is_animating
Definition QCustomStackedWidget.h:131
virtual void slideInAnimation(PopupInfo origin_rect, enum t_direction direction=AUTOMATIC, bool cache_in_image=false)
Definition QCustomStackedWidget.cpp:658
int m_speed
Definition QCustomStackedWidget.h:116
double animationPercent() const
Definition QCustomStackedWidget.h:69
QWidget * activeWidget() const
Definition QCustomStackedWidget.cpp:487
bool m_vertical
Definition QCustomStackedWidget.h:132
virtual void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time=0, enum t_direction direction=AUTOMATIC)
Definition QCustomStackedWidget.cpp:609
uint04 m_now
Definition QCustomStackedWidget.h:118
Buffer< QWidget * > m_child_widgets
Definition QCustomStackedWidget.h:127
uint04 activeIndex() const
Definition QCustomStackedWidget.cpp:478
uint04 m_last
Definition QCustomStackedWidget.h:120
virtual void setCurrentIdx(uint04 current_index)
Definition QCustomStackedWidget.cpp:503
enum QEasingCurve::Type m_animationtype
Definition QCustomStackedWidget.h:117
uint04 count() const
Definition QCustomStackedWidget.cpp:134
void removeWidget(QWidget *widget)
Definition QCustomStackedWidget.cpp:409
static ApplicationOption< sint04 > default_stack_animation_speed
Definition QCustomStackedWidget.h:101
QWidget * widget(uint04 index) const
Definition QCustomStackedWidget.cpp:126
t_direction
Definition QCustomStackedWidget.h:50
@ AUTOMATIC
Definition QCustomStackedWidget.h:55
@ TOP2BOTTOM
Definition QCustomStackedWidget.h:53
@ RIGHT2LEFT
Definition QCustomStackedWidget.h:52
@ BOTTOM2TOP
Definition QCustomStackedWidget.h:54
@ LEFT2RIGHT
Definition QCustomStackedWidget.h:51
uint04 indexOf(QWidget *widget) const
Definition QCustomStackedWidget.cpp:139
Definition QCustomStackedWidget.h:142
QWidget * currentWidget() const
Definition QCustomStackedWidget.h:200
void slideInIdx(uint04 idx, int delay_time=0, enum t_direction direction=AUTOMATIC) override
Definition QCustomStackedWidget.h:166
void slideInWgt(QWidget *widget, enum t_direction direction=AUTOMATIC, bool force_slide=false) override
Definition QCustomStackedWidget.h:178
void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time=0, enum t_direction direction=AUTOMATIC) override
Definition QCustomStackedWidget.h:162
void slideInAnimation(PopupInfo origin_rect, enum t_direction direction=AUTOMATIC, bool cache_in_image=false) override
Definition QCustomStackedWidget.h:172
uint04 currentIndex() const
Definition QCustomStackedWidget.h:198
void setCurrentIndex(uint04 idx)
Definition QCustomStackedWidget.h:158
virtual void slideInNext() override
Definition QCustomStackedWidget.h:152
virtual uint04 addWidget(QWidget *w) override
Definition QCustomStackedWidget.h:147
bool hasWidget(QWidget *widget) const
Definition QCustomStackedWidget.h:194
QWidget * activeWidget() const
Definition QCustomStackedWidget.h:188
uint04 activeIndex() const
Definition QCustomStackedWidget.h:185
QCustomStackedWidget(QWidget *parent=nullptr)
Definition QCustomStackedWidget.h:144
uint04 count() const
Definition QCustomStackedWidget.h:191
void removeWidget(QWidget *widget)
Definition QCustomStackedWidget.h:181
uint04 indexOf(QWidget *widget) const
Definition QCustomStackedWidget.h:199
void slideInAnimation(enum t_direction direction=AUTOMATIC, bool cache_in_image=false) override
Definition QCustomStackedWidget.h:175
void slideInIdx(uint04 idx, enum t_direction direction) override
Definition QCustomStackedWidget.h:169
virtual void slideInPrev() override
Definition QCustomStackedWidget.h:155
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
Definition PopupInfo.h:10