Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
animated_stacked_widget.h
Go to the documentation of this file.
1
#ifndef ANIMATED_STACKED_WIDGET_H
2
#define ANIMATED_STACKED_WIDGET_H
3
4
#include <QStackedWidget>
5
6
class
GLTransitionWidget
;
7
class
QSoundEffect;
8
class
QParallelAnimationGroup;
9
19
class
AnimatedStackedWidget
final :
public
QStackedWidget {
20
Q_OBJECT
22
Q_PROPERTY(
int
duration
READ
GetDuration
WRITE
SetDuration
)
23
24
public
:
28
enum
AnimationType
{
29
Fade
,
30
Slide
,
31
SlideAndFade
,
32
Push
33
};
34
41
explicit
AnimatedStackedWidget
(QWidget *parent =
nullptr
);
42
47
~AnimatedStackedWidget
()
override
;
48
53
void
SetDuration
(
const
int
duration
) {
duration_
=
duration
; }
54
59
int
GetDuration
()
const
{
return
duration_
; }
60
65
void
SetAnimationType
(
const
AnimationType
type) {
animation_type_
= type; }
66
71
AnimationType
GetAnimationType
()
const
{
return
animation_type_
; }
72
77
bool
IsAnimating
()
const
{
return
animation_running_
; }
78
79
public
slots:
86
void
SlideToIndex
(
int
index);
87
93
void
SlideToWidget
(QWidget *widget);
94
99
void
SlideToNextIndex
();
100
101
protected
:
106
void
AnimateFade
(
int
next_index)
const
;
107
112
void
AnimateSlide
(
int
next_index)
const
;
113
118
void
AnimateSlideAndFade
(
int
next_index)
const
;
119
124
void
AnimatePush
(
int
next_index)
const
;
125
126
private
slots:
132
void
OnGLTransitionFinished
();
133
134
private
:
141
void
PrepareAnimation
(
int
next_index)
const
;
142
147
void
CleanupAfterAnimation
()
const
;
148
150
int
duration_
;
152
AnimationType
animation_type_
;
154
QParallelAnimationGroup *
animation_group_
;
156
bool
animation_running_
;
158
int
target_index_
;
160
GLTransitionWidget
*
gl_transition_widget_
=
nullptr
;
162
QSoundEffect *
swoosh_sound_
;
163
};
164
165
#endif
// ANIMATED_STACKED_WIDGET_H
AnimatedStackedWidget::~AnimatedStackedWidget
~AnimatedStackedWidget() override
Destructor. Cleans up the animation group and the OpenGL transition widget.
Definition
animated_stacked_widget.cpp:38
AnimatedStackedWidget::target_index_
int target_index_
Stores the index of the target widget during an animation.
Definition
animated_stacked_widget.h:158
AnimatedStackedWidget::SlideToIndex
void SlideToIndex(int index)
Initiates an animated transition to the widget at the specified index. Plays a sound effect and start...
Definition
animated_stacked_widget.cpp:43
AnimatedStackedWidget::AnimateSlideAndFade
void AnimateSlideAndFade(int next_index) const
Configures and adds animations to the animation_group_ for a combined slide and fade transition.
Definition
animated_stacked_widget.cpp:190
AnimatedStackedWidget::swoosh_sound_
QSoundEffect * swoosh_sound_
Sound effect played during transitions.
Definition
animated_stacked_widget.h:162
AnimatedStackedWidget::animation_type_
AnimationType animation_type_
The type of animation currently configured.
Definition
animated_stacked_widget.h:152
AnimatedStackedWidget::duration
int duration
Property controlling the duration of the transition animation in milliseconds.
Definition
animated_stacked_widget.h:22
AnimatedStackedWidget::SlideToWidget
void SlideToWidget(QWidget *widget)
Initiates an animated transition to the specified widget. Convenience slot that finds the index of th...
Definition
animated_stacked_widget.cpp:65
AnimatedStackedWidget::AnimateSlide
void AnimateSlide(int next_index) const
Configures and adds animations to the animation_group_ for a slide transition (CPU fallback).
Definition
animated_stacked_widget.cpp:163
AnimatedStackedWidget::SlideToNextIndex
void SlideToNextIndex()
Initiates an animated transition to the next widget in the stack (wraps around). Useful for creating ...
Definition
animated_stacked_widget.cpp:72
AnimatedStackedWidget::GetAnimationType
AnimationType GetAnimationType() const
Gets the currently configured animation type.
Definition
animated_stacked_widget.h:71
AnimatedStackedWidget::IsAnimating
bool IsAnimating() const
Checks if a transition animation is currently running.
Definition
animated_stacked_widget.h:77
AnimatedStackedWidget::CleanupAfterAnimation
void CleanupAfterAnimation() const
Cleans up graphics effects and resets widget geometries after an animation finishes....
Definition
animated_stacked_widget.cpp:119
AnimatedStackedWidget::animation_group_
QParallelAnimationGroup * animation_group_
Parallel animation group managing the individual property animations.
Definition
animated_stacked_widget.h:154
AnimatedStackedWidget::SetDuration
void SetDuration(const int duration)
Sets the duration of the transition animation.
Definition
animated_stacked_widget.h:53
AnimatedStackedWidget::AnimatedStackedWidget
AnimatedStackedWidget(QWidget *parent=nullptr)
Constructs an AnimatedStackedWidget. Initializes the animation group, sound effect,...
Definition
animated_stacked_widget.cpp:10
AnimatedStackedWidget::AnimationType
AnimationType
Enum defining the available types of transition animations.
Definition
animated_stacked_widget.h:28
AnimatedStackedWidget::Push
@ Push
Push the current widget partially out while the next slides in.
Definition
animated_stacked_widget.h:32
AnimatedStackedWidget::Slide
@ Slide
Slide the current widget out and the next widget in (can use OpenGL).
Definition
animated_stacked_widget.h:30
AnimatedStackedWidget::Fade
@ Fade
Cross-fade between the current and next widget.
Definition
animated_stacked_widget.h:29
AnimatedStackedWidget::SlideAndFade
@ SlideAndFade
Combine sliding and fading effects.
Definition
animated_stacked_widget.h:31
AnimatedStackedWidget::SetAnimationType
void SetAnimationType(const AnimationType type)
Sets the type of animation to use for transitions.
Definition
animated_stacked_widget.h:65
AnimatedStackedWidget::OnGLTransitionFinished
void OnGLTransitionFinished()
Slot called when the OpenGL transition animation finishes. Hides the OpenGL widget,...
Definition
animated_stacked_widget.cpp:275
AnimatedStackedWidget::gl_transition_widget_
GLTransitionWidget * gl_transition_widget_
Optional widget for handling OpenGL-accelerated slide transitions.
Definition
animated_stacked_widget.h:160
AnimatedStackedWidget::GetDuration
int GetDuration() const
Gets the current duration of the transition animation.
Definition
animated_stacked_widget.h:59
AnimatedStackedWidget::AnimatePush
void AnimatePush(int next_index) const
Configures and adds animations to the animation_group_ for a push transition.
Definition
animated_stacked_widget.cpp:237
AnimatedStackedWidget::PrepareAnimation
void PrepareAnimation(int next_index) const
Prepares the appropriate animation based on animation_type_. Calls the corresponding Animate* method ...
Definition
animated_stacked_widget.cpp:80
AnimatedStackedWidget::duration_
int duration_
Duration of the transition animation in milliseconds.
Definition
animated_stacked_widget.h:150
AnimatedStackedWidget::AnimateFade
void AnimateFade(int next_index) const
Configures and adds animations to the animation_group_ for a fade transition.
Definition
animated_stacked_widget.cpp:131
AnimatedStackedWidget::animation_running_
bool animation_running_
Flag indicating if a transition animation is currently running.
Definition
animated_stacked_widget.h:156
GLTransitionWidget
An OpenGL widget designed to render smooth, animated slide transitions between two other widgets.
Definition
gl_transition_widget.h:16
src
ui
widgets
animated_stacked_widget.h
Generated by
1.13.2