Expose state machine graph, entered state names, and timeline introspection - #8
Merged
Merged
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
…ection
Three read-only surfaces a host needs to let a .riv's state machine own
its sequencing while the host still measures and reacts to it — all
already present in the runtime and simply not surfaced.
RiveArtboard::stateMachineGraph(name) (+ RiveView passthrough) returns a
machine's static structure WITHOUT instantiating it: entry timeline,
every AnimationState's timeline name, and transitions resolved from
LayerState* to {from, to} name pairs (entry/exit/any/blend report "",
matching the stateChanged contract). A host can now derive a clip
sequence from the graph itself instead of duplicating it in code — so
adding or reordering states in the .riv needs no host change.
RiveStateMachine::stateChanged now carries the entered state's TIMELINE
name instead of an empty string. A LayerState has no name of its own —
StateMachineLayerComponent extends Core directly and the format has no
name property for it — but an AnimationState knows the LinearAnimation
it plays, and that name is what the editor shows on the state. States
with no single timeline (entry / exit / any / blend) stay unnamed rather
than inventing a label callers could come to depend on. The header's
contract is updated, including a note that the first argument has always
been the change index rather than a layer name: rive reports changes as
a flat list across layers with no way to ask which layer each came from.
This is also the host's transition-interception point: every handoff is
observable as a from -> to pair.
RiveStateMachine::currentStateTime / currentStateTimeline (read-only
Q_PROPERTYs, published per advance) expose the live playhead within the
state's active clip via currentAnimationByIndex(). Under a state machine
RiveView's currentFrame is 0 by design — a graph has no single
scrubbable timeline — but a host progress bar still needs to measure
playback, and these two give it position-within-state to combine with
the graph-derived ordering and per-clip durations.
RiveArtboard::animationDuration(name) / RiveView::animationDuration(name)
report a clip's length in seconds WITHOUT instantiating it for playback;
animationLoops(name) reports whether it repeats (loop or ping-pong),
which is how a host tells a graph spine's loop tail from a one-shot end.
Misses and empty names return 0 / false.
Tests: graph shape + endpoints cross-checked against animationNames with
miss/mint-after-read contracts; playhead populated after first advance
and bounded by the clip's real duration; loop flag cross-checked against
each clip's own setting; the state-machine spy asserts at least one
emission is named and every name matches an enumerated animation (the
regression guard for the empty-string behaviour); render smoke covers
the RiveView no-source contract. Full suite: 38/38.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jslauthor
force-pushed
the
feat/state-machine-graph-and-playhead
branch
from
July 29, 2026 23:39
9b4b714 to
e570d34
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three read-only surfaces a host needs to let a .riv's state machine own its sequencing while the host still measures and reacts to it — all already present in the runtime and simply not surfaced.
RiveArtboard::stateMachineGraph(name) (+ RiveView passthrough) returns a machine's static structure WITHOUT instantiating it: entry timeline, every AnimationState's timeline name, and transitions resolved from LayerState* to {from, to} name pairs (entry/exit/any/blend report "", matching the stateChanged contract). A host can now derive a clip sequence from the graph itself instead of duplicating it in code — so adding or reordering states in the .riv needs no host change.
RiveStateMachine::stateChanged now carries the entered state's TIMELINE name instead of an empty string. A LayerState has no name of its own — StateMachineLayerComponent extends Core directly and the format has no name property for it — but an AnimationState knows the LinearAnimation it plays, and that name is what the editor shows on the state. States with no single timeline (entry / exit / any / blend) stay unnamed rather than inventing a label callers could come to depend on. The header's contract is updated, including a note that the first argument has always been the change index rather than a layer name: rive reports changes as a flat list across layers with no way to ask which layer each came from. This is also the host's transition-interception point: every handoff is observable as a from -> to pair.
RiveStateMachine::currentStateTime / currentStateTimeline (read-only Q_PROPERTYs, published per advance) expose the live playhead within the state's active clip via currentAnimationByIndex(). Under a state machine RiveView's currentFrame is 0 by design — a graph has no single scrubbable timeline — but a host progress bar still needs to measure playback, and these two give it position-within-state to combine with the graph-derived ordering and per-clip durations.
RiveArtboard::animationDuration(name) / RiveView::animationDuration(name) report a clip's length in seconds WITHOUT instantiating it for playback; animationLoops(name) reports whether it repeats (loop or ping-pong), which is how a host tells a graph spine's loop tail from a one-shot end. Misses and empty names return 0 / false.
Tests: graph shape + endpoints cross-checked against animationNames with miss/mint-after-read contracts; playhead populated after first advance and bounded by the clip's real duration; loop flag cross-checked against each clip's own setting; the state-machine spy asserts at least one emission is named and every name matches an enumerated animation (the regression guard for the empty-string behaviour); render smoke covers the RiveView no-source contract. Full suite: 38/38.