All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
MultiWidgets::Momentum Class Reference

Momentum provides limits and dampening to a floating-point attribute. More...

#include <MultiWidgets/Momentum.hpp>

Inheritance diagram for MultiWidgets::Momentum:
Stylish::Styleable Valuable::Node Valuable::Attribute Patterns::NotCopyable Valuable::Serializable

Public Types

enum  Flags {
  NONE = 0, CYCLIC = (1 << 0), SEEK_TO_NEAREST_INTEGER = (1 << 1), SEEK_TO_PREV_INTEGER = (1 << 2),
  SEEK_TO_NEXT_INTEGER = (1 << 3)
}
 Behaviour flags. More...
 

Valuable Attributes

float attenuate = 0.949999988F
 Determines how the velocity is attenuated. More...
 
float epsilon = 1.99999995E-5F
 The epsilon determines minimum accuracy for the velocity. More...
 
Radiant::FlagsT< Momentum::Flagsflags = NONE
 Flags determine how the value is calculated. More...
 
float max = 100
 Maximum value for the simulated value. More...
 
float min = -100
 Minimum value for the simulated value. More...
 
float snap-multiplier = 3.F
 After simulation is in snapping mode this is the multiplier which will determine how much faster velocity decreases. More...
 
float snap-threshold = 0.00249999994F
 When velocity is less than snap-threshold * (max - min) the value is started to simulate according to the snapping rules. More...
 
float value = 0.F
 Current value of the simulation. More...
 
float velocity = 0.F
 Velocity determines how quickly the simulated value changes. More...
 
float velocity-factor = 60.F
 This attribute determines the factor which velocity is multiplied when updating value. More...
 
- Valuable Attributes inherited from Stylish::Styleable
QString css-class = ""
 Get the CSS classes of the Styleable as a space separated string. More...
 
QString css-id = ""
 Get the CSS id of the Styleable. More...
 
- Valuable Attributes inherited from Valuable::Node
Node::Uuid id = generateId()
 Returns the unique id. More...
 

Public Member Functions

float attenuate () const
 Determines how the velocity is attenuated. More...
 
float epsilon () const
 The epsilon determines minimum accuracy for the velocity. More...
 
Radiant::FlagsT< Flagsflags () const
 Flags determine how the value is calculated. More...
 
float getHistoryVelocity () const
 Returns the average of the velocity from past few frames. More...
 
bool hasTarget () const
 Check if the target value has been specified. More...
 
float maximum () const
 Maximum value for the simulated value. More...
 
float minimum () const
 Minimum value for the simulated value. More...
 
 Momentum (Valuable::Node *host=nullptr)
 Constructs a new Momentum. More...
 
bool moving () const
 Check if the velocity is non-zero. More...
 
void setAttenuate (float att)
 Setter for attribute attenuate. More...
 
void setEpsilon (float e)
 Setter for attribute epsilon. More...
 
void setFlags (Radiant::FlagsT< Flags > flags, bool value)
 Can disable and enable multiple flags at a time. More...
 
void setLimits (float min, float max)
 Sets the limits for the parameter. More...
 
void setMaximum (float max)
 Setter for attribute max. More...
 
void setMinimum (float min)
 Setter for attribute min. More...
 
void setSnapMultiplier (float multiplier)
 Setter for attribute snap-multiplier. More...
 
void setSnapThreshold (float threshold)
 Setter for attribute snap-threshold. More...
 
void setTarget (float target, float vel=0.0f)
 Set a target value for the parameter. More...
 
void setValue (float value)
 Setter for attribute value. More...
 
void setVelocity (float vel)
 Sets velocity for the given value and moves value according the given velocity. More...
 
void setVelocityFactor (float factor)
 Setter for attribute velocity-factor. More...
 
float snapMultiplier () const
 After simulation is in snapping mode this is the multiplier which will determine how much faster velocity decreases. More...
 
float snapThreshold () const
 When velocity is less than snap-threshold * (max - min) the value is started to simulate according to the snapping rules. More...
 
float target () const
 Current target value. More...
 
bool update (float dt, bool autoSnap=true)
 Update the simulation. More...
 
float value () const
 Current value of the simulation. More...
 
float velocity () const
 Velocity determines how quickly the simulated value changes. More...
 
float velocityFactor () const
 This attribute determines the factor which velocity is multiplied when updating value. More...
 
 ~Momentum ()
 Destructor.
 
- Public Member Functions inherited from Stylish::Styleable
void addCSSClass (const QString &s)
 Adds the Styleable to CSS class s. More...
 
void addCSSClasses (const QStringList &classes)
 Adds the Styleable to given CSS classes. More...
 
QString attributeSource (const QByteArray &name) const
 Gets CSS declaration source location based on the attribute name For example if this object has "size" attribute that is set from a CSS file, attributeSource("size") would return "filename.css:line". More...
 
const Style & childStyle () const
 Cached style that should be applied to all children of this object.
 
const Radiant::ArraySet
< QByteArray > & 
cssClasses () const
 Get the CSS classes of the Styleable in lowercase.
 
const QString & cssClassStr () const
 Get the CSS classes of the Styleable as a space separated string. More...
 
QString cssId () const
 Get the CSS id of the Styleable. More...
 
const QByteArray & cssType () const
 Get the CSS type of the Styleable.
 
bool hasCSSClass (const QByteArray &s) const
 Does the Styleable belong to given CSS class. More...
 
bool match (const SimpleSelector &ss, int *specificityOut=nullptr) const
 Checks if SimpleSelector matches this object. More...
 
bool pseudoClass (const QByteArray &name) const
 Query if the Styleable has pseudo class called name.
 
void removeCSSClass (const QString &s)
 Remove the Styleable from CSS class s. More...
 
void setCSSClasses (const QString &s)
 Set the CSS classes as a space separated list You almost always want to use addCSSClass instead of this one. More...
 
void setCSSId (const QString &s)
 Set the CSS id of the Styleable. More...
 
void setCSSType (const QByteArray &s)
 Set the CSS type of the Styleable.
 
virtual bool setProperty (Valuable::Attribute &var, const Valuable::StyleValue &value, Layer layer)
 Converts the given Stylish::Value to Valuable::Attribute.
 
void setPseudoClass (const QByteArray &name, bool state)
 Disable or enable pseudo class.
 
virtual bool setStyle (const Style &style)
 Applies a style to the object. More...
 
QString simpleSelector (bool includePseudoClasses=true) const
 Returns a CSS simple selector that matches this Styleable.
 
const Style & style () const
 Returns the style for this object.
 
 Styleable (const QByteArray &name="Styleable")
 Constructor for Styleable. More...
 
- Public Member Functions inherited from Valuable::Node
bool acceptsEvent (const QByteArray &messageId) const
 Returns true if this object accepts event 'id' in eventProcess.
 
bool addAttribute (Attribute *const attribute)
 Adds a new Attribute to the list of attribute objects. More...
 
bool addAttribute (const QByteArray &name, Attribute *const attribute)
 Adds a new Attribute to the list of attribute objects.
 
template<typename Widget >
bool addAttribute (const QByteArray &name, const Radiant::IntrusivePtr< Widget > &attribute)
 Adds a new Attribute to the list of attribute objects. More...
 
long addListener (const QByteArray &attribute, v8::Persistent< v8::Function > func, int role=Attribute::CHANGE_ROLE)
 Add a JavaScript attribute listener to attribute belonging this Node. More...
 
virtual Attributeattribute (const QByteArray &name) const
 Gets an Attribute with the given name. More...
 
template<typename T >
AttributeT< T > * attribute (const QByteArray &name) const
 Gets an Attribute with the given name. More...
 
const containerattributes () const
 
void clearValues (Layer layer)
 Clears all Attribute values of the given layer. More...
 
void debugDump ()
 Prints the contents of this Attribute to the terminal.
 
virtual bool deserialize (const ArchiveElement &element)
 De-serializes this object (and its children) from a DOM node.
 
void eventAddDeprecated (const QByteArray &deprecatedId, const QByteArray &newId)
 Register a deprecated event that is automatically converted to new event id and a warning is issued when it is used. More...
 
void eventAddIn (const QByteArray &messageId)
 Registers a new event that this class handles in eventProcess.
 
template<typename Widget >
long eventAddListener (const QByteArray &eventId, const QByteArray &messageId, Radiant::IntrusivePtr< Widget > &listener, ListenerType listenerType=DIRECT, const Radiant::BinaryData *defaultData=0)
 Add an event listener to this object. More...
 
long eventAddListener (const QByteArray &eventId, const QByteArray &messageId, Valuable::Node *listener, ListenerType listenerType=DIRECT, const Radiant::BinaryData *defaultData=0)
 Add an event listener to this object. More...
 
long eventAddListener (const QByteArray &eventId, ListenerFuncVoid func, ListenerType listenerType=DIRECT)
 Add an event listener to this object. More...
 
long eventAddListener (const QByteArray &eventId, Node *dstNode, ListenerFuncVoid func, ListenerType listenerType=DIRECT)
 
long eventAddListenerBd (const QByteArray &eventId, Node *dstNode, ListenerFuncBd func, ListenerType listenerType=DIRECT)
 
long eventAddListenerBd (const QByteArray &eventId, ListenerFuncBd func, ListenerType listenerType=DIRECT)
 Add an event listener to this object. More...
 
void eventAddOut (const QByteArray &eventId)
 Registers a new event this class can send with eventSend.
 
const QSet< QByteArray > & eventInNames () const
 Returns set of all registered IN events.
 
unsigned eventListenerCount () const
 Returns the number of event listeners.
 
const QSet< QByteArray > & eventOutNames () const
 Returns set of all registered OUT events.
 
void eventPassingEnable (bool enable)
 Control whether events are passed.
 
template<typename Widget >
int eventRemoveListener (Radiant::IntrusivePtr< Widget > &listener)
 Removes all events from this object to given listener. More...
 
template<typename Widget >
int eventRemoveListener (const QByteArray &eventId=QByteArray(), const QByteArray &messageId=QByteArray(), Radiant::IntrusivePtr< Widget > &listener=Radiant::IntrusivePtr< Widget >())
 Removes events from this object that match the parameters. More...
 
int eventRemoveListener (const QByteArray &eventId=QByteArray(), const QByteArray &messageId=QByteArray(), Valuable::Node *listener=0)
 Removes event listeners from this object. More...
 
int eventRemoveListener (Valuable::Node *listener)
 Removes all events from this object to given listener. More...
 
bool eventRemoveListener (long listenerId)
 Removes event listener with given id. More...
 
void eventSend (const QByteArray &eventId, Radiant::BinaryData &bd)
 Sends an event and bd to all listeners on this eventId.
 
void eventSend (const QByteArray &eventId)
 Sends an event to all listeners on this eventId.
 
template<typename P1 >
void eventSend (const QByteArray &eventId, const P1 &p1)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 , typename P3 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2, const P3 &p3)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 , typename P3 , typename P4 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5)
 Sends an event to all listeners on this eventId. More...
 
unsigned eventSourceCount () const
 Returns the number of event sources.
 
Uuid id () const
 Returns the unique id.
 
bool isBeingDestroyed () const
 Returns true if we are about to delete this object. More...
 
bool loadFromFileXML (const QString &filename)
 Reads this object (and its children) from an XML file.
 
bool loadFromMemoryXML (const QByteArray &buffer)
 Reads this object (and its children) from a memory buffer.
 
 Node (Node *host, const QByteArray &name="", bool transit=false)
 Constructs a new Node and adds it under the given host. More...
 
 Node (Node &&node)
 Moves a node, including all its attributes, events etc. More...
 
Nodeoperator= (Node &&node)
 Moves a node, replacing this. More...
 
virtual bool readElement (const ArchiveElement &element)
 Handles a serialization element that lacks automatic handlers. More...
 
void removeAttribute (Attribute *const attribute)
 Removes an Attribute from the list of attribute objects.
 
bool saveToFileXML (const QString &filename, unsigned int opts=SerializationOptions::DEFAULTS) const
 Saves this object (and its children) to an XML file.
 
bool saveToMemoryXML (QByteArray &buffer, unsigned int opts=SerializationOptions::DEFAULTS) const
 Saves this object (and its children) to binary data buffer.
 
virtual ArchiveElement serialize (Archive &doc) const
 Serializes this object (and its children) to a DOM node.
 
virtual void setAsDefaults ()
 Sets the current USER attribute value as the default value and clears the USER value. More...
 
void setId (Uuid newId)
 Sets the unique id. More...
 
template<class T >
bool setValue (const QByteArray &name, const T &v)
 Uses a query string to find a Attribute, and sets a new value to that if found. More...
 
bool setValue (const QByteArray &name, v8::Handle< v8::Value > v)
 Set attribute value from JavaScript. More...
 
- Public Member Functions inherited from Valuable::Attribute
long addListener (ListenerFunc func, int role=CHANGE_ROLE)
 Adds a listener that is invoked whenever the value is changed. More...
 
long addListener (Node *listener, ListenerFunc func, int role=CHANGE_ROLE)
 Adds a listener that is invoked whenever the value is changed. More...
 
long addListener (v8::Persistent< v8::Function > func, int role=CHANGE_ROLE)
 Adds a JavaScript listener that is invoked whenever the value is changed. More...
 
virtual float asFloat (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object in a floating point number. More...
 
virtual int asInt (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object in an integer. More...
 
virtual QString asString (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object to a string. More...
 
 Attribute (const Attribute &o)
 Create a copy of the given Attribute WITHOUT the link to host, listeners, or the attribute name. More...
 
 Attribute (Node *host, const QByteArray &name, bool transit=false)
 Constructs a new value object and attaches it to its host. More...
 
virtual void clearValue (Layer layer)
 Unsets the value from a specific layer. More...
 
virtual void emitChange ()
 Invokes the change valueChanged function of all listeners.
 
virtual void eventProcess (const QByteArray &id, Radiant::BinaryData &data)
 Process a message. More...
 
void eventProcessFloat (const char *id, float v)
 Utility function for sending a float message to the object.
 
void eventProcessInt (const char *id, int v)
 Utility function for sending an int message to the object.
 
void eventProcessString (const char *id, const QString &str)
 Utility function for sending string message to the object.
 
void eventProcessString (const char *id, const char *str)
 Utility function for sending string message to the object.
 
void eventProcessVector2 (const char *id, Nimble::Vector2)
 Utility function for sending a Nimble::Vector2f message to the object.
 
void eventProcessVector3 (const char *id, Nimble::Vector3)
 Utility function for sending a Vector3 message to the object.
 
void eventProcessVector4 (const char *id, Nimble::Vector4)
 Utility function for sending a Vector4 message to the object.
 
virtual bool handleShorthand (const Valuable::StyleValue &value, Radiant::ArrayMap< Valuable::Attribute *, Valuable::StyleValue > &expanded)
 If attribute supports shorthand properties, this should be used to parse those. More...
 
Nodehost () const
 The host object of the value object (is any). More...
 
virtual bool isChanged () const
 
virtual bool isValueDefinedOnLayer (Layer layer) const
 Check if the given layer defines a value. More...
 
bool layerForSerialization (SerializationOptions flags, Layer &layer) const
 
const QByteArray & name () const
 Returns the name of the object.
 
const Attributeoperator= (const Attribute &)
 Create a copy of the given Attribute WITHOUT the link to host, listeners, or the attribute name. More...
 
AttributeownerShorthand () const
 
QByteArray path () const
 Returns the path (separated by '/'s) from the root.
 
void removeHost ()
 Sets the host pointer to zero and removes this object from the host. More...
 
bool removeListener (Node *listener, int role=ALL_ROLES)
 Removes a listener from the listener list. More...
 
bool removeListener (long id)
 Removes a listener from the listener list. More...
 
void removeListeners (int role=ALL_ROLES)
 Removes listeners from the listener list.
 
virtual bool set (float v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (int v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (const QString &v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector2f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector3f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector4f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const StyleValue &value, Layer layer=USER)
 Sets the value of the object.
 
void setName (const QByteArray &s)
 Sets the name of the object.
 
void setOwnerShorthand (Attribute *owner)
 
virtual QByteArray type () const
 Get the type id of the attribute. More...
 
- Public Member Functions inherited from Valuable::Serializable
virtual bool deserializeXML (const DOMElement &element)
 Deserializes (reads) this object from an XML element. More...
 
bool isSerializable () const
 
void setSerializable (bool v)
 

Additional Inherited Members

- Node Events inherited from Stylish::Styleable
[OUT] pseudo-class-changed (QString name, bool state)
 Pseudo class name was added (state == true) or removed (state == false)
 
- Static Public Member Functions inherited from Valuable::Node
static bool copyValues (const Node &from, Node &to)
 Copies attribute values from one node to another. More...
 
static void disableQueue ()
 Disables all AFTER_UPDATE event processing, no new events will be accepted and the current queue will be cleared. More...
 
static Uuid generateId ()
 Generates a unique identifier. More...
 
static void invokeAfterUpdate (ListenerFuncVoid function)
 Queue function to be called in the main thread after the next update() More...
 
static int processQueue ()
 Triggers any pending AFTER_UPDATE-events. More...
 
static void reEnableQueue ()
 Enables queue after calling disableQueue. More...
 
static void setFatalOnEventMismatch (bool haltApplication)
 Controls what to do when an event mismatch is detected The default behavior is to output a warning to the terminal (haltApplication = false). More...
 
- Protected Member Functions inherited from Stylish::Styleable
virtual void attributeAdded (Attribute *attribute)
 This is called when new attribute is added to Node. More...
 
virtual void attributeRemoved (Attribute *attribute)
 This is called when attribute is removed from Node. More...
 
virtual void updateStyle ()
 Set the style for this object.
 
- Protected Attributes inherited from Stylish::Styleable
Style m_childStyle
 Cached style that should be applied to all children of this object.
 
Valuable::AttributeString m_cssClass
 CSS class of the object as a space separated list.
 
Valuable::AttributeString m_cssId
 CSS id of the object.
 
QByteArray m_cssType
 CSS type of the object.
 
Style m_style
 Currently applied style.
 

Detailed Description

Momentum provides limits and dampening to a floating-point attribute.

Typically Momentum is used to produce animations that feel as if objects would behave in a physical matter. For example, it can be used to simulate dampening of velocity by friction.

To control the Momentum parameters from CSS, you need to use following kind of a construct:

ListWidget > Momentum
{
attenuate: 0.05;
flags: cyclic seek-to-nearest-integer;
}

This example is for a case where the momentum object is used in a ListWidget.

Member Enumeration Documentation

Behaviour flags.

Enumerator
NONE 

"none", No special behaviour

CYCLIC 

"cyclic", Wrap around when the range is exceeded.

SEEK_TO_NEAREST_INTEGER 

"seek-to-nearest-integer", When entering snapping mode, seek to the integer nearest the current value

SEEK_TO_PREV_INTEGER 

"seek-to-previous-integer", When entering snapping mode, seek to the previous integer of the current value

SEEK_TO_NEXT_INTEGER 

"seek-to-next-integer", When entering snapping mode, seek to the integer next to the current value

Constructor & Destructor Documentation

MultiWidgets::Momentum::Momentum ( Valuable::Node host = nullptr)

Constructs a new Momentum.

Parameters
hostHost object of this momentum

Member Function Documentation

float MultiWidgets::Momentum::attenuate ( ) const

Determines how the velocity is attenuated.

When value is one the attenuation is stronger ie. velocity goes fast to zero. Value is effectively clamped to the unit interval.

See Also
setAttenuate
float MultiWidgets::Momentum::epsilon ( ) const

The epsilon determines minimum accuracy for the velocity.

If the velocity drops below epsilon, it is clamped to zero.

See Also
setEpsilon
Radiant::FlagsT<Flags> MultiWidgets::Momentum::flags ( ) const

Flags determine how the value is calculated.

See Also
setFlags
float MultiWidgets::Momentum::getHistoryVelocity ( ) const

Returns the average of the velocity from past few frames.

Useful to avoid sudden changes in velocity when a finger is removed from the screen.

Returns
average velocity
bool MultiWidgets::Momentum::hasTarget ( ) const
inline

Check if the target value has been specified.

Returns
true if the target has been set
float MultiWidgets::Momentum::maximum ( void  ) const

Maximum value for the simulated value.

See Also
setMaximum
Returns
Current value of the max attribute
float MultiWidgets::Momentum::minimum ( void  ) const

Minimum value for the simulated value.

See Also
setMinimum
Returns
Current value of the min attribute
bool MultiWidgets::Momentum::moving ( ) const
inline

Check if the velocity is non-zero.

Returns
true if the velocity differs from zero
void MultiWidgets::Momentum::setAttenuate ( float  att)

Setter for attribute attenuate.

See Also
attenuate
Parameters
attnew attribute value
void MultiWidgets::Momentum::setEpsilon ( float  e)

Setter for attribute epsilon.

See Also
epsilon
Parameters
enew attribute value
void MultiWidgets::Momentum::setFlags ( Radiant::FlagsT< Flags flags,
bool  value 
)

Can disable and enable multiple flags at a time.

Parameters
flagsflags to modify
valuevalue of the flags to set
See Also
flags
void MultiWidgets::Momentum::setLimits ( float  min,
float  max 
)

Sets the limits for the parameter.

See Also
setMinimum, setMaximum
Parameters
minminimum allowed value for the attribute
maxmaximum allowed value for the attribute
void MultiWidgets::Momentum::setMaximum ( float  max)

Setter for attribute max.

See Also
maximum
Parameters
maxnew attribute value
void MultiWidgets::Momentum::setMinimum ( float  min)

Setter for attribute min.

See Also
minimum
Parameters
minnew attribute value
void MultiWidgets::Momentum::setSnapMultiplier ( float  multiplier)

Setter for attribute snap-multiplier.

See Also
snapMultiplier
Parameters
multipliernew attribute value
void MultiWidgets::Momentum::setSnapThreshold ( float  threshold)

Setter for attribute snap-threshold.

See Also
snapThreshold
Parameters
thresholdnew attribute value
void MultiWidgets::Momentum::setTarget ( float  target,
float  vel = 0.0f 
)

Set a target value for the parameter.

The actual value is then interpolated and the dampening is ignored.

See Also
target
Parameters
targetTarget value
velInitial velocity
void MultiWidgets::Momentum::setValue ( float  value)

Setter for attribute value.

Parameters
valuenew attribute value
void MultiWidgets::Momentum::setVelocity ( float  vel)

Sets velocity for the given value and moves value according the given velocity.

Parameters
velNew value for velocity
See Also
velocity
void MultiWidgets::Momentum::setVelocityFactor ( float  factor)

Setter for attribute velocity-factor.

See Also
velocityFactor
Parameters
factornew attribute value
float MultiWidgets::Momentum::snapMultiplier ( ) const

After simulation is in snapping mode this is the multiplier which will determine how much faster velocity decreases.

See Also
setSnapMultiplier, snap-threshold
Returns
Current value of the snap-multiplier attribute
float MultiWidgets::Momentum::snapThreshold ( ) const

When velocity is less than snap-threshold * (max - min) the value is started to simulate according to the snapping rules.

Basically velocity will attenuate snap-multiplier times faster after this.

See Also
setSnapThreshold, snap-multiplier
Returns
Current value of the snap-threshold attribute
float MultiWidgets::Momentum::target ( ) const

Current target value.

See Also
setTarget
Returns
Current target
bool MultiWidgets::Momentum::update ( float  dt,
bool  autoSnap = true 
)

Update the simulation.

Parameters
dtframe time in seconds
autoSnapIf set ot true, momentum will automatically snap to closest integer values
Returns
true if the value was changed; otherwise false
float MultiWidgets::Momentum::value ( ) const
inline

Current value of the simulation.

See Also
setValue
float MultiWidgets::Momentum::velocity ( ) const
inline

Velocity determines how quickly the simulated value changes.

See Also
setVelocity
float MultiWidgets::Momentum::velocityFactor ( ) const

This attribute determines the factor which velocity is multiplied when updating value.

Can be used if wanting to "accelerate" time.

See Also
setVelocityFactor
Returns
Current value of the velocity-factor attribute