Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
gl_transition_widget.h
Go to the documentation of this file.
1#ifndef GL_TRANSITION_WIDGET_H
2#define GL_TRANSITION_WIDGET_H
3
4#include <QOpenGLWidget>
5
6class QPropertyAnimation;
7
16class GLTransitionWidget final : public QOpenGLWidget {
17 Q_OBJECT
19 Q_PROPERTY(float offset READ GetOffset WRITE SetOffset)
20
21public:
27 explicit GLTransitionWidget(QWidget *parent = nullptr);
28
33 ~GLTransitionWidget() override;
34
42 void SetWidgets(QWidget *current_widget, QWidget *next_widget);
43
50 void StartTransition(int duration);
51
56 float GetOffset() const { return offset_; }
57
64 void SetOffset(float offset);
65
66signals:
71
72protected:
79 void paintEvent(QPaintEvent *event) override;
80
81private:
85 QPixmap next_pixmap_;
87 float offset_ = 0.0f;
89 QPropertyAnimation *animation_ = nullptr;
90};
91
92#endif // GL_TRANSITION_WIDGET_H
float offset_
Current progress of the transition animation (0.0 = start, 1.0 = end).
Definition gl_transition_widget.h:87
void StartTransition(int duration)
Starts the slide transition animation. Configures and starts the QPropertyAnimation to animate the 'o...
Definition gl_transition_widget.cpp:36
void SetWidgets(QWidget *current_widget, QWidget *next_widget)
Sets the widgets involved in the transition. Captures the current visual state of the provided widget...
Definition gl_transition_widget.cpp:23
void transitionFinished()
Emitted when the transition animation (QPropertyAnimation) finishes.
void SetOffset(float offset)
Sets the transition offset. This is typically called by the QPropertyAnimation. Updates the internal ...
Definition gl_transition_widget.cpp:44
GLTransitionWidget(QWidget *parent=nullptr)
Constructs a GLTransitionWidget. Initializes the QPropertyAnimation for the offset and sets widget at...
Definition gl_transition_widget.cpp:8
float GetOffset() const
Gets the current transition offset.
Definition gl_transition_widget.h:56
~GLTransitionWidget() override
Destructor. Cleans up the QPropertyAnimation.
Definition gl_transition_widget.cpp:19
QPropertyAnimation * animation_
Animation object controlling the 'offset' property over time.
Definition gl_transition_widget.h:89
QPixmap current_pixmap_
Pixmap captured from the widget sliding out.
Definition gl_transition_widget.h:83
float offset
Property controlling the horizontal offset during the transition (0.0 to 1.0). Animatable.
Definition gl_transition_widget.h:19
void paintEvent(QPaintEvent *event) override
Overridden paint event handler. Renders the transition frame. Draws the current_pixmap_ sliding out t...
Definition gl_transition_widget.cpp:51
QPixmap next_pixmap_
Pixmap captured from the widget sliding in.
Definition gl_transition_widget.h:85