Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
GLTransitionWidget Class Referencefinal

An OpenGL widget designed to render smooth, animated slide transitions between two other widgets. More...

#include <gl_transition_widget.h>

Inheritance diagram for GLTransitionWidget:
Collaboration diagram for GLTransitionWidget:

Signals

void transitionFinished ()
 Emitted when the transition animation (QPropertyAnimation) finishes.
 

Public Member Functions

float GetOffset () const
 Gets the current transition offset.
 
 GLTransitionWidget (QWidget *parent=nullptr)
 Constructs a GLTransitionWidget. Initializes the QPropertyAnimation for the offset and sets widget attributes for optimal painting.
 
void SetOffset (float offset)
 Sets the transition offset. This is typically called by the QPropertyAnimation. Updates the internal offset_ value and schedules a repaint of the widget.
 
void SetWidgets (QWidget *current_widget, QWidget *next_widget)
 Sets the widgets involved in the transition. Captures the current visual state of the provided widgets into pixmaps (current_pixmap_, next_pixmap_) which will be used for rendering the animation. Takes a device's pixel ratio into account.
 
void StartTransition (int duration)
 Starts the slide transition animation. Configures and starts the QPropertyAnimation to animate the 'offset' property from 0.0 to 1.0 over the specified duration.
 
 ~GLTransitionWidget () override
 Destructor. Cleans up the QPropertyAnimation.
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 Overridden paint event handler. Renders the transition frame. Draws the current_pixmap_ sliding out to the left and the next_pixmap_ sliding in from the right, based on the current value of offset_. Uses QPainter with high-quality settings.
 

Properties

float offset
 Property controlling the horizontal offset during the transition (0.0 to 1.0). Animatable.
 

Private Attributes

QPropertyAnimation * animation_ = nullptr
 Animation object controlling the 'offset' property over time.
 
QPixmap current_pixmap_
 Pixmap captured from the widget sliding out.
 
QPixmap next_pixmap_
 Pixmap captured from the widget sliding in.
 
float offset_ = 0.0f
 Current progress of the transition animation (0.0 = start, 1.0 = end).
 

Detailed Description

An OpenGL widget designed to render smooth, animated slide transitions between two other widgets.

This widget captures the visual representation (pixmap) of the current and next widgets and then uses QPainter (within the OpenGL context) to draw them sliding horizontally. The transition progress is controlled by a QPropertyAnimation animating the 'offset' property. It's intended to be used by AnimatedStackedWidget for hardware-accelerated slide transitions.

Constructor & Destructor Documentation

◆ GLTransitionWidget()

GLTransitionWidget::GLTransitionWidget ( QWidget * parent = nullptr)
explicit

Constructs a GLTransitionWidget. Initializes the QPropertyAnimation for the offset and sets widget attributes for optimal painting.

Parameters
parentOptional parent widget.
Here is the call graph for this function:

◆ ~GLTransitionWidget()

GLTransitionWidget::~GLTransitionWidget ( )
override

Destructor. Cleans up the QPropertyAnimation.

Member Function Documentation

◆ GetOffset()

float GLTransitionWidget::GetOffset ( ) const
inline

Gets the current transition offset.

Returns
The current offset value (0.0 to 1.0).

◆ paintEvent()

void GLTransitionWidget::paintEvent ( QPaintEvent * event)
overrideprotected

Overridden paint event handler. Renders the transition frame. Draws the current_pixmap_ sliding out to the left and the next_pixmap_ sliding in from the right, based on the current value of offset_. Uses QPainter with high-quality settings.

Parameters
eventThe paint event.

◆ SetOffset()

void GLTransitionWidget::SetOffset ( float offset)

Sets the transition offset. This is typically called by the QPropertyAnimation. Updates the internal offset_ value and schedules a repaint of the widget.

Parameters
offsetThe new offset value (0.0 to 1.0).

◆ SetWidgets()

void GLTransitionWidget::SetWidgets ( QWidget * current_widget,
QWidget * next_widget )

Sets the widgets involved in the transition. Captures the current visual state of the provided widgets into pixmaps (current_pixmap_, next_pixmap_) which will be used for rendering the animation. Takes a device's pixel ratio into account.

Parameters
current_widgetThe widget currently visible, which will slide out.
next_widgetThe widget that will slide in.

◆ StartTransition()

void GLTransitionWidget::StartTransition ( int duration)

Starts the slide transition animation. Configures and starts the QPropertyAnimation to animate the 'offset' property from 0.0 to 1.0 over the specified duration.

Parameters
durationThe duration of the transition in milliseconds.

◆ transitionFinished

void GLTransitionWidget::transitionFinished ( )
signal

Emitted when the transition animation (QPropertyAnimation) finishes.

Here is the caller graph for this function:

Member Data Documentation

◆ animation_

QPropertyAnimation* GLTransitionWidget::animation_ = nullptr
private

Animation object controlling the 'offset' property over time.

◆ current_pixmap_

QPixmap GLTransitionWidget::current_pixmap_
private

Pixmap captured from the widget sliding out.

◆ next_pixmap_

QPixmap GLTransitionWidget::next_pixmap_
private

Pixmap captured from the widget sliding in.

◆ offset_

float GLTransitionWidget::offset_ = 0.0f
private

Current progress of the transition animation (0.0 = start, 1.0 = end).

Property Documentation

◆ offset

float GLTransitionWidget::offset
readwrite

Property controlling the horizontal offset during the transition (0.0 to 1.0). Animatable.


The documentation for this class was generated from the following files: