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

Applies a multiphase cyberpunk-style text reveal animation to a QLabel. More...

#include <cyberpunk_text_effect.h>

Inheritance diagram for CyberpunkTextEffect:
Collaboration diagram for CyberpunkTextEffect:

Public Member Functions

 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.
 

Private Slots

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.
 

Private Member Functions

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.
 

Private Attributes

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.
 

Detailed Description

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:

  1. Scanning: A vertical bar "|" sweeps across the label's width.
  2. Typing: The original text is revealed character by character, with occasional random glitch characters inserted.
  3. Glitching: A brief final phase where random characters are rapidly inserted and removed from the full text.
  4. Final: The animation stops, displaying the original text cleanly.

The animation is driven by a QTimer.

Constructor & Destructor Documentation

◆ 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
labelPointer to the QLabel widget to animate.
parentOptional parent QObject.
Here is the call graph for this function:

Member Function Documentation

◆ 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.

Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Member Data Documentation

◆ 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: