Louvre
v2.12.0-1
C++ library for Wayland compositors
|
Time-based animations. More...
Public Types | |
using | Callback = std::function< void(LAnimation *)> |
Public Member Functions | |
LAnimation (UInt32 durationMs=0, const Callback &onUpdate=nullptr, const Callback &onFinish=nullptr) noexcept | |
Creates a reusable animation. More... | |
~LAnimation () | |
Destructor for the LAnimation class. More... | |
void | setOnUpdateCallback (const Callback &onUpdate) noexcept |
Sets the onUpdate() callback handler function. More... | |
void | setOnFinishCallback (const Callback &onFinish) noexcept |
Sets the onFinish() callback handler function. More... | |
void | setDuration (UInt32 durationMs) noexcept |
Sets the duration of the animation in milliseconds. More... | |
UInt32 | duration () const noexcept |
Returns the duration of the animation in milliseconds. More... | |
Float64 | value () const noexcept |
Returns a number linearly interpolated from 0.0 to 1.0. More... | |
void | start () noexcept |
Starts the animation. More... | |
void | stop () |
Halts the animation before its duration is reached. More... | |
bool | running () const noexcept |
Checks if the animation is currently running. More... | |
Public Member Functions inherited from LObject | |
LObject (const LObject &) noexcept | |
Copy constructor. More... | |
LObject & | operator= (const LObject &) noexcept |
Assignment operator (each object has its own individual LWeak reference count). More... | |
void | setUserData (UIntPtr data) const noexcept |
Store an unsigned integer value/pointer. More... | |
UIntPtr | userData () const noexcept |
Retrieves the stored unsigned integer value/pointer. More... | |
Static Public Member Functions | |
static void | oneShot (UInt32 durationMs, const Callback &onUpdate=nullptr, const Callback &onFinish=nullptr) noexcept |
Creates and launches a one-time animation with automatic cleanup. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from LObject | |
LObject () noexcept=default | |
Constructor of the LObject class. More... | |
virtual | ~LObject () noexcept |
Destructor of the LObject class. More... | |
void | notifyDestruction () noexcept |
Notifies the object destruction. More... | |
Time-based animations.
This class can be used for animating object parameters such as positions, color, opacity, etc. It has a fixed duration in milliseconds, and is synchronized with each initialized output's render loop.
After started, the onUpdate()
callback is triggered before each LOutput::paintGL() call, allowing you to access the value() property, which is a 64-bit floating-point number linearly interpolated from 0.0 to 1.0, indicating the completion percentage of the animation.
onUpdate()
callback may not be invoked.After the animation finishes, the onFinish()
callback is triggered, and the value() property has a value of 1.0.
using Callback = std::function<void(LAnimation*)> |
Callback function type used to handle the onUpdate()
and onFinish()
events.
|
noexcept |
Creates a reusable animation.
Creates an animation without starting it immediately.
~LAnimation | ( | ) |
Destructor for the LAnimation class.
Destroys an animation object. If the animation is currently running at the time of destruction, the onFinish()
callback is invoked immediately before the object is destroyed.
|
staticnoexcept |
Creates and launches a one-time animation with automatic cleanup.
The oneShot() method creates and starts an animation immediately, and it is automatically destroyed once finished.
|
noexcept |
Sets the onUpdate()
callback handler function.
This method allows you to set the callback function that will be called when an update event occurs.
onUpdate | A reference to the callback function. Pass nullptr to disable the callback. |
|
noexcept |
Sets the onFinish()
callback handler function.
This method allows you to set the callback function that will be called when the animaion finishes or stop() is called.
onFinish | A reference to the callback function. Pass nullptr to disable the callback. |
|
inlinenoexcept |
Sets the duration of the animation in milliseconds.
Use this method to specify the duration of the animation in milliseconds.
durationMs | The duration of the animation in milliseconds. |
|
inlinenoexcept |
Returns the duration of the animation in milliseconds.
Use this method to retrieve the duration of the animation in milliseconds.
|
inlinenoexcept |
Returns a number linearly interpolated from 0.0 to 1.0.
This method returns a value indicating the percentage of completion of the animation. The value is linearly interpolated between 0.0 (start of the animation) and 1.0 (end of the animation).
|
noexcept |
Starts the animation.
If the animation is already running, calling this method a no-op.
void stop | ( | ) |
|
inlinenoexcept |
Checks if the animation is currently running.
true
if running, false
otherwise.