-
- All Implemented Interfaces:
-
app.rive.runtime.kotlin.core.RefCount
public final class ViewModel extends NativeObject
A description of a ViewModel in the Rive file. It can be used to retrieve property definitions at runtime. However, properties cannot be modified - that requires an instance. Use one of the createInstance methods to create an instance with mutable properties from this ViewModel.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classViewModel.PropertyA description of a property in the ViewModel.
These can't be used to get or set the value of the property. For that, you will need a ViewModelInstance and use its methods.
public enumViewModel.PropertyDataType
-
Field Summary
Fields Modifier and Type Field Description private final Stringnameprivate final IntegerinstanceCountprivate final IntegerpropertyCountprivate final List<ViewModel.Property>propertiesprivate final BooleanhasCppObjectprivate AtomicIntegerrefsprivate LongcppPointerprivate final List<RefCount>dependenciesprivate final IntegerrefCount
-
Method Summary
Modifier and Type Method Description final StringgetName()final IntegergetInstanceCount()final IntegergetPropertyCount()final List<ViewModel.Property>getProperties()final BooleangetHasCppObject()final AtomicIntegergetRefs()final UnitsetRefs(AtomicInteger refs)final LonggetCppPointer()final UnitsetCppPointer(Long cppPointer)final List<RefCount>getDependencies()IntegergetRefCount()final ViewModelInstancecreateBlankInstance()Create a new blank ViewModelInstance. final ViewModelInstancecreateDefaultInstance()Create a new ViewModelInstance. final ViewModelInstancecreateInstanceFromIndex(Integer index)Create a new ViewModelInstance. final ViewModelInstancecreateInstanceFromName(String name)Create a new ViewModelInstance. -
-
Method Detail
-
getInstanceCount
final Integer getInstanceCount()
-
getPropertyCount
final Integer getPropertyCount()
-
getProperties
final List<ViewModel.Property> getProperties()
-
getHasCppObject
final Boolean getHasCppObject()
-
getRefs
final AtomicInteger getRefs()
-
setRefs
final Unit setRefs(AtomicInteger refs)
-
getCppPointer
final Long getCppPointer()
-
setCppPointer
final Unit setCppPointer(Long cppPointer)
-
getDependencies
final List<RefCount> getDependencies()
-
getRefCount
Integer getRefCount()
-
createBlankInstance
final ViewModelInstance createBlankInstance()
Create a new blank ViewModelInstance. Use Artboard::setViewModel to apply it. The instance name will be an empty string.
Property values will be defaulted:
Numbers will be 0
Strings will be empty
Booleans will be false
Colors will be ARGB(0xFF, 0, 0, 0)
Enums will be their first value
Useful when you want to supply all property values yourself.
-
createDefaultInstance
final ViewModelInstance createDefaultInstance()
Create a new ViewModelInstance. Use Artboard::setViewModel to apply it.
Property values will be those of the instance marked as "Default" in the Rive editor.
-
createInstanceFromIndex
final ViewModelInstance createInstanceFromIndex(Integer index)
Create a new ViewModelInstance. Use Artboard::setViewModel to apply it.
Useful when the Rive file has a set of default property values that you want to initialize with.
- Parameters:
index- Rive file 0-based index for this instance.
-
createInstanceFromName
final ViewModelInstance createInstanceFromName(String name)
Create a new ViewModelInstance. Use Artboard::setViewModel to apply it.
Useful when the Rive file has a set of default property values that you want to initialize with.
- Parameters:
name- Rive file name for this instance.
-
-
-
-