|
JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins
« « « Anklang Documentation |
Models a 1-dimensional position that can be dragged around by the user, and which will then continue moving with a customisable physics behaviour when released. More...
#include "juce_AnimatedPosition.h"
Classes | |
| class | Listener |
| Implement this class if you need to receive callbacks when the value of an AnimatedPosition changes. More... | |
Public Member Functions | |
| void | setLimits (Range< double > newRange) noexcept |
| Sets a range within which the value will be constrained. | |
| void | beginDrag () |
| Called to indicate that the object is now being controlled by a mouse-drag or similar operation. | |
| void | drag (double deltaFromStartOfDrag) |
| Called during a mouse-drag operation, to indicate that the mouse has moved. | |
| void | endDrag () |
| Called after beginDrag() and drag() to indicate that the drag operation has now finished. | |
| void | nudge (double deltaFromCurrentPosition) |
| Called outside of a drag operation to cause a nudge in the specified direction. | |
| double | getPosition () const noexcept |
| Returns the current position. | |
| void | setPosition (double newPosition) |
| Explicitly sets the position and stops any further movement. | |
| void | addListener (Listener *listener) |
| Adds a listener to be called when the value changes. | |
| void | removeListener (Listener *listener) |
| Removes a previously-registered listener. | |
Public Attributes | |
| Behaviour | behaviour |
| The behaviour object. | |
Models a 1-dimensional position that can be dragged around by the user, and which will then continue moving with a customisable physics behaviour when released.
This is useful for things like scrollable views or objects that can be dragged and thrown around with the mouse/touch, and by writing your own behaviour class, you can customise the trajectory that it follows when released.
The class uses its own Timer to continuously change its value when a drag ends, and Listener objects can be registered to receive callbacks whenever the value changes.
The value is stored as a double, and can be used to represent whatever units you need.
The template parameter Behaviour must be a class that implements various methods to return the physics of the value's movement - you can use the classes provided for this in the AnimatedPositionBehaviours namespace, or write your own custom behaviour.
@tags{GUI}
Definition at line 53 of file juce_AnimatedPosition.h.
| juce::AnimatedPosition< Behaviour >::AnimatedPosition | ( | ) |
Definition at line 56 of file juce_AnimatedPosition.h.
| void juce::AnimatedPosition< Behaviour >::addListener | ( | Listener * | listener | ) |
Adds a listener to be called when the value changes.
Definition at line 142 of file juce_AnimatedPosition.h.
| void juce::AnimatedPosition< Behaviour >::beginDrag | ( | ) |
Called to indicate that the object is now being controlled by a mouse-drag or similar operation.
After calling this method, you should make calls to the drag() method each time the mouse drags the position around, and always be sure to finish with a call to endDrag() when the mouse is released, which allows the position to continue moving freely according to the specified behaviour.
Definition at line 77 of file juce_AnimatedPosition.h.
| void juce::AnimatedPosition< Behaviour >::drag | ( | double | deltaFromStartOfDrag | ) |
Called during a mouse-drag operation, to indicate that the mouse has moved.
The delta is the difference between the position when beginDrag() was called and the new position that's required.
Definition at line 88 of file juce_AnimatedPosition.h.
| void juce::AnimatedPosition< Behaviour >::endDrag | ( | ) |
Called after beginDrag() and drag() to indicate that the drag operation has now finished.
Definition at line 96 of file juce_AnimatedPosition.h.
|
noexcept |
Returns the current position.
Definition at line 112 of file juce_AnimatedPosition.h.
| void juce::AnimatedPosition< Behaviour >::nudge | ( | double | deltaFromCurrentPosition | ) |
Called outside of a drag operation to cause a nudge in the specified direction.
This is intended for use by e.g. mouse-wheel events.
Definition at line 104 of file juce_AnimatedPosition.h.
| void juce::AnimatedPosition< Behaviour >::removeListener | ( | Listener * | listener | ) |
Removes a previously-registered listener.
Definition at line 145 of file juce_AnimatedPosition.h.
|
noexcept |
Sets a range within which the value will be constrained.
Definition at line 63 of file juce_AnimatedPosition.h.
| void juce::AnimatedPosition< Behaviour >::setPosition | ( | double | newPosition | ) |
Explicitly sets the position and stops any further movement.
This will cause a synchronous call to any listeners if the position actually changes.
Definition at line 121 of file juce_AnimatedPosition.h.
| Behaviour juce::AnimatedPosition< Behaviour >::behaviour |
The behaviour object.
This is public to let you tweak any parameters that it provides.
Definition at line 151 of file juce_AnimatedPosition.h.