49 void syncRefs(std::vector<ActiveCssAnimation> &anims,
50 const std::vector<AnimationRef> &refs,
79 std::unordered_map<std::string, AnimState> imperative;
81 std::vector<ActiveCssAnimation> css;
83 std::unordered_map<std::string, std::vector<ActiveCssAnimation>> parts;
86 void addImperative(
const std::string &name, std::shared_ptr<UIAnimation> anim)
88 ensureState().imperative[name] = {std::move(anim), 0.0f, 0.0f,
false,
false};
94 void play(
Layout &node,
const std::string &name,
bool reverse);
108 void addCss(
const std::string &name,
double startTime)
110 auto &css = ensureState().css;
116 a.startTime = startTime;
117 css.push_back(std::move(a));
120 void stopCss(
const std::string &name)
124 for (
auto &a : state_->css)
129 bool hasCss() const noexcept {
return state_ && !state_->css.empty(); }
131 void overlayCssComputed(ComputedStyle &out,
const Theme &theme)
const
133 if (state_ && !state_->css.empty())
157 for (
const auto &[n, v] : state_->parts)
170 for (
const auto &[n, s] : state_->imperative)
173 if (!state_->css.empty())
175 for (
const auto &[pn, v] : state_->parts)
188 for (
const auto &[n, s] : state_->imperative)
194 std::unique_ptr<State> state_;
199 state_ = std::make_unique<State>();
203 static_assert(
sizeof(
AnimationPlayer) ==
sizeof(
void *),
"AnimationPlayer must remain pointer-sized");
Low-level animation types: imperative tracks, CSS keyframes, and the per-instance active animation st...
Centralized standard library includes used throughout ZenitUI.
Small value types shared by the layout, rendering and input layers.
The Style / ComputedStyle pair and all style-related value types.
Global stylesheet storage and rule matching.
The base node type: tree, style, layout, input, scroll, render.
Definition Layout.hpp:154
Per-context stylesheet: rules, keyframes, and root style.
Definition Theme.hpp:164
Internal helpers; called from AnimationPlayer and from Layout::draw.
Definition AnimationPlayer.hpp:41
void overlayCssStyle(Style &out, const std::vector< ActiveCssAnimation > &anims, const Theme &theme)
Overlay active CSS keyframe frames onto a sparse Style.
void tickAbsolute(std::vector< ActiveCssAnimation > &anims, double now, const Theme &theme)
Update active CSS animations against absolute timestamp now.
void overlayCssComputed(ComputedStyle &out, const std::vector< ActiveCssAnimation > &anims, const Theme &theme)
Overlay active CSS keyframe frames onto a ComputedStyle.
void syncRefs(std::vector< ActiveCssAnimation > &anims, const std::vector< AnimationRef > &refs, double now)
Synchronize the active-animation list with a new set of references.
void tickIncremental(std::vector< ActiveCssAnimation > &anims, float dt, const Theme &theme)
Advance active CSS animations incrementally by dt seconds.
Playback state for one CSS animation on one node.
Definition AnimPrimitives.hpp:122
Definition AnimationPlayer.hpp:77
Per-node animation state and operations.
Definition AnimationPlayer.hpp:74
void syncCss(Layout &node)
Sync css with node.style_.targetStyle.animations.
bool hasActiveLocal() const
true if this node itself (not descendants) has any active animation.
Definition AnimationPlayer.hpp:166
bool hasActivePartAnims() const
true if any part is currently animating.
Definition AnimationPlayer.hpp:153
void applyCssToPart(Layout &node, const std::string &partName, Style &out)
Resolve and overlay CSS animations for pseudo-element partName.
bool tickImperative(Layout &node, float dt)
Advance imperative animations by dt seconds.
bool hasActive(const Layout &node) const
true if this node or any descendant has an active animation.
bool hasActiveImperative() const
true if any imperative animation is currently playing.
Definition AnimationPlayer.hpp:184
void tickCss(Layout &node, float dt)
Advance CSS animations by dt seconds.
void play(Layout &node, const std::string &name, bool reverse)
Start (or restart) the imperative animation named name.
Dense style: every property has a concrete value.
Definition Style.hpp:1036
Sparse style: every property is Opt<T>, unset by default.
Definition Style.hpp:932