A QStackedWidget subclass that provides animated transitions between widgets.
More...
#include <animated_stacked_widget.h>
|
| void | SlideToIndex (int index) |
| | Initiates an animated transition to the widget at the specified index. Plays a sound effect and starts the configured animation type. Does nothing if an animation is already running, or the index is invalid/current.
|
| |
| void | SlideToNextIndex () |
| | Initiates an animated transition to the next widget in the stack (wraps around). Useful for creating carousel-like behavior.
|
| |
| void | SlideToWidget (QWidget *widget) |
| | Initiates an animated transition to the specified widget. Convenience slot that finds the index of the widget and calls SlideToIndex().
|
| |
|
| void | AnimateFade (int next_index) const |
| | Configures and adds animations to the animation_group_ for a fade transition.
|
| |
| void | AnimatePush (int next_index) const |
| | Configures and adds animations to the animation_group_ for a push transition.
|
| |
| void | AnimateSlide (int next_index) const |
| | Configures and adds animations to the animation_group_ for a slide transition (CPU fallback).
|
| |
| void | AnimateSlideAndFade (int next_index) const |
| | Configures and adds animations to the animation_group_ for a combined slide and fade transition.
|
| |
|
| int | duration |
| | Property controlling the duration of the transition animation in milliseconds.
|
| |
|
| void | OnGLTransitionFinished () |
| | Slot called when the OpenGL transition animation finishes. Hides the OpenGL widget, updates the current index, shows the target widget, resets animation flags, and emits currentChanged().
|
| |
|
| void | CleanupAfterAnimation () const |
| | Cleans up graphics effects and resets widget geometries after an animation finishes. Ensures widgets are in their correct final state and removes temporary effects.
|
| |
| void | PrepareAnimation (int next_index) const |
| | Prepares the appropriate animation based on animation_type_. Calls the corresponding Animate* method or set up the OpenGL transition. Starts the animation_group_ if not using OpenGL.
|
| |
A QStackedWidget subclass that provides animated transitions between widgets.
This widget enhances the standard QStackedWidget by adding visual animations (like fade, slide, push) when switching between child widgets. It supports different animation types and durations, and can optionally use OpenGL for smoother slide transitions via GLTransitionWidget. It also plays a sound effect during transitions.
◆ AnimationType
Enum defining the available types of transition animations.
| Enumerator |
|---|
| Fade | Cross-fade between the current and next widget.
|
| Slide | Slide the current widget out and the next widget in (can use OpenGL).
|
| SlideAndFade | Combine sliding and fading effects.
|
| Push | Push the current widget partially out while the next slides in.
|
◆ AnimatedStackedWidget()
| AnimatedStackedWidget::AnimatedStackedWidget |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Constructs an AnimatedStackedWidget. Initializes the animation group, sound effect, and the optional OpenGL transition widget. Connects animation signals.
- Parameters
-
| parent | Optional parent widget. |
◆ ~AnimatedStackedWidget()
| AnimatedStackedWidget::~AnimatedStackedWidget |
( |
| ) |
|
|
override |
Destructor. Cleans up the animation group and the OpenGL transition widget.
◆ AnimateFade()
| void AnimatedStackedWidget::AnimateFade |
( |
int | next_index | ) |
const |
|
protected |
Configures and adds animations to the animation_group_ for a fade transition.
- Parameters
-
| next_index | The index of the target widget. |
◆ AnimatePush()
| void AnimatedStackedWidget::AnimatePush |
( |
int | next_index | ) |
const |
|
protected |
Configures and adds animations to the animation_group_ for a push transition.
- Parameters
-
| next_index | The index of the target widget. |
◆ AnimateSlide()
| void AnimatedStackedWidget::AnimateSlide |
( |
int | next_index | ) |
const |
|
protected |
Configures and adds animations to the animation_group_ for a slide transition (CPU fallback).
- Parameters
-
| next_index | The index of the target widget. |
◆ AnimateSlideAndFade()
| void AnimatedStackedWidget::AnimateSlideAndFade |
( |
int | next_index | ) |
const |
|
protected |
Configures and adds animations to the animation_group_ for a combined slide and fade transition.
- Parameters
-
| next_index | The index of the target widget. |
◆ CleanupAfterAnimation()
| void AnimatedStackedWidget::CleanupAfterAnimation |
( |
| ) |
const |
|
private |
Cleans up graphics effects and resets widget geometries after an animation finishes. Ensures widgets are in their correct final state and removes temporary effects.
◆ GetAnimationType()
Gets the currently configured animation type.
- Returns
- The current AnimationType.
◆ GetDuration()
| int AnimatedStackedWidget::GetDuration |
( |
| ) |
const |
|
inline |
Gets the current duration of the transition animation.
- Returns
- The animation duration in milliseconds.
◆ IsAnimating()
| bool AnimatedStackedWidget::IsAnimating |
( |
| ) |
const |
|
inline |
Checks if a transition animation is currently running.
- Returns
- True if an animation is in progress, false otherwise.
◆ OnGLTransitionFinished
| void AnimatedStackedWidget::OnGLTransitionFinished |
( |
| ) |
|
|
privateslot |
Slot called when the OpenGL transition animation finishes. Hides the OpenGL widget, updates the current index, shows the target widget, resets animation flags, and emits currentChanged().
◆ PrepareAnimation()
| void AnimatedStackedWidget::PrepareAnimation |
( |
int | next_index | ) |
const |
|
private |
Prepares the appropriate animation based on animation_type_. Calls the corresponding Animate* method or set up the OpenGL transition. Starts the animation_group_ if not using OpenGL.
- Parameters
-
| next_index | The index of the target widget. |
◆ SetAnimationType()
| void AnimatedStackedWidget::SetAnimationType |
( |
const AnimationType | type | ) |
|
|
inline |
Sets the type of animation to use for transitions.
- Parameters
-
◆ SetDuration()
| void AnimatedStackedWidget::SetDuration |
( |
const int | duration | ) |
|
|
inline |
Sets the duration of the transition animation.
- Parameters
-
| duration | The animation duration in milliseconds. |
◆ SlideToIndex
| void AnimatedStackedWidget::SlideToIndex |
( |
int | index | ) |
|
|
slot |
Initiates an animated transition to the widget at the specified index. Plays a sound effect and starts the configured animation type. Does nothing if an animation is already running, or the index is invalid/current.
- Parameters
-
| index | The index of the target widget. |
◆ SlideToNextIndex
| void AnimatedStackedWidget::SlideToNextIndex |
( |
| ) |
|
|
slot |
Initiates an animated transition to the next widget in the stack (wraps around). Useful for creating carousel-like behavior.
◆ SlideToWidget
| void AnimatedStackedWidget::SlideToWidget |
( |
QWidget * | widget | ) |
|
|
slot |
Initiates an animated transition to the specified widget. Convenience slot that finds the index of the widget and calls SlideToIndex().
- Parameters
-
| widget | Pointer to the target widget. |
◆ animation_group_
| QParallelAnimationGroup* AnimatedStackedWidget::animation_group_ |
|
private |
Parallel animation group managing the individual property animations.
◆ animation_running_
| bool AnimatedStackedWidget::animation_running_ |
|
private |
Flag indicating if a transition animation is currently running.
◆ animation_type_
The type of animation currently configured.
◆ duration_
| int AnimatedStackedWidget::duration_ |
|
private |
Duration of the transition animation in milliseconds.
◆ gl_transition_widget_
Optional widget for handling OpenGL-accelerated slide transitions.
◆ swoosh_sound_
| QSoundEffect* AnimatedStackedWidget::swoosh_sound_ |
|
private |
Sound effect played during transitions.
◆ target_index_
| int AnimatedStackedWidget::target_index_ |
|
private |
Stores the index of the target widget during an animation.
◆ duration
| int AnimatedStackedWidget::duration |
|
readwrite |
Property controlling the duration of the transition animation in milliseconds.
The documentation for this class was generated from the following files: