The IScrollProcessor interface. More...
#include "murl_logic_i_scroll_processor.h"
Inherited by Murl::Logic::ScrollProcessor.
Public Member Functions | |
virtual IProcessorPtr | GetProcessor ()=0 |
Get the processor interface from a IScrollProcessor object. More... | |
Setup button | |
Methods to setup the button to track. | |
virtual void | SetButtonId (const String &buttonId)=0 |
Set the path and identifier of the button node to track. More... | |
virtual const String & | GetButtonId () const =0 |
Get the identifier of the button node to track. More... | |
virtual Bool | SetButtonNode (Graph::INode *buttonNode)=0 |
Set the button node to track. More... | |
virtual Graph::IButton * | GetButtonNode () const =0 |
Get the button node to track. More... | |
virtual Bool | SetButtonEnabled (Bool isEnabled)=0 |
Set enable or disable the button. More... | |
virtual Bool | IsButtonEnabled () const =0 |
Check if the button is enabled. More... | |
Setup input | |
Methods for controlling relative inputs. | |
virtual void | SetDeadZode (const Vector &distances)=0 |
Set the dead zone distances. More... | |
virtual const Vector & | GetDeadZone () const =0 |
Get the minimum dead zone distances. More... | |
virtual void | SetAccelerationFactor (Real accelerationFactor)=0 |
Set the acceleration factor. More... | |
virtual Real | GetAccelerationFactor () const =0 |
Get the acceleration factor. More... | |
virtual void | SetAccelerationTimeout (Real timeout)=0 |
Set the acceleration timeout. More... | |
virtual Real | GetAccelerationTimeout () const =0 |
Get the acceleration timeout. More... | |
virtual Bool | SetDecelerationFactor (Real decelerationFactor)=0 |
Set the deceleration factor. More... | |
virtual Real | GetDecelerationFactor () const =0 |
Get the deceleration factor. More... | |
virtual void | SetDecelerationTimeout (Real timeout)=0 |
Set the deceleration timeout. More... | |
virtual Real | GetDecelerationTimeout () const =0 |
Get the deceleration timeout. More... | |
virtual void | SetStopVelocity (Real stopVelocity)=0 |
Set the deceleration stop velocity. More... | |
virtual Real | GetStopVelocity () const =0 |
Get the deceleration stop velocity. More... | |
virtual void | SetMaxVelocity (Real maxVelocity)=0 |
Set the maximum velocity. More... | |
virtual Real | GetMaxVelocity () const =0 |
Get the maximum velocity. More... | |
Current states | |
Methods for getting the current states. | |
virtual Bool | IsActive () const =0 |
Check if the ScrollProcessor is active. More... | |
virtual Bool | IsOutsideDeadZone () const =0 |
Check if the current movement is outside the dead zone. More... | |
virtual Bool | IsButtonPressed () const =0 |
Check if the graph button is tracked and pressed. More... | |
virtual Bool | WasButtonReleased () const =0 |
Check if the graph button was released. More... | |
virtual Bool | WasButtonReleasedInsideDeadZone () const =0 |
Check if the graph button was released inside the dead zone. More... | |
Movement controlling | |
Methods for controlling the current movement. | |
virtual const Vector & | GetMovement () const =0 |
Get the recent movement. More... | |
virtual Bool | BeginMovement (const IState *state)=0 |
Begin setting the next movement. More... | |
virtual Bool | EndMovement (const IState *state)=0 |
End setting the next movement. More... | |
virtual Bool | SetMovement (const Vector &delta)=0 |
Set the next movement. More... | |
virtual void | ResetMovement ()=0 |
Reset the current movement including all current states. | |
Position tracking | |
Methods for position tracking. Consider that the position tracking operates on vector data, which means that all 3 axis (x/y/z) are evaluated and should be setup correctly. | |
virtual void | SetPositionEnabled (Bool isEnabled)=0 |
Set enable or disable the position tracking. More... | |
virtual Bool | IsPositionEnabled () const =0 |
Check if the position tracking is enabled. More... | |
virtual void | SetMinPosition (const Vector &position)=0 |
Set the minimum position. More... | |
virtual const Vector & | GetMinPosition () const =0 |
Get the minimum position. More... | |
virtual void | SetMaxPosition (const Vector &position)=0 |
Set the maximum position. More... | |
virtual const Vector & | GetMaxPosition () const =0 |
Get the maximum position. More... | |
virtual void | SetMinDampDistance (const Vector &distance)=0 |
Set the damping distance for the minimum position. More... | |
virtual const Vector & | GetMinDampDistance () const =0 |
Get the damping distance for the minimum position. More... | |
virtual void | SetMaxDampDistance (const Vector &distance)=0 |
Set the damping distance for the maximum position. More... | |
virtual const Vector & | GetMaxDampDistance () const =0 |
Get the damping distance for the maximum position. More... | |
virtual void | SetDampFactor (Real dampFactor)=0 |
Set the damping factor. More... | |
virtual Real | GetDampFactor () const =0 |
Get the damping factor. More... | |
virtual void | SetBounceTime (Real bounceTime)=0 |
Set the bounce time. More... | |
virtual Real | GetBounceTime () const =0 |
Get the bounce time. More... | |
virtual void | SetBounceInterpolation (IEnums::Interpolation interpolation)=0 |
Set the bounce interpolation. More... | |
virtual IEnums::Interpolation | GetBounceInterpolation () const =0 |
Get the bounce interpolation. More... | |
virtual const Vector & | GetPosition () const =0 |
Get the current position. More... | |
virtual void | SetPosition (const Vector &position)=0 |
Set the current position. More... | |
virtual Bool | MoveToPosition (Real duration, const Vector &position, IEnums::Interpolation interpolation=IEnums::INTERPOLATION_EASE_IN_OUT)=0 |
Start a position animation. More... | |
virtual Bool | IsMoveToPositionRunning () const =0 |
Check if the position animation is running. More... | |
virtual Bool | WasMoveToPositionRunning () const =0 |
Check if the position animation has stopped running. More... | |
Detailed Description
The IScrollProcessor interface.
The ScrollProcessor is used for tracking the inputs of a Graph::IButton node and/or any input provided by the user's logic code.
The ScrollProcessor is used for scroll areas and swipe gestures:
- Tracking the relative movement of the input.
- Performing a deceleration when the input is released.
- Performing an acceleration when the input is repeated.
Additional a position tracking can be used for:
- Tracking an absolute position.
- Specifying minimum and maximum bounds.
- Damping on the bounds.
- Position animation.
The ScrollProcessor operates in units of 1, which means the button size is 1 in x and y direction independent of the button's scalefactor.
All values used by the ScrollProcessor simply operates in units of 1. Scaling the results to adequate values applies to the user's logic code.
The ScrollProcessor implements an IProcessor which is typically attached as a child of an user defined logic processor.
Member Function Documentation
◆ GetProcessor()
|
pure virtual |
Get the processor interface from a IScrollProcessor object.
The ScrollProcessor implements an IProcessor which is typically attached as a child of an user defined logic processor.
- Returns
- The processor interface shared pointer.
◆ SetButtonId()
|
pure virtual |
Set the path and identifier of the button node to track.
The button node can be set alternatively by using SetButtonNode().
- Parameters
-
buttonId The full path and identifier to a button node.
◆ GetButtonId()
|
pure virtual |
Get the identifier of the button node to track.
The identifier contains the path and identifier set by SetButtonId(). If the button node is specified by SetButtonNode() the identifier contains the node identifer only without path.
- Returns
- The identifier of the button node.
◆ SetButtonNode()
|
pure virtual |
Set the button node to track.
The button node can be set alternatively by using SetButtonId().
- Parameters
-
buttonNode The button node object.
- Returns
- true if successful, false if the node is invalid.
◆ GetButtonNode()
|
pure virtual |
Get the button node to track.
If the button node is specified by SetButtonId() the node is valid after Init() or at least one tick has been processed. If using SetButtonNode() the button node is available immediately.
- Returns
- The button node object.
◆ SetButtonEnabled()
Set enable or disable the button.
- Parameters
-
isEnabled true for enable, false for disable.
- Returns
- true if successful.
◆ IsButtonEnabled()
|
pure virtual |
Check if the button is enabled.
- Returns
- true if the button is enabled.
◆ SetDeadZode()
|
pure virtual |
Set the dead zone distances.
The dead zone distance specifies the minimum length of the input movement on the corresponding axis. This is useful to filter "short" movements when tapping on the button, use WasButtonReleasedInsideDeadZone(). The dead zone state is available by IsOutsideDeadZone() which is set to true if the input movement exceeds any of the dead zone minimum distances. If the minimum distance is <= 0.0 the corresponding axis is ignored. The deceleration/acceleration is applied only if the input movement is outside the dead zone.
The default value is Vector(0.01, 0.01, 0.01, 0.0) in units.
- Parameters
-
distances The minimum input move distances in units.
◆ GetDeadZone()
|
pure virtual |
Get the minimum dead zone distances.
- Returns
- The minimum dead zone distances in units.
◆ SetAccelerationFactor()
|
pure virtual |
Set the acceleration factor.
If an input is repeated within the acceleration timeout, the recent velocity of the previous input is multiplied by the acceleration factor and added to the current velocity.
The default value is 16.0.
- Parameters
-
accelerationFactor The acceleration factor.
◆ GetAccelerationFactor()
|
pure virtual |
Get the acceleration factor.
- Returns
- The acceleration factor.
◆ SetAccelerationTimeout()
|
pure virtual |
Set the acceleration timeout.
The acceleration is applied only if an input is repeated within the acceleration timeout.
The default value is 0.5 seconds.
- Parameters
-
timeout The acceleration timeout in seconds.
◆ GetAccelerationTimeout()
|
pure virtual |
Get the acceleration timeout.
- Returns
- The acceleration timeout in seconds.
◆ SetDecelerationFactor()
|
pure virtual |
Set the deceleration factor.
The deceleration factor is multiplied to the recent movement when the input ends. The deceleration stops if the recent velocity underflows the stop velocity value.
The default value is 0.01.
- Parameters
-
decelerationFactor The deceleration factor per second must be < 1.
- Returns
- true if successful, false if decelerationFactor is >= 1.
◆ GetDecelerationFactor()
|
pure virtual |
Get the deceleration factor.
- Returns
- The deceleration factor per second.
◆ SetDecelerationTimeout()
|
pure virtual |
Set the deceleration timeout.
Inhibit deceleration if the time between the last and the recent movement exceeds the deceleration timeout.
The default value is 0.1 seconds.
- Parameters
-
timeout The deceleration timeout in seconds.
◆ GetDecelerationTimeout()
|
pure virtual |
Get the deceleration timeout.
- Returns
- The deceleration timeout in seconds.
◆ SetStopVelocity()
|
pure virtual |
Set the deceleration stop velocity.
The deceleration stops if the recent velocity underflows the stop velocity value.
The default value is 0.01 units/second.
- Parameters
-
stopVelocity The deceleration stop velocity value.
◆ GetStopVelocity()
|
pure virtual |
Get the deceleration stop velocity.
- Returns
- The deceleration stop velocity in units/seconds.
◆ SetMaxVelocity()
|
pure virtual |
Set the maximum velocity.
The maximum velocity is the highest allowed velocity, which means the current velocity is clamped to the maximum velocity. The velocity is not clamped if the maximum velocity is 0.
The default value is 32.0 units/second.
- Parameters
-
maxVelocity The the maximum velocity in units/second.
◆ GetMaxVelocity()
|
pure virtual |
Get the maximum velocity.
- Returns
- The maximum velocity in units/second.
◆ IsActive()
|
pure virtual |
Check if the ScrollProcessor is active.
The ScrollProcessor is active if the graph button is pressed or the accleration/deceleration is active or the move animation is running.
- Returns
- true if the ScrollProcessor is active.
◆ IsOutsideDeadZone()
|
pure virtual |
Check if the current movement is outside the dead zone.
This state reports also true if the deceleration is stopped by a tap, even if the tap's input is probably inside the dead zone. See also SetDeadZode().
- Returns
- true if the current movement is outside the dead zone.
◆ IsButtonPressed()
|
pure virtual |
Check if the graph button is tracked and pressed.
- Returns
- true if the graph button is pressed.
◆ WasButtonReleased()
|
pure virtual |
Check if the graph button was released.
- Returns
- true if the graph button was released.
◆ WasButtonReleasedInsideDeadZone()
|
pure virtual |
Check if the graph button was released inside the dead zone.
- Returns
- true if the graph button was released inside the dead zone.
◆ GetMovement()
|
pure virtual |
Get the recent movement.
The movement is set by the button input or the acceleration/deceleration or the move animation.
- Returns
- The movement vector in units of the recent tick.
◆ BeginMovement()
Begin setting the next movement.
This method can be called optionally before applying custom movements using SetMovement(). This enables the deceleration/acceleration behaviour. The movement can be set only if the button is not pressed.
- Parameters
-
state The IState object.
- Returns
- true if successful, false if the button is pressed.
◆ EndMovement()
End setting the next movement.
This method can be called optionally after applying custom movements using SetMovement(). This applies the deceleration/acceleration behaviour. The movement can be set only if the button is not pressed.
- Parameters
-
state The IState object.
- Returns
- true if successful, false if the button is pressed.
◆ SetMovement()
Set the next movement.
Setting the movement sets the IsActive() state to true in the next tick. The movement can be set only if the button is not pressed. If the button is pressed during the next tick, the next movement is ignored. See also BeginMovement() and EndMovement().
- Parameters
-
delta The movement vector in units for the next tick.
- Returns
- true if successful, false if the button is pressed.
◆ SetPositionEnabled()
|
pure virtual |
Set enable or disable the position tracking.
The position tracking can be disabled for implementing endless scrolling by using the relative movement methods only, typically GetMovement().
The default value is true.
- Parameters
-
isEnabled true for enable, false for disable.
◆ IsPositionEnabled()
|
pure virtual |
Check if the position tracking is enabled.
- Returns
- true if the position tracking is enabled.
◆ SetMinPosition()
|
pure virtual |
Set the minimum position.
The default value is Vector(0.0, 0.0, 0.0, 1.0).
- Parameters
-
position The minimum position in units.
◆ GetMinPosition()
|
pure virtual |
Get the minimum position.
- Returns
- The minimum position in units.
◆ SetMaxPosition()
|
pure virtual |
Set the maximum position.
The default value is Vector(1.0, 1.0, 1.0, 1.0).
- Parameters
-
position The maximum position in units.
◆ GetMaxPosition()
|
pure virtual |
Get the maximum position.
- Returns
- The maximum position in units.
◆ SetMinDampDistance()
|
pure virtual |
Set the damping distance for the minimum position.
The damping distance specifies an extra minimum to converge to. The position range is (minimum position - minimum damping distance, minimum position].
The default value is Vector(0.5, 0.5, 0.5, 0.0).
- Parameters
-
distance The damping distance for the minimum position in units.
◆ GetMinDampDistance()
|
pure virtual |
Get the damping distance for the minimum position.
- Returns
- The damping distance for the minimum position in units.
◆ SetMaxDampDistance()
|
pure virtual |
Set the damping distance for the maximum position.
The damping distance specifies an extra maximum to converge to. The position range is [maximum position, maximum position + maximum damping distance).
The default value is Vector(0.5, 0.5, 0.5, 0.0).
- Parameters
-
distance The damping distance for the maximum position in units.
◆ GetMaxDampDistance()
|
pure virtual |
Get the damping distance for the maximum position.
- Returns
- The damping distance for the maximum position in units.
◆ SetDampFactor()
|
pure virtual |
Set the damping factor.
The higher the factor, the stronger is the damping (1 + 1 / (-x / f - 1)).
The default value is 1.0.
- Parameters
-
dampFactor The damping factor should be >= 1.0.
◆ GetDampFactor()
|
pure virtual |
Get the damping factor.
- Returns
- The damping factor.
◆ SetBounceTime()
|
pure virtual |
Set the bounce time.
The bounce time is the duration to move back from the damping area to the minimum / maximum position.
- Parameters
-
bounceTime The bounce time in seconds.
◆ GetBounceTime()
|
pure virtual |
Get the bounce time.
- Returns
- The bounce time in seconds.
◆ SetBounceInterpolation()
|
pure virtual |
Set the bounce interpolation.
The bounce interpolation is applied when moving back from the damping area to the minimum / maximum position.
- Parameters
-
interpolation The bounce interpolation.
◆ GetBounceInterpolation()
|
pure virtual |
Get the bounce interpolation.
- Returns
- The bounce interpolation.
◆ GetPosition()
|
pure virtual |
Get the current position.
- Returns
- The current position in units.
◆ SetPosition()
|
pure virtual |
Set the current position.
If setting the position simply set the "real" position from input, this method calculates immediately the resulting damped position if necessary, use GetPosition() to get the resulting position.
- Parameters
-
position The current position in units.
◆ MoveToPosition()
|
pure virtual |
Start a position animation.
The position animation starts at the current position and and can be triggered only if the ScrollProcessor is not active.
- Parameters
-
duration The animation duration in seconds. position The destination position in units. interpolation The interpolation type.
- Returns
- true if the animation was started successfully, false if the ScrollProcessor is already active.
◆ IsMoveToPositionRunning()
|
pure virtual |
Check if the position animation is running.
- Returns
- true if running.
◆ WasMoveToPositionRunning()
|
pure virtual |
Check if the position animation has stopped running.
If the animation is stopped, this state is true within the current logic tick only and will be cleared at the next logic tick.
- Returns
- true if stopped.
The documentation for this interface was generated from the following file:
- murl_logic_i_scroll_processor.h