advanceAndApply.
Concepts
ViewModelRuntime— schema for a view model defined in the editor. Lives in theFile.ViewModelInstanceRuntime— typed wrapper around an instance of that schema. Exposes the property API (propertyNumber,propertyString, etc). You own it viarcp<>.ViewModelInstance— the underlying bindable instance.ArtboardandStateMachineInstancebind to this type. Get one from aViewModelInstanceRuntimewith.instance().ViewModelInstance*Runtime— typed handles for individual properties (…NumberRuntime,…StringRuntime, etc).
Creating an Instance
The simplest path is to ask the file for the artboard’s default view model, then create a default instance from it:Bind the same
ViewModelInstance to both the artboard and the state machine.
The artboard binding drives layout-affecting properties; the state-machine binding
drives state-machine transitions and listener conditions.Reading & Writing Properties
All accessors are path-based —/-separated for nested view models.
Nested View Models
Lists
ViewModelInstanceRuntimes — same property API as
above.
Image & Artboard Properties
Lifecycle
- A
ViewModelInstanceRuntimeis a thin wrapper over aViewModelInstance. Hold thercp<>for as long as anything binds to it. - Property handles (
ViewModelInstanceNumberRuntime*, etc) are owned by the parent instance. Cache the pointer — it stays valid for the instance’s lifetime. - After mutating properties, the next
sm->advanceAndApply(dt)propagates the changes through data binds and into rendering.
When Properties Don’t Exist
EverypropertyX(name) getter returns nullptr if the name doesn’t
resolve, so you can probe an instance safely: