JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::AnimatedPositionBehaviours::ContinuousWithMomentum Struct Reference

A non-snapping behaviour that allows the content to be freely flicked in either direction, with momentum based on the velocity at which it was released, and variable friction to make it come to a halt. More...

#include <juce_AnimatedPositionBehaviours.h>

Collaboration diagram for juce::AnimatedPositionBehaviours::ContinuousWithMomentum:

Public Member Functions

 ContinuousWithMomentum ()=default
 
double getNextPosition (double oldPos, double elapsedSeconds) noexcept
 Called by the AnimatedPosition class to get the new position, after the given time has elapsed. More...
 
bool isStopped (double) const noexcept
 Called by the AnimatedPosition class to check whether the object is now stationary. More...
 
void releasedWithVelocity (double, double releaseVelocity) noexcept
 Called by the AnimatedPosition class. More...
 
void setFriction (double newFriction) noexcept
 Sets the friction that damps the movement of the value. More...
 
void setMinimumVelocity (double newMinimumVelocityToUse) noexcept
 Sets the minimum velocity of the movement. More...
 

Private Attributes

double damping = 0.92
 
double minimumVelocity = 0.05
 
double velocity = 0
 

Detailed Description

A non-snapping behaviour that allows the content to be freely flicked in either direction, with momentum based on the velocity at which it was released, and variable friction to make it come to a halt.

This class is intended to be used as a template parameter to the AnimatedPosition class.

See also
AnimatedPosition

@tags{GUI}

Constructor & Destructor Documentation

◆ ContinuousWithMomentum()

juce::AnimatedPositionBehaviours::ContinuousWithMomentum::ContinuousWithMomentum ( )
default

Member Function Documentation

◆ getNextPosition()

double juce::AnimatedPositionBehaviours::ContinuousWithMomentum::getNextPosition ( double  oldPos,
double  elapsedSeconds 
)
inlinenoexcept

Called by the AnimatedPosition class to get the new position, after the given time has elapsed.

References damping, minimumVelocity, and velocity.

◆ isStopped()

bool juce::AnimatedPositionBehaviours::ContinuousWithMomentum::isStopped ( double  ) const
inlinenoexcept

Called by the AnimatedPosition class to check whether the object is now stationary.

References velocity.

◆ releasedWithVelocity()

void juce::AnimatedPositionBehaviours::ContinuousWithMomentum::releasedWithVelocity ( double  ,
double  releaseVelocity 
)
inlinenoexcept

Called by the AnimatedPosition class.

This tells us the position and velocity at which the user is about to release the object. The velocity is measured in units/second.

References velocity.

◆ setFriction()

void juce::AnimatedPositionBehaviours::ContinuousWithMomentum::setFriction ( double  newFriction)
inlinenoexcept

Sets the friction that damps the movement of the value.

A typical value is 0.08; higher values indicate more friction.

References damping.

◆ setMinimumVelocity()

void juce::AnimatedPositionBehaviours::ContinuousWithMomentum::setMinimumVelocity ( double  newMinimumVelocityToUse)
inlinenoexcept

Sets the minimum velocity of the movement.

Any velocity that's slower than this will stop the animation. The default is 0.05.

References minimumVelocity.

Member Data Documentation

◆ damping

double juce::AnimatedPositionBehaviours::ContinuousWithMomentum::damping = 0.92
private

Referenced by getNextPosition(), and setFriction().

◆ minimumVelocity

double juce::AnimatedPositionBehaviours::ContinuousWithMomentum::minimumVelocity = 0.05
private

◆ velocity

double juce::AnimatedPositionBehaviours::ContinuousWithMomentum::velocity = 0
private

The documentation for this struct was generated from the following file: