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

Implements the Resizing state behavior for the Blob animation. More...

#include <resizing_state.h>

Inheritance diagram for ResizingState:
Collaboration diagram for ResizingState:

Public Member Functions

void Apply (std::vector< QPointF > &control_points, std::vector< QPointF > &velocity, QPointF &blob_center, const BlobConfig::BlobParameters &params) override
 Applies state-specific logic. Currently empty for ResizingState. The primary logic for this state is handled in HandleResize().
 
void ApplyForce (const QVector2D &force, std::vector< QPointF > &velocity, QPointF &blob_center, const std::vector< QPointF > &control_points, double blob_radius) override
 Applies an external force to the blob, similar to the Moving state. The force applied to each control point's velocity is scaled based on its distance from the center. A portion of the force is also applied directly to the blob's center position. This is used by HandleResize to apply a force based on the size change.
 
void HandleResize (std::vector< QPointF > &control_points, std::vector< QPointF > &target_points, std::vector< QPointF > &velocity, QPointF &blob_center, const QSize &old_size, const QSize &new_size)
 Handles the logic when a resize event occurs while in this state. Recalculates the blob's center based on the new size, shifts control points and target points accordingly, and applies a force based on the magnitude and direction of the size change.
 
 ResizingState ()
 Default constructor for ResizingState.
 
- Public Member Functions inherited from BlobState
virtual ~BlobState ()=default
 Virtual destructor. Ensures proper cleanup when deleting derived state objects through a base class pointer.
 

Detailed Description

Implements the Resizing state behavior for the Blob animation.

This state is active when the application window is being resized. It primarily handles the adjustment of the blob's position and applies a force based on the size change to create a visual reaction. The Apply() method in this state currently does nothing, as the main logic is triggered by the HandleResize() method.

Constructor & Destructor Documentation

◆ ResizingState()

ResizingState::ResizingState ( )

Default constructor for ResizingState.

Member Function Documentation

◆ Apply()

void ResizingState::Apply ( std::vector< QPointF > & control_points,
std::vector< QPointF > & velocity,
QPointF & blob_center,
const BlobConfig::BlobParameters & params )
overridevirtual

Applies state-specific logic. Currently empty for ResizingState. The primary logic for this state is handled in HandleResize().

Parameters
control_pointsReference to the vector of current control point positions.
velocityReference to the vector of current control point velocities.
blob_centerReference to the blob's center position.
paramsBlob appearance parameters (read-only).

Implements BlobState.

◆ ApplyForce()

void ResizingState::ApplyForce ( const QVector2D & force,
std::vector< QPointF > & velocity,
QPointF & blob_center,
const std::vector< QPointF > & control_points,
double blob_radius )
overridevirtual

Applies an external force to the blob, similar to the Moving state. The force applied to each control point's velocity is scaled based on its distance from the center. A portion of the force is also applied directly to the blob's center position. This is used by HandleResize to apply a force based on the size change.

Parameters
forceThe external force vector to apply.
velocityReference to the vector of current control point velocities (modified).
blob_centerReference to the blob's center position (modified).
control_pointsReference to the vector of current control point positions (read-only).
blob_radiusThe current average radius of the blob (read-only).

Implements BlobState.

Here is the caller graph for this function:

◆ HandleResize()

void ResizingState::HandleResize ( std::vector< QPointF > & control_points,
std::vector< QPointF > & target_points,
std::vector< QPointF > & velocity,
QPointF & blob_center,
const QSize & old_size,
const QSize & new_size )

Handles the logic when a resize event occurs while in this state. Recalculates the blob's center based on the new size, shifts control points and target points accordingly, and applies a force based on the magnitude and direction of the size change.

Parameters
control_pointsReference to the vector of current control point positions (modified).
target_pointsReference to the vector of target control point positions (modified).
velocityReference to the vector of current control point velocities (modified).
blob_centerReference to the blob's center position (modified).
old_sizeThe size of the widget before the resize.
new_sizeThe size of the widget after the resize.
Here is the call graph for this function:

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