An OpenGL widget designed to render smooth, animated slide transitions between two other widgets.
More...
#include <gl_transition_widget.h>
|
| void | transitionFinished () |
| | Emitted when the transition animation (QPropertyAnimation) finishes.
|
| |
|
| 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.
|
| |
|
| 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.
|
| |
|
| float | offset |
| | Property controlling the horizontal offset during the transition (0.0 to 1.0). Animatable.
|
| |
|
| 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).
|
| |
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.
◆ GLTransitionWidget()
| GLTransitionWidget::GLTransitionWidget |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Constructs a GLTransitionWidget. Initializes the QPropertyAnimation for the offset and sets widget attributes for optimal painting.
- Parameters
-
| parent | Optional parent widget. |
◆ ~GLTransitionWidget()
| GLTransitionWidget::~GLTransitionWidget |
( |
| ) |
|
|
override |
Destructor. Cleans up the QPropertyAnimation.
◆ 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
-
◆ 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
-
| offset | The 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_widget | The widget currently visible, which will slide out. |
| next_widget | The 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
-
| duration | The duration of the transition in milliseconds. |
◆ transitionFinished
| void GLTransitionWidget::transitionFinished |
( |
| ) |
|
|
signal |
Emitted when the transition animation (QPropertyAnimation) finishes.
◆ 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).
◆ 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: