ScriptedDataConverters in C++ runtime. Adds a new DataType.any which allows a datavalue to be applied as long as the propertyKey type matches the datavalue's type.
Co-authored-by: Philip Chung <philterdesign@gmail.com>
* make file ref counted
* migrate File to refcnt
* add bindable artboard class to keep file reference
* feat(unity): support rcp file and BindableArtboard class (#10228)
* refactor(apple): use updated file bindable artboard apis (#10229)
* update command queue to support bindable artboards
* use bindable artboards on command queue
* self manage view model instances in js runtime
* change remaining viewModelInstanceRuntimes to rcp
* refactor(apple): update view model instances to use rcp (#10298)
* refactor(unity): support rcp ViewModelInstanceRuntime (#10309)
* rebase fix
* deprecate getArtboard in favor of getBindableArtboard
* fix merge
* remove unused lambda capture
* fix rive binding
* feat(Android): RCP File, VMI, and add bindable artboards (#10456)
* refactor: C++ refactors
- Import from long (incorrect) -> jlong
- Header clang-tidy fix
- Use reinterpret_cast instead of C-style cast
- Break out some variables instead of long one liners
- Use auto
- Remove unused env and thisObj
# Conflicts:
# packages/runtime_android/kotlin/src/main/cpp/src/helpers/general.cpp
* docs: Improve documentation on the File class
* feat: Support bindable artboard type and RCP VMIs
# Conflicts:
# packages/runtime_android/kotlin/src/androidTest/java/app/rive/runtime/kotlin/core/RiveDataBindingTest.kt
* feat: Support RCP files
* refactor: Change from +1/-1 ref to just release
* fix: Moved to the more appropriate null pointer for GetStringUTFChars
* replace unref with release
Co-authored-by: Adam <67035612+damzobridge@users.noreply.github.com>
Co-authored-by: David Skuza <david@rive.app>
Co-authored-by: Erik <erik@rive.app>
Co-authored-by: hernan <hernan@rive.app>
* fix(apple): do not use symbolic trait font copy on failure
* fix(apple): release ctfont copy
* refactor(apple): do not manually ref rcp'd font, remove cache
Co-authored-by: David Skuza <david@rive.app>
* fix(apple): remove #ifdef checks in public headers
Fixes an issue where framework consumers would also have to set
WITH_RIVE_TEXT or WITH_RIVE_AUDIO
* refactor(apple): remove #if(def) from public interfaces and no-op instead
* fix(apple): fix incorrect api usage
Co-authored-by: David Skuza <david@rive.app>
* refactor(ios): use active screen display link when available
* project(ios): run pr ios tests on xcode 15.4
* fix: conditionally build screen display link for non-visionos
Co-authored-by: David Skuza <david@rive.app>
## Changes
- Adds support for replacing view model instance properties with other view model instances
## Fixes
- Fixes an issue where nested view model instances and properties were getting incorrectly created and cached
Diffs=
909ae012c1 feat(ios): add data binding replace view model instance support (#9500)
Co-authored-by: David Skuza <david@rive.app>
Adds support for data binding to the iOS runtime.
## Changes
### RiveFile
Updated to match c++ runtime support for getting view models by index, name, and default for an artboard.
### RiveArtboard
Updated to match c++ runtime support for binding a view model instance.
### RiveStateMachine
Updated to match c++ runtime support for binding a view model instance. Additionally, this holds a strong reference to the view model instance that is currently bound (which aids in knowing which state machine should have its property listeners called after advance).
### RiveModel
Adds support for enabling / disabling autoBind functionality. This has to be done _after_ initialization, since Swift default arguments don't bridge to ObjC, and I didn't want to add n number of new initializers. When enabled, a callback will be called with the bound instance.
## New Types
Currently, type names are similar to those found within the c++ runtime. They're kind of ugly when it comes to ObjC, but the Swift names are cleaned up (e.g `RiveViewModelRuntime.Instance` instead of `RiveViewModelInstanceRuntime`).
### RiveDataBindingViewModel
The bridging type between the c++ runtime equivalent (`rive::ViewModelRuntime`) and ObjC.
### RiveDataBindingViewModelInstance
Swift: `RiveDataBindingViewModel.Instance`
The bridging type between the c++ runtime equivalent (`rive::ViewModelInstanceRuntime`) and ObjC.
### RiveDataBindingViewModelInstanceProperty
Swift: `RiveDataBindingViewModel.Instance.Property`
The superclass bridging type between the c++ runtime equivalent (`rive::ViewModelInstanceValueRuntime`) and ObjC.
### Subclasses
- Strings: `RiveDataBindingViewModelInstanceStringProperty`
- Swift: `RiveDataBindingViewModel.Instance.StringProperty`
- Numbers: `RiveDataBindingViewModelInstanceNumberProperty`
- Swift: `RiveDataBindingViewModel.Instance.NumberProperty`
- Boolean: `RiveDataBindingViewModelInstanceBooleanProperty`
- Swift: `RiveDataBindingViewModel.Instance.BooleanProperty`
- Color: `RiveDataBindingViewModelInstanceColorProperty`
- Swift: `RiveDataBindingViewModel.Instance.ColorProperty`
- Enum: `RiveDataBindingViewModelInstanceEnumProperty`
- Swift: `RiveDataBindingViewModel.Instance.EnumProperty`
- Trigger: `RiveDataBindingViewModelInstanceTriggerProperty`
- Swift: `RiveDataBindingViewModel.Instance.TriggerProperty`
### Observability
KVO has (temporarily) been disabled, "forcing" observability to be done through the explicit `addListener` and `removeListener` functions of each property type. `removeListener` exists on the superclass, however the matching `addListener` functions exist on each property type, primarily due to the fact that there is no "pretty" way of handing these functions as generics (where only the value type of the property differs for each callback) other than utilizing `id`. Listeners exist within the context of a property; however, an instance will use its (cached) properties to request that it calls its listeners.
## Details
### Caching properties
When a property getter is called on a view model instance, a cache is first checked for the property, otherwise a new one is returned and cached. This helps with ensuring we are using the same pointer under-the-hood. This isn't strictly necessary (per testing) but does allow for some niceties, such as not having to explicitly maintain a strong reference to a property if you want to just observe: `instance.triggerProperty(from: "...").addListener { ... }`.
Properties are cached for the first component when parsing the path for the property. In the instance that a path with > 1 component is provided to a property (e.g `instance.triggerProperty(from: 'nested/trigger")`, then the appropriate nested view models are created, and the property is associated with the correct view model (e.g above, the view model `nested will be cached, and the trigger property will be cached within that view model).
### Caching nested view models
Similar to caching properties, when a (nested) view model getter is called on a view model instance, a cache is first checked for the view model, otherwise a new one is returned and cached. This helps ensure that when (re)binding an instance to a (new) state machine or artboard, that all properties within that view model still have its listeners attached, regardless of how nested a path goes. This will likely help with implementing replacing instance functionality in v2.
## Testing
Unit tests have been added for data binding, attempting to capture high-level expectations rather than totally verifying the c++ runtime expectations. This includes things like: all getters returning object-or-nil, listeners being called with the correct values, autoBinding, property and view model caching, etc. The `.riv` file for unit tests is the same one that is used within the Example app.
## Example
A new `.riv` file has been added that shows basic usage of each property type (including observability). The same `.riv` file is used in the unit tests.
Diffs=
b2f1db73d7 feat(ios): add support for data binding (#9227)
Co-authored-by: David Skuza <david@rive.app>