Applies a multiphase cyberpunk-style text reveal animation to a QLabel.
More...
#include <cyberpunk_text_effect.h>
|
| | CyberpunkTextEffect (QLabel *label, QWidget *parent=nullptr) |
| | Constructs a CyberpunkTextEffect. Stores the target QLabel, hides it initially, and sets up the animation timer.
|
| |
| void | StartAnimation () |
| | Starts the text reveal an animation sequence from the beginning. Resets the animation phase and character index, then starts the internal timer.
|
| |
|
| void | NextAnimationStep () |
| | Slot called periodically by the timer to advance the animation. Executes the logic for the current animation phase (scanning, typing, glitching) by calling the corresponding private Animate* method. Stops the timer when the animation completes.
|
| |
|
| void | AnimateGlitching () |
| | Handles the final "Glitching" phase of the animation. Briefly displays the full text with rapidly changing random characters inserted. Transitions to the final phase when complete.
|
| |
| void | AnimateScanning () |
| | Handles the "Scanning" phase of the animation. Displays a sweeping vertical bar "|" across the label's width. Transitions to the "Typing" phase when complete.
|
| |
| void | AnimateTyping () |
| | Handles the "Typing" phase of the animation. Reveals the original text character by character, inserting random glitch characters occasionally. Transitions to the "Glitching" phase when complete.
|
| |
|
| int | char_index_ = 0 |
| | Index used during scanning and typing phases to track progress.
|
| |
| int | glitch_count_ = 0 |
| | Counter used during the final glitching phase.
|
| |
| QLabel * | label_ |
| | Pointer to the QLabel widget being animated.
|
| |
| QString | original_text_ |
| | The original text content of the label.
|
| |
| int | phase_ = 0 |
| | Current phase of the animation (0: Scan, 1: Type, 2: Glitch, 3: Done).
|
| |
| QTimer * | timer_ |
| | Timer driving the animation steps.
|
| |
Applies a multiphase cyberpunk-style text reveal animation to a QLabel.
This class takes control of a QLabel and animates its text content through several phases:
- Scanning: A vertical bar "|" sweeps across the label's width.
- Typing: The original text is revealed character by character, with occasional random glitch characters inserted.
- Glitching: A brief final phase where random characters are rapidly inserted and removed from the full text.
- Final: The animation stops, displaying the original text cleanly.
The animation is driven by a QTimer.
◆ CyberpunkTextEffect()
| CyberpunkTextEffect::CyberpunkTextEffect |
( |
QLabel * | label, |
|
|
QWidget * | parent = nullptr ) |
|
explicit |
Constructs a CyberpunkTextEffect. Stores the target QLabel, hides it initially, and sets up the animation timer.
- Parameters
-
| label | Pointer to the QLabel widget to animate. |
| parent | Optional parent QObject. |
◆ AnimateGlitching()
| void CyberpunkTextEffect::AnimateGlitching |
( |
| ) |
|
|
private |
Handles the final "Glitching" phase of the animation. Briefly displays the full text with rapidly changing random characters inserted. Transitions to the final phase when complete.
◆ AnimateScanning()
| void CyberpunkTextEffect::AnimateScanning |
( |
| ) |
|
|
private |
Handles the "Scanning" phase of the animation. Displays a sweeping vertical bar "|" across the label's width. Transitions to the "Typing" phase when complete.
◆ AnimateTyping()
| void CyberpunkTextEffect::AnimateTyping |
( |
| ) |
|
|
private |
Handles the "Typing" phase of the animation. Reveals the original text character by character, inserting random glitch characters occasionally. Transitions to the "Glitching" phase when complete.
◆ NextAnimationStep
| void CyberpunkTextEffect::NextAnimationStep |
( |
| ) |
|
|
privateslot |
Slot called periodically by the timer to advance the animation. Executes the logic for the current animation phase (scanning, typing, glitching) by calling the corresponding private Animate* method. Stops the timer when the animation completes.
◆ StartAnimation()
| void CyberpunkTextEffect::StartAnimation |
( |
| ) |
|
Starts the text reveal an animation sequence from the beginning. Resets the animation phase and character index, then starts the internal timer.
◆ char_index_
| int CyberpunkTextEffect::char_index_ = 0 |
|
private |
Index used during scanning and typing phases to track progress.
◆ glitch_count_
| int CyberpunkTextEffect::glitch_count_ = 0 |
|
private |
Counter used during the final glitching phase.
◆ label_
| QLabel* CyberpunkTextEffect::label_ |
|
private |
Pointer to the QLabel widget being animated.
◆ original_text_
| QString CyberpunkTextEffect::original_text_ |
|
private |
The original text content of the label.
◆ phase_
| int CyberpunkTextEffect::phase_ = 0 |
|
private |
Current phase of the animation (0: Scan, 1: Type, 2: Glitch, 3: Done).
◆ timer_
| QTimer* CyberpunkTextEffect::timer_ |
|
private |
Timer driving the animation steps.
The documentation for this class was generated from the following files: