Manages transitions and movement analysis for the Blob animation based on window events.
More...
#include <blob_transition_manager.h>
|
| void | movementStopped () |
| | Emitted when the inactivity counter exceeds a threshold, indicating that window movement has stopped.
|
| |
| void | significantMovementDetected () |
| | Emitted when the calculated velocity exceeds a threshold, indicating significant window movement.
|
| |
| void | transitionCompleted () |
| | Emitted when a transition (e.g., to idle state) completes.
|
| |
|
| void | AddMovementSample (const QPointF &position, qint64 timestamp) |
| | Adds a new window movement sample to the internal buffer. Removes the oldest sample if the buffer exceeds kMaxMovementSamples. Updates last_movement_time_.
|
| |
| | BlobTransitionManager (QObject *parent=nullptr) |
| | Constructs a BlobTransitionManager.
|
| |
| void | ClearAllMovementBuffers () |
| | Clears the internal movement sample buffer.
|
| |
| void | ClearMovementBuffer () |
| | Clears the internal buffer of window movement samples.
|
| |
| int | GetInactivityCounter () const |
| | Gets the current value of the inactivity counter.
|
| |
| qint64 | GetLastMovementTime () const |
| | Gets the timestamp of the last recorded movement sample.
|
| |
| std::pmr::deque< WindowMovementSample > | GetMovementBuffer () const |
| | Gets a copy of the current movement buffer.
|
| |
| void | IncrementInactivityCounter () |
| | Increments the inactivity counter. Called when no significant movement is detected.
|
| |
| bool | IsMoving () const |
| | Checks if the manager currently considers the window to be moving.
|
| |
| void | ProcessMovementBuffer (std::vector< QPointF > &velocity, QPointF &blob_center, std::vector< QPointF > &control_points, float blob_radius, const std::function< void(std::vector< QPointF > &, QPointF &, std::vector< QPointF > &, float, QVector2D)> &ApplyInertiaForce, const std::function< void(const QPointF &)> &SetLastWindowPos) |
| | Processes the buffered window movement samples to calculate velocity and apply inertia.
|
| |
| void | ResetInactivityCounter () |
| | Resets the inactivity counter to zero. Typically called when movement is detected.
|
| |
| void | SetLastMovementTime (const qint64 time) |
| | Manually sets the timestamp of the last movement.
|
| |
| void | SetMoving (const bool is_moving) |
| | Manually sets the moving state.
|
| |
| void | SetResizingState (const bool is_resizing) |
| | Sets the flag indicating whether the window is currently being resized. Movement processing is skipped if this flag is true.
|
| |
|
| int | inactivity_counter_ = 0 |
| | Counter incremented each frame when no significant movement is detected. Used to determine when movement stops.
|
| |
| bool | is_moving_ = false |
| | Flag indicating if the window is currently considered to be moving based on processed samples.
|
| |
| bool | is_resizing_ = false |
| | Flag indicating if the window is currently being resized (prevents movement processing during resize).
|
| |
| qint64 | last_movement_time_ = 0 |
| | Timestamp (ms since epoch) of the last added movement sample.
|
| |
| QVector2D | m_smoothed_velocity_ |
| | Smoothed velocity vector calculated from the movement buffer.
|
| |
| std::pmr::deque< WindowMovementSample > | movement_buffer_ |
| | Buffer storing recent window movement samples. Uses polymorphic allocator for potential performance benefits.
|
| |
|
| static constexpr int | kMaxMovementSamples = 10 |
| | Maximum number of window movement samples to store in the buffer.
|
| |
Manages transitions and movement analysis for the Blob animation based on window events.
This class processes a buffer of window movement samples to calculate velocity and determine if the window is actively moving. It applies inertia forces to the blob based on this movement and detects when movement starts and stops.
◆ BlobTransitionManager()
| BlobTransitionManager::BlobTransitionManager |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
◆ AddMovementSample()
| void BlobTransitionManager::AddMovementSample |
( |
const QPointF & | position, |
|
|
qint64 | timestamp ) |
Adds a new window movement sample to the internal buffer. Removes the oldest sample if the buffer exceeds kMaxMovementSamples. Updates last_movement_time_.
- Parameters
-
| position | The window position sample. |
| timestamp | The timestamp of the sample. |
◆ ClearAllMovementBuffers()
| void BlobTransitionManager::ClearAllMovementBuffers |
( |
| ) |
|
|
inline |
Clears the internal movement sample buffer.
◆ ClearMovementBuffer()
| void BlobTransitionManager::ClearMovementBuffer |
( |
| ) |
|
Clears the internal buffer of window movement samples.
◆ GetInactivityCounter()
| int BlobTransitionManager::GetInactivityCounter |
( |
| ) |
const |
|
inlinenodiscard |
Gets the current value of the inactivity counter.
- Returns
- The inactivity counter-value.
◆ GetLastMovementTime()
| qint64 BlobTransitionManager::GetLastMovementTime |
( |
| ) |
const |
|
inlinenodiscard |
Gets the timestamp of the last recorded movement sample.
- Returns
- Timestamp in milliseconds since the epoch.
◆ GetMovementBuffer()
Gets a copy of the current movement buffer.
- Returns
- A deque containing the recent WindowMovementSample structs.
◆ IncrementInactivityCounter()
| void BlobTransitionManager::IncrementInactivityCounter |
( |
| ) |
|
|
inline |
Increments the inactivity counter. Called when no significant movement is detected.
◆ IsMoving()
| bool BlobTransitionManager::IsMoving |
( |
| ) |
const |
|
inlinenodiscard |
Checks if the manager currently considers the window to be moving.
- Returns
- True if moving, false otherwise.
◆ movementStopped
| void BlobTransitionManager::movementStopped |
( |
| ) |
|
|
signal |
Emitted when the inactivity counter exceeds a threshold, indicating that window movement has stopped.
◆ ProcessMovementBuffer()
| void BlobTransitionManager::ProcessMovementBuffer |
( |
std::vector< QPointF > & | velocity, |
|
|
QPointF & | blob_center, |
|
|
std::vector< QPointF > & | control_points, |
|
|
float | blob_radius, |
|
|
const std::function< void(std::vector< QPointF > &, QPointF &, std::vector< QPointF > &, float, QVector2D)> & | ApplyInertiaForce, |
|
|
const std::function< void(const QPointF &)> & | SetLastWindowPos ) |
Processes the buffered window movement samples to calculate velocity and apply inertia.
Calculates a smoothed velocity based on recent movement samples. If significant movement is detected, it calls the provided ApplyInertiaForce function to affect the blob's dynamics, updates the last known window position, resets the inactivity counter, and emits significantMovementDetected(). If movement stops, it increments the inactivity counter and emits movementStopped() after a period of inactivity.
- Parameters
-
| velocity | Reference to the vector storing velocities of blob control points (modified by ApplyInertiaForce). |
| blob_center | Reference to the blob's center position (modified by ApplyInertiaForce). |
| control_points | Reference to the vector storing blob control points (modified by ApplyInertiaForce). |
| blob_radius | The current radius of the blob. |
| ApplyInertiaForce | A function callback to apply the calculated inertia force to the blob's state. |
| SetLastWindowPos | A function callback to update the last known window position used by dynamics. |
◆ ResetInactivityCounter()
| void BlobTransitionManager::ResetInactivityCounter |
( |
| ) |
|
|
inline |
Resets the inactivity counter to zero. Typically called when movement is detected.
◆ SetLastMovementTime()
| void BlobTransitionManager::SetLastMovementTime |
( |
const qint64 | time | ) |
|
|
inline |
Manually sets the timestamp of the last movement.
- Parameters
-
| time | The timestamp in milliseconds since the epoch. |
◆ SetMoving()
| void BlobTransitionManager::SetMoving |
( |
const bool | is_moving | ) |
|
|
inline |
Manually sets the moving state.
- Parameters
-
| is_moving | The new moving state. |
◆ SetResizingState()
| void BlobTransitionManager::SetResizingState |
( |
const bool | is_resizing | ) |
|
|
inline |
Sets the flag indicating whether the window is currently being resized. Movement processing is skipped if this flag is true.
- Parameters
-
| is_resizing | True if resizing, false otherwise. |
◆ significantMovementDetected
| void BlobTransitionManager::significantMovementDetected |
( |
| ) |
|
|
signal |
Emitted when the calculated velocity exceeds a threshold, indicating significant window movement.
◆ transitionCompleted
| void BlobTransitionManager::transitionCompleted |
( |
| ) |
|
|
signal |
Emitted when a transition (e.g., to idle state) completes.
◆ inactivity_counter_
| int BlobTransitionManager::inactivity_counter_ = 0 |
|
private |
Counter incremented each frame when no significant movement is detected. Used to determine when movement stops.
◆ is_moving_
| bool BlobTransitionManager::is_moving_ = false |
|
private |
Flag indicating if the window is currently considered to be moving based on processed samples.
◆ is_resizing_
| bool BlobTransitionManager::is_resizing_ = false |
|
private |
Flag indicating if the window is currently being resized (prevents movement processing during resize).
◆ kMaxMovementSamples
| int BlobTransitionManager::kMaxMovementSamples = 10 |
|
staticconstexprprivate |
Maximum number of window movement samples to store in the buffer.
◆ last_movement_time_
| qint64 BlobTransitionManager::last_movement_time_ = 0 |
|
private |
Timestamp (ms since epoch) of the last added movement sample.
◆ m_smoothed_velocity_
| QVector2D BlobTransitionManager::m_smoothed_velocity_ |
|
private |
Smoothed velocity vector calculated from the movement buffer.
◆ movement_buffer_
Buffer storing recent window movement samples. Uses polymorphic allocator for potential performance benefits.
The documentation for this class was generated from the following files: