Animation & Transitions Overview
ProGUI includes a built-in animation system designed to facilitate smooth visual changes and transitions for UI elements over time. This system allows developers to define animations on Windows or Widgets, control their duration and timing, and utilize various easing functions (transitions) to control the rate of change.
Key aspects of the animation system include:
- Animation Control: Functions like StartAnimation() and StopAnimation() allow precise control over starting and stopping animation loops associated with specific objects (Windows or Widgets) using unique IDs.
- Event-Driven Updates: When an animation is running, ProGUI dispatches
#PG_Event_Animate(or#PG_Event_AnimateSkinfor skin transitions) events to the target object. These events indicate the start, update, and end phases of the animation, providing the current elapsed time and delta time within the event data structure (PG_EventAnimate). - Timing Information: The AnimationGetCurrentTime() function allows querying the progress of a specific animation.
- Transition Functions (Easing): A comprehensive library of
Transition_*functions is provided to calculate intermediate values during an animation. These implement various easing curves (linear, ease-in, ease-out, ease-in-out, elastic, bounce, back, etc.) allowing for natural-looking acceleration and deceleration effects. These can be used within animation event handlers to smoothly interpolate property values (like position, size, color, opacity) between a start and end state based on the elapsed time. - Skin Integration: The animation system is used internally by the skinning engine to handle transitions defined in skin properties (e.g., `transition: background-color 0.5s ease-in;`).
- Performance: Animations are managed efficiently, often leveraging platform-specific mechanisms (like DirectComposition on Windows) and optimized rendering updates.
Developers typically use StartAnimation() to initiate a process that
requires updates over time (like a custom animation or a timed sequence) and then perform the necessary
calculations or state changes within an event handler attached to the #PG_Event_Animate
event, often utilizing the provided Transition_* functions.