ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
Animations, Transitions & Filters

Property transitions, @keyframes, imperative animations, and post-processing filters. More...

Namespaces

namespace  ZenitUI::Anim
 Internal helpers; called from AnimationPlayer and from Layout::draw.

Classes

struct  ZenitUI::AnimationPlayer
 Per-node animation state and operations. More...
class  ZenitUI::UIAnimation
 A time-parameterised sequence of per-property tracks. More...
struct  ZenitUI::AnimState
 Playback state for one UIAnimation on one node. More...
struct  ZenitUI::Keyframe
 One keyframe of a CSS animation: a normalized time and a sparse style delta. More...
struct  ZenitUI::KeyframeAnimation
 A named list of keyframes, keyed by name in Theme::keyframes. More...
struct  ZenitUI::ActiveCssAnimation
 Playback state for one CSS animation on one node. More...
struct  ZenitUI::FilterParam
 One uniform exposed by a filter shader. More...
struct  ZenitUI::FilterContext
 Per-invocation state passed to applyFilter and to custom filters. More...
struct  ZenitUI::FilterDef
 Complete description of one filter. More...
class  ZenitUI::FilterRegistry
 Per-context map from CSS filter name to FilterDef. More...

Typedefs

using ZenitUI::FilterCustomFn = std::function<void(const FilterContext &)>
 Callback signature for FilterPattern::Custom filters.

Enumerations

enum class  ZenitUI::TransitionFunction {
  Linear , EaseInQuad , EaseOutQuad , EaseInOutQuad ,
  EaseInCubic , EaseOutCubic , EaseInOutCubic , EaseInBack ,
  EaseOutBack , EaseOutElastic , EaseOutBounce
}
 Timing function applied between two keyframe values. More...
enum class  ZenitUI::FilterPattern { FilterPattern::SinglePass , FilterPattern::Separable , FilterPattern::Silhouette , FilterPattern::Custom }
 Execution pattern for a filter definition. More...
enum class  ZenitUI::FilterParamType {
  Float , Vec2 , Vec3 , Vec4 ,
  Color
}
 Type of a filter parameter.

Functions

float ZenitUI::sampleActive (const ActiveCssAnimation &a, bool &finished)
 Sample the given CSS animation's local time without touching the cache.
float ZenitUI::sampleActiveCached (const ActiveCssAnimation &a, bool &finished)
 Cached wrapper around sampleActive.
Style ZenitUI::evaluateKeyframes (const KeyframeAnimation &anim, float localT, TransitionFunction ease)
 Interpolate a KeyframeAnimation at local time localT.
float ZenitUI::getRatio (float t, TransitionFunction fn)
 Map a normalized time t in [0, 1] through the given easing.
bool ZenitUI::parseEasing (std::string_view name, TransitionFunction &out)
 Parse an easing name (CSS-like) into a TransitionFunction.
void ZenitUI::applyFilter (const FilterDef &def, const FilterContext &ctx)
 Execute one filter against the given context.

Detailed Description

Property transitions, @keyframes, imperative animations, and post-processing filters.

Key concepts:

  • Transitions: opt-in per node (transition-time: 0s by default); set transition or transition-time in .zstyle to smoothly interpolate across state changes and ::part styles.
  • Keyframe & imperative animations: declare @keyframes in .zstyle or register a multi-track UIAnimation via Layout::addAnimation / playAnimation with forward/reverse playback and onFinished chaining.
  • Filters & shaders: apply filter: blur(...), drop-shadow(...), or custom passes registered in UIContext::filters. Off-screen targets are automatically pooled by UIContext::targetPool and baked when static by LayerCache.

Live examples: 11_animations · 12_effects_canvas

Live examples
  • 00_demo — Flagship ZenitUI showcase: live Dark/Light theming, ZMarkup prefabs & keyed Each, Bindable<T>, UTF-8 TextArea, 10k-row VirtualView, portals, filters, and CanvasLayout.

Enumeration Type Documentation

◆ FilterPattern

enum class ZenitUI::FilterPattern
strong

Execution pattern for a filter definition.

Enumerator
SinglePass 

One shader, one draw.

Separable 

Two shader passes (H then V), using the scratch target.

Silhouette 

Offset silhouette draw + original draw, for drop-shadows.

Custom 

Invoke the custom callback directly.

◆ TransitionFunction

enum class ZenitUI::TransitionFunction
strong

Timing function applied between two keyframe values.

The set matches the subset of the CSS cubic-bezier() presets that ZenitUI supports out of the box. Custom cubic-bezier curves are not exposed; use the closest preset or a Custom filter for arbitrary motion.

Examples
11_animations/main.cpp.

Function Documentation

◆ applyFilter()

void ZenitUI::applyFilter ( const FilterDef & def,
const FilterContext & ctx )

Execute one filter against the given context.

Parameters
defFilter definition to execute.
ctxInvocation context providing renderer, targets, and UIContext.
Examples
08_virtual_list/main.cpp.

◆ evaluateKeyframes()

Style ZenitUI::evaluateKeyframes ( const KeyframeAnimation & anim,
float localT,
TransitionFunction ease )
inline

Interpolate a KeyframeAnimation at local time localT.

Finds the two keyframes bracketing localT, computes the local sub-progress, applies easing, then lerps every property present in both bracketing keyframes. Properties present in only one side are taken from that side directly.

◆ getRatio()

float ZenitUI::getRatio ( float t,
TransitionFunction fn )
inline

Map a normalized time t in [0, 1] through the given easing.

Parameters
tProgress, clamped to [0, 1] by the function.
fnEasing curve to apply.
Returns
Eased progress. May exceed [0, 1] for overshooting curves (EaseInBack, EaseOutBack, EaseOutElastic, EaseOutBounce).

◆ parseEasing()

bool ZenitUI::parseEasing ( std::string_view name,
TransitionFunction & out )
inline

Parse an easing name (CSS-like) into a TransitionFunction.

Case-insensitive; separators -, _ and space are ignored, so "ease-in-out-quad", "EaseInOutQuad" and "ease in out quad" all parse to TransitionFunction::EaseInOutQuad.

Parameters
nameInput string view.
[out]outSet on success.
Returns
true if the name matched a known curve.
Examples
11_animations/main.cpp.

◆ sampleActive()

float ZenitUI::sampleActive ( const ActiveCssAnimation & a,
bool & finished )
inline

Sample the given CSS animation's local time without touching the cache.

Combines elapsed, delay, duration, iterations, alternate into a normalized [0, 1] progress value. Also reports whether this is the final frame of the animation via finished.

Parameters
aActive animation.
[out]finishedSet to true on the last sample.
Returns
Local time in [0, 1].