diff --git a/.gitignore b/.gitignore index 2491f4c6..19b56216 100644 --- a/.gitignore +++ b/.gitignore @@ -90,3 +90,19 @@ shared_lib/dependencies shared_lib/bin *.make Makefile + +# https://dart.dev/guides/libraries/private-files + +.dart_tool/ +build/ + +doc/api/ + +# IntelliJ +*.iml +*.ipr +*.iws +.idea/ + +# Mac +.DS_Store \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index 63fe01d8..05150c1e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,6 +1,7 @@ analyzer: errors: unused_import: error + prefer_is_empty: ignore exclude: - ios - macos @@ -51,7 +52,8 @@ linter: - join_return_with_assignment - library_names - library_prefixes - - lines_longer_than_80_chars + # STOKANAL-FORK-EDIT +# - lines_longer_than_80_chars # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 - no_adjacent_strings_in_list - no_duplicate_case_values @@ -76,7 +78,7 @@ linter: - prefer_contains - prefer_final_fields - prefer_final_in_for_each - - prefer_foreach +# - prefer_foreach - prefer_function_declarations_over_variables - prefer_initializing_formals - prefer_is_empty diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 00000000..fa0b357c --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/example/devtools_options.yaml b/example/devtools_options.yaml new file mode 100644 index 00000000..fa0b357c --- /dev/null +++ b/example/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 00000000..2735b12c --- /dev/null +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,36 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import audio_session +import connectivity_plus +import device_info_plus +import flutter_udid +import in_app_purchase_storekit +import in_app_review +import just_audio +import package_info_plus +import path_provider_foundation +import rive_common +import shared_preferences_foundation +import url_launcher_macos +import wakelock_plus + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) + ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) + DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) + FlutterUdidPlugin.register(with: registry.registrar(forPlugin: "FlutterUdidPlugin")) + InAppPurchasePlugin.register(with: registry.registrar(forPlugin: "InAppPurchasePlugin")) + InAppReviewPlugin.register(with: registry.registrar(forPlugin: "InAppReviewPlugin")) + JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) +} diff --git a/example/windows/flutter/generated_plugin_registrant.cc b/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..19277733 --- /dev/null +++ b/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,23 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + ConnectivityPlusWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + FlutterUdidPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterUdidPluginCApi")); + RivePluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("RivePlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); +} diff --git a/example/windows/flutter/generated_plugin_registrant.h b/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..dc139d85 --- /dev/null +++ b/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 00000000..305dfbd6 --- /dev/null +++ b/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,27 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + connectivity_plus + flutter_udid + rive_common + url_launcher_windows +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/lib/src/controllers/linear_animation_controller.dart b/lib/src/controllers/linear_animation_controller.dart index f4c5f99b..d35095f4 100644 --- a/lib/src/controllers/linear_animation_controller.dart +++ b/lib/src/controllers/linear_animation_controller.dart @@ -1,9 +1,11 @@ import 'package:rive/src/core/core.dart'; +import 'package:rive/src/generated/rive_core_beans.dart'; import 'package:rive/src/rive_core/animation/keyed_object.dart'; import 'package:rive/src/rive_core/animation/linear_animation_instance.dart' as core; import 'package:rive/src/rive_core/event.dart'; import 'package:rive/src/runtime_mounted_artboard.dart'; + export 'package:rive/src/runtime_mounted_artboard.dart'; /// An AnimationController which controls a StateMachine and provides access to @@ -27,9 +29,12 @@ class LinearAnimationInstance extends core.LinearAnimationInstance @override void reportEvent(Event event) { - _runtimeEventListeners.toList().forEach((callback) { - callback(event); - }); + for (final t in _runtimeEventListeners) { + t(event); + } + // _runtimeEventListeners.toList().forEach((callback) { + // callback(event); + // }); } @override @@ -37,9 +42,8 @@ class LinearAnimationInstance extends core.LinearAnimationInstance int objectId, int propertyKey, double elapsedSeconds) { var coreObject = context?.resolve(objectId); if (coreObject != null) { - RiveCoreContext.setCallback( + PropertyBeans.get(propertyKey).setCallback( coreObject, - propertyKey, CallbackData(this, delay: elapsedSeconds), ); } diff --git a/lib/src/controllers/state_machine_controller.dart b/lib/src/controllers/state_machine_controller.dart index 1448515b..d8f1e69a 100644 --- a/lib/src/controllers/state_machine_controller.dart +++ b/lib/src/controllers/state_machine_controller.dart @@ -7,6 +7,7 @@ import 'package:rive/src/rive_core/animation/state_machine_trigger.dart'; import 'package:rive/src/rive_core/artboard.dart'; import 'package:rive/src/rive_core/state_machine_controller.dart' as core; import 'package:rive/src/runtime_mounted_artboard.dart'; + export 'package:rive/src/runtime_mounted_artboard.dart'; /// [StateMachine]s supports three input types. The StateMachine mostly @@ -114,10 +115,13 @@ class SMITrigger extends SMIInput { /// the inputs of the StateMachine. class StateMachineController extends core.StateMachineController with RuntimeEventReporter { - final List _inputs = []; /// A list of inputs available in the StateMachine. - Iterable get inputs => _inputs; + @nonVirtual + final List inputs = []; + + // /// A list of inputs available in the StateMachine. + // Iterable get inputs => _inputs; final _runtimeEventListeners = {}; @@ -130,13 +134,13 @@ class StateMachineController extends core.StateMachineController for (final input in stateMachine.inputs) { switch (input.coreType) { case StateMachineNumberBase.typeKey: - _inputs.add(SMINumber._(input as StateMachineNumber, this)); + inputs.add(SMINumber._(input as StateMachineNumber, this)); break; case StateMachineBoolBase.typeKey: - _inputs.add(SMIBool._(input as StateMachineBool, this)); + inputs.add(SMIBool._(input as StateMachineBool, this)); break; case StateMachineTriggerBase.typeKey: - _inputs.add(SMITrigger._(input as StateMachineTrigger, this)); + inputs.add(SMITrigger._(input as StateMachineTrigger, this)); break; } } @@ -168,7 +172,7 @@ class StateMachineController extends core.StateMachineController /// For easier to use methods, see [getBoolInput], [getTriggerInput], /// [getNumberInput]. SMIInput? findInput(String name) { - for (final input in _inputs) { + for (final input in inputs) { if (input._is() && input.name == name) { return input as SMIInput; } @@ -181,7 +185,7 @@ class StateMachineController extends core.StateMachineController /// For easier to use methods, see [getBoolInput], [getTriggerInput], /// [getNumberInput]. T? findSMI(String name) { - for (final input in _inputs) { + for (final input in inputs) { if (input is T && input.name == name) { return input as T; } @@ -209,8 +213,11 @@ class StateMachineController extends core.StateMachineController @override void advanceInputs() { - for (final input in _inputs) { - input.advance(); + final t = inputs.length; + for (var i = 0; i < t; i++) { + // for (final input in _inputs) { + inputs[i].advance(); + // input.advance(); } } @@ -224,8 +231,16 @@ class StateMachineController extends core.StateMachineController @override void applyEvents() { - var events = reportedEvents.toList(growable: false); super.applyEvents(); - _runtimeEventListeners.toList().forEach(events.forEach); + + for (final event in _runtimeEventListeners) { + // reportedEvents.forEach(event); + + var list = reportedEvents; + var t = list.length; + for (var i = 0; i < t; i++) { + event(list[i]); + } + } } } diff --git a/lib/src/core/core.dart b/lib/src/core/core.dart index 1f0b8495..0da79316 100644 --- a/lib/src/core/core.dart +++ b/lib/src/core/core.dart @@ -1,9 +1,6 @@ -import 'dart:collection'; - import 'package:flutter/foundation.dart'; import 'package:rive/src/rive_core/runtime/exceptions/rive_format_error_exception.dart'; - -export 'dart:typed_data'; +import 'package:stokanal/core.dart'; export 'package:flutter/foundation.dart'; export 'package:rive/src/animation_list.dart'; @@ -39,21 +36,82 @@ export 'package:rive/src/viewmodel_properties.dart'; typedef PropertyChangeCallback = void Function(dynamic from, dynamic to); typedef BatchAddCallback = void Function(); +const _coreTypes = {}; + +const _highInt = 0xFFFFFFFF00000000; +const _lowInt = 0xFFFFFFFF; +const _negative = 0x80000000; +const _module = 0x7FFFFFFF; + +int _to(int s) { + // // TODO comment me + // if (s > _module || s < -_module) { + // throw Exception('_to=$s'); + // } + + if (s < 0) { + return _negative + (-s); + } else { + return s; + } +} + +int _from(int s) => (s & _negative > 0 ? -1 : 1) * (s & _module); +int _setLow(final int v, final int s) => (v & _highInt) + _to(s); + +// int _getLow(int v) => _from(v & _lowInt); +// int _setHigh(final int v, final int s) { +// var r = (_to(s) << 32) + (v & _lowInt); +// // // TODO comment me +// // if (_getHigh(r) != s) { +// // throw Exception('v=${v.toRadixString(2)} s=${s.toRadixString(2)} r=${r.toRadixString(2)} high=${_getHigh(r).toRadixString(2)}'); +// // } +// return r; +// } +// int _getHigh(int v) => _from((v & _highInt) >> 32); + abstract class Core { static const int missingId = -1; covariant late T context; int get coreType; - int id = missingId; - Set get coreTypes => {}; - bool _hasValidated = false; - bool get hasValidated => _hasValidated; + + @mustCallSuper + void onRemoved() {} + + // int id = missingId; + + int _value = _setLow(0, missingId); + // @nonVirtual + // int get id => _getLow(_value); + // @nonVirtual + // set id(int id) => _value = _setLow(_value, id); + // @nonVirtual + // int get high => _getHigh(_value); + // @nonVirtual + // set high(int high) => _value = _setHigh(_value, high); + @nonVirtual + int get id => _from(_value & _lowInt); + @nonVirtual + set id(int id) => _value = (_value & _highInt) + _to(id); + @nonVirtual + int get high => _from((_value & _highInt) >> 32); + @nonVirtual + set high(int high) => _value = (_to(high) << 32) + (_value & _lowInt); + + + // TODO override this method with a static field, see KeyFrameDoubleBase as example + Set get coreTypes => _coreTypes;//{}; + + @nonVirtual + bool hasValidated = false; + // bool get hasValidated => _hasValidated; void onAddedDirty(); void onAdded() {} - void onRemoved() {} - void remove() => context.removeObject(this); bool import(ImportStack stack) => true; + void remove() => context.removeObject(this); + bool validate() => true; /// Make a duplicate of this core object, N.B. that all properties excluding @@ -72,9 +130,8 @@ abstract class Core { // ignore: avoid_classes_with_only_static_members class InternalCoreHelper { - static void markValid(Core object) { - object._hasValidated = true; - } + static void markValid(Core object) => + object.hasValidated = true; } abstract class CoreContext { @@ -93,7 +150,7 @@ abstract class CoreContext { // ignore: one_member_abstracts abstract class ImportStackObject { - final _resolveBefore = {}; + final _resolveBefore = UniqueList.of(); bool _resolved = false; bool initStack(ImportStack stack) { @@ -116,11 +173,9 @@ abstract class ImportStackObject { return true; } _resolved = true; - if (_resolveBefore.isNotEmpty) { - for (final before in _resolveBefore) { - if (!before._internalResolve()) { - return false; - } + for (final before in _resolveBefore) { + if (!before._internalResolve()) { + return false; } } return resolve(); @@ -132,7 +187,7 @@ abstract class ImportStackObject { /// Stack to help the RiveFile locate latest ImportStackObject created of a /// certain type. class ImportStack { - final _latests = HashMap(); + final _latests = {}; T? latest(int coreType) { var latest = _latests[coreType]; if (latest is T) { diff --git a/lib/src/core/core_meta.dart b/lib/src/core/core_meta.dart new file mode 100644 index 00000000..3350f6b6 --- /dev/null +++ b/lib/src/core/core_meta.dart @@ -0,0 +1,38 @@ +// import 'package:rive/src/generated/animation/keyframe_base.dart'; +// +// import '../rive_core/container_component.dart'; +// +// final _map = {}; +// +// abstract class CoreMetas { +// static final CoreMeta frameInitialValue = CoreMeta._(frame: KeyFrameBase.frameInitialValue); +// } +// +// @immutable +// class CoreMeta extends Object { +// +// final int frame; +// +// @override +// final int hashCode; +// +// CoreMeta._({required this.frame}): +// hashCode = frame { +// _map[this] = this; +// if (_map.length % 100 == 0) { +// print('MAP LENGTH > ${_map.length} > $frame >> $hashCode'); +// } +// } +// +// @override +// bool operator ==(Object other) => other is CoreMeta && +// other.frame == frame; +// +// CoreMeta _copy({ +// int? frame, +// }) => CoreMeta._( +// frame: frame??this.frame, +// ); +// +// CoreMeta setFrame(int frame) => _map[_copy(frame: frame)]!; +// } \ No newline at end of file diff --git a/lib/src/core/field_types/core_field_type.dart b/lib/src/core/field_types/core_field_type.dart index 0caf2741..f966d6c5 100644 --- a/lib/src/core/field_types/core_field_type.dart +++ b/lib/src/core/field_types/core_field_type.dart @@ -4,4 +4,6 @@ import 'package:rive_common/utilities.dart'; abstract class CoreFieldType { T deserialize(BinaryReader reader); void skip(BinaryReader reader) => deserialize(reader); + + // const CoreFieldType(); } diff --git a/lib/src/core/importers/artboard_importer.dart b/lib/src/core/importers/artboard_importer.dart index 25d5de64..dd6df72f 100644 --- a/lib/src/core/importers/artboard_importer.dart +++ b/lib/src/core/importers/artboard_importer.dart @@ -31,7 +31,7 @@ class ArtboardImporter extends ImportStackObject { } assert(!artboard.children.contains(artboard), 'artboard should never contain itself as a child'); - for (final object in artboard.objects.toList(growable: false)) { + for (final object in artboard.objects) {//.toList(growable: false)) { if (object == null) { continue; } diff --git a/lib/src/core/importers/backboard_importer.dart b/lib/src/core/importers/backboard_importer.dart index f8eb0907..9ddc2146 100644 --- a/lib/src/core/importers/backboard_importer.dart +++ b/lib/src/core/importers/backboard_importer.dart @@ -11,9 +11,9 @@ class BackboardImporter extends ImportStackObject { final Backboard backboard; final HashMap artboardLookup; - final Set nestedArtboards = {}; + final nestedArtboards = {}; final List fileAssets = []; - final Set fileAssetReferencers = {}; + final fileAssetReferencers = {}; BackboardImporter(this.artboardLookup, this.backboard); void addArtboard(Artboard object) {} diff --git a/lib/src/generated/animation/cubic_ease_interpolator_base.dart b/lib/src/generated/animation/cubic_ease_interpolator_base.dart index 006833ce..a74463e3 100644 --- a/lib/src/generated/animation/cubic_ease_interpolator_base.dart +++ b/lib/src/generated/animation/cubic_ease_interpolator_base.dart @@ -5,14 +5,16 @@ import 'package:rive/src/generated/animation/keyframe_interpolator_base.dart'; import 'package:rive/src/rive_core/animation/cubic_interpolator.dart'; +const _coreTypes = { + CubicEaseInterpolatorBase.typeKey, + CubicInterpolatorBase.typeKey, + KeyFrameInterpolatorBase.typeKey +}; + abstract class CubicEaseInterpolatorBase extends CubicInterpolator { static const int typeKey = 28; @override int get coreType => CubicEaseInterpolatorBase.typeKey; @override - Set get coreTypes => { - CubicEaseInterpolatorBase.typeKey, - CubicInterpolatorBase.typeKey, - KeyFrameInterpolatorBase.typeKey - }; + Set get coreTypes => _coreTypes; } diff --git a/lib/src/generated/animation/cubic_value_interpolator_base.dart b/lib/src/generated/animation/cubic_value_interpolator_base.dart index 21595ea0..3c009ac7 100644 --- a/lib/src/generated/animation/cubic_value_interpolator_base.dart +++ b/lib/src/generated/animation/cubic_value_interpolator_base.dart @@ -5,14 +5,16 @@ import 'package:rive/src/generated/animation/keyframe_interpolator_base.dart'; import 'package:rive/src/rive_core/animation/cubic_interpolator.dart'; +const _coreTypes = { + CubicValueInterpolatorBase.typeKey, + CubicInterpolatorBase.typeKey, + KeyFrameInterpolatorBase.typeKey +}; + abstract class CubicValueInterpolatorBase extends CubicInterpolator { static const int typeKey = 138; @override int get coreType => CubicValueInterpolatorBase.typeKey; @override - Set get coreTypes => { - CubicValueInterpolatorBase.typeKey, - CubicInterpolatorBase.typeKey, - KeyFrameInterpolatorBase.typeKey - }; + Set get coreTypes => _coreTypes; } diff --git a/lib/src/generated/animation/interpolating_keyframe_base.dart b/lib/src/generated/animation/interpolating_keyframe_base.dart index 59f761e8..bae5c27f 100644 --- a/lib/src/generated/animation/interpolating_keyframe_base.dart +++ b/lib/src/generated/animation/interpolating_keyframe_base.dart @@ -5,61 +5,44 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/animation/keyframe.dart'; +const _coreTypes = {InterpolatingKeyFrameBase.typeKey, KeyFrameBase.typeKey}; + abstract class InterpolatingKeyFrameBase extends KeyFrame { static const int typeKey = 170; @override int get coreType => InterpolatingKeyFrameBase.typeKey; @override - Set get coreTypes => - {InterpolatingKeyFrameBase.typeKey, KeyFrameBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// InterpolationType field with key 68. static const int interpolationTypePropertyKey = 68; static const int interpolationTypeInitialValue = 0; - int _interpolationType = interpolationTypeInitialValue; /// The type of interpolation index in KeyframeInterpolation applied to this /// keyframe. - int get interpolationType => _interpolationType; - - /// Change the [_interpolationType] field value. - /// [interpolationTypeChanged] will be invoked only if the field's value has - /// changed. - set interpolationType(int value) { - if (_interpolationType == value) { - return; - } - int from = _interpolationType; - _interpolationType = value; - if (hasValidated) { - interpolationTypeChanged(from, value); - } - } - - void interpolationTypeChanged(int from, int to); + @nonVirtual + int interpolationType = interpolationTypeInitialValue; /// -------------------------------------------------------------------------- /// InterpolatorId field with key 69. static const int interpolatorIdPropertyKey = 69; static const int interpolatorIdInitialValue = -1; - int _interpolatorId = interpolatorIdInitialValue; - /// The id of the custom interpolator used when interpolation is Cubic. - int get interpolatorId => _interpolatorId; + int get interpolatorId; /// Change the [_interpolatorId] field value. /// [interpolatorIdChanged] will be invoked only if the field's value has /// changed. + @nonVirtual set interpolatorId(int value) { - if (_interpolatorId == value) { + // int from = _interpolatorId; + int from = interpolatorId; + if (from == value) { return; } - int from = _interpolatorId; - _interpolatorId = value; - if (hasValidated) { - interpolatorIdChanged(from, value); - } + // _interpolatorId = value; + interpolatorIdChanged(from, value); } void interpolatorIdChanged(int from, int to); @@ -68,8 +51,8 @@ abstract class InterpolatingKeyFrameBase extends KeyFrame { void copy(Core source) { super.copy(source); if (source is InterpolatingKeyFrameBase) { - _interpolationType = source._interpolationType; - _interpolatorId = source._interpolatorId; + interpolationType = source.interpolationType; + // _interpolatorId = source._interpolatorId; } } } diff --git a/lib/src/generated/animation/keyed_object_base.dart b/lib/src/generated/animation/keyed_object_base.dart index 5c1e6498..f9e6c92d 100644 --- a/lib/src/generated/animation/keyed_object_base.dart +++ b/lib/src/generated/animation/keyed_object_base.dart @@ -4,42 +4,54 @@ import 'package:rive/src/core/core.dart'; +const _coreTypes = {KeyedObjectBase.typeKey}; + abstract class KeyedObjectBase extends Core { static const int typeKey = 25; + @override int get coreType => KeyedObjectBase.typeKey; @override - Set get coreTypes => {KeyedObjectBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// ObjectId field with key 51. static const int objectIdPropertyKey = 51; static const int objectIdInitialValue = 0; - int _objectId = objectIdInitialValue; /// Identifier used to track the object that is keyed. - int get objectId => _objectId; + // @nonVirtual + // int objectId = objectIdInitialValue; - /// Change the [_objectId] field value. - /// [objectIdChanged] will be invoked only if the field's value has changed. - set objectId(int value) { - if (_objectId == value) { - return; - } - int from = _objectId; - _objectId = value; - if (hasValidated) { - objectIdChanged(from, value); - } - } + @nonVirtual + int get objectId => high; + @nonVirtual + set objectId(int frame) => high = frame; + + + // /// Identifier used to track the object that is keyed. + // int get objectId => _objectId; + // + // /// Change the [_objectId] field value. + // /// [objectIdChanged] will be invoked only if the field's value has changed. + // set objectId(int value) { + // if (_objectId == value) { + // return; + // } + // int from = _objectId; + // _objectId = value; + // if (hasValidated) { + // objectIdChanged(from, value); + // } + // } - void objectIdChanged(int from, int to); + // void objectIdChanged(int from, int to); @override void copy(Core source) { super.copy(source); if (source is KeyedObjectBase) { - _objectId = source._objectId; + objectId = source.objectId; } } } diff --git a/lib/src/generated/animation/keyed_property_base.dart b/lib/src/generated/animation/keyed_property_base.dart index 515dcf97..6f6cdebb 100644 --- a/lib/src/generated/animation/keyed_property_base.dart +++ b/lib/src/generated/animation/keyed_property_base.dart @@ -4,43 +4,57 @@ import 'package:rive/src/core/core.dart'; +import '../rive_core_beans.dart'; + +const _coreTypes = {KeyedPropertyBase.typeKey}; + abstract class KeyedPropertyBase extends Core { static const int typeKey = 26; @override int get coreType => KeyedPropertyBase.typeKey; @override - Set get coreTypes => {KeyedPropertyBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// PropertyKey field with key 53. static const int propertyKeyPropertyKey = 53; - static const int propertyKeyInitialValue = CoreContext.invalidPropertyKey; - int _propertyKey = propertyKeyInitialValue; + // static const int propertyKeyInitialValue = CoreContext.invalidPropertyKey; + + /// STOKANAL-FORK-EDIT: exposing + // int propertyKey_ = CoreContext.invalidPropertyKey; + PropertyBean propertyBean = PropertyBeans.invalid; /// The property type that is keyed. - int get propertyKey => _propertyKey; + // int get propertyKey => propertyKey_; + int get propertyKey => propertyBean.propertyKey; - /// Change the [_propertyKey] field value. + /// Change the [propertyKey_] field value. /// [propertyKeyChanged] will be invoked only if the field's value has /// changed. + @nonVirtual set propertyKey(int value) { - if (_propertyKey == value) { + if (propertyKey == value) { return; } - int from = _propertyKey; - _propertyKey = value; - if (hasValidated) { - propertyKeyChanged(from, value); - } + + // int from = propertyKey_; + + // propertyKey_ = value; + propertyBean = PropertyBeans.get(value); + + // if (hasValidated) { + // propertyKeyChanged(from, value); + // } } - void propertyKeyChanged(int from, int to); + // void propertyKeyChanged(int from, int to); @override void copy(Core source) { super.copy(source); if (source is KeyedPropertyBase) { - _propertyKey = source._propertyKey; + // propertyKey_ = source.propertyKey_; + propertyBean = source.propertyBean; } } } diff --git a/lib/src/generated/animation/keyframe_base.dart b/lib/src/generated/animation/keyframe_base.dart index 295a1e61..52532b47 100644 --- a/lib/src/generated/animation/keyframe_base.dart +++ b/lib/src/generated/animation/keyframe_base.dart @@ -3,43 +3,34 @@ import 'package:rive/src/core/core.dart'; +const _coreTypes = {KeyFrameBase.typeKey}; + abstract class KeyFrameBase extends Core { static const int typeKey = 29; @override int get coreType => KeyFrameBase.typeKey; @override - Set get coreTypes => {KeyFrameBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Frame field with key 67. static const int framePropertyKey = 67; static const int frameInitialValue = 0; - int _frame = frameInitialValue; - - /// Timecode as frame number can be converted to time by dividing by animation - /// fps. - int get frame => _frame; - /// Change the [_frame] field value. - /// [frameChanged] will be invoked only if the field's value has changed. - set frame(int value) { - if (_frame == value) { - return; - } - int from = _frame; - _frame = value; - if (hasValidated) { - frameChanged(from, value); - } - } + /// Timecode as frame number can be converted to time by dividing by animation fps + // @nonVirtual + // int frame = frameInitialValue; - void frameChanged(int from, int to); + @nonVirtual + int get frame => high; + @nonVirtual + set frame(int frame) => high = frame; @override void copy(Core source) { super.copy(source); if (source is KeyFrameBase) { - _frame = source._frame; + frame = source.frame; } } } diff --git a/lib/src/generated/animation/keyframe_double_base.dart b/lib/src/generated/animation/keyframe_double_base.dart index 6f2eb19e..b66b21a4 100644 --- a/lib/src/generated/animation/keyframe_double_base.dart +++ b/lib/src/generated/animation/keyframe_double_base.dart @@ -6,44 +6,33 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_base.dart'; import 'package:rive/src/rive_core/animation/interpolating_keyframe.dart'; +const _coreTypes = { + KeyFrameDoubleBase.typeKey, + InterpolatingKeyFrameBase.typeKey, + KeyFrameBase.typeKey +}; + abstract class KeyFrameDoubleBase extends InterpolatingKeyFrame { static const int typeKey = 30; @override int get coreType => KeyFrameDoubleBase.typeKey; @override - Set get coreTypes => { - KeyFrameDoubleBase.typeKey, - InterpolatingKeyFrameBase.typeKey, - KeyFrameBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Value field with key 70. static const int valuePropertyKey = 70; static const double valueInitialValue = 0; - double _value = valueInitialValue; - double get value => _value; - - /// Change the [_value] field value. - /// [valueChanged] will be invoked only if the field's value has changed. - set value(double value) { - if (_value == value) { - return; - } - double from = _value; - _value = value; - if (hasValidated) { - valueChanged(from, value); - } - } - void valueChanged(double from, double to); + /// STOKANAL-FORK-EDIT: exposing + @nonVirtual + double value = valueInitialValue; @override void copy(Core source) { super.copy(source); if (source is KeyFrameDoubleBase) { - _value = source._value; + value = source.value; } } } diff --git a/lib/src/generated/animation/keyframe_id_base.dart b/lib/src/generated/animation/keyframe_id_base.dart index 07377b70..4b39349e 100644 --- a/lib/src/generated/animation/keyframe_id_base.dart +++ b/lib/src/generated/animation/keyframe_id_base.dart @@ -6,16 +6,18 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_base.dart'; import 'package:rive/src/rive_core/animation/interpolating_keyframe.dart'; +const _coreTypes = { + KeyFrameIdBase.typeKey, + InterpolatingKeyFrameBase.typeKey, + KeyFrameBase.typeKey +}; + abstract class KeyFrameIdBase extends InterpolatingKeyFrame { static const int typeKey = 50; @override int get coreType => KeyFrameIdBase.typeKey; @override - Set get coreTypes => { - KeyFrameIdBase.typeKey, - InterpolatingKeyFrameBase.typeKey, - KeyFrameBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Value field with key 122. diff --git a/lib/src/generated/animation/layer_state_base.dart b/lib/src/generated/animation/layer_state_base.dart index 89b109b9..e7075c3b 100644 --- a/lib/src/generated/animation/layer_state_base.dart +++ b/lib/src/generated/animation/layer_state_base.dart @@ -17,29 +17,33 @@ abstract class LayerStateBase extends StateMachineLayerComponent { /// Flags field with key 536. static const int flagsPropertyKey = 536; static const int flagsInitialValue = 0; - int _flags = flagsInitialValue; - int get flags => _flags; - /// Change the [_flags] field value. - /// [flagsChanged] will be invoked only if the field's value has changed. - set flags(int value) { - if (_flags == value) { - return; - } - int from = _flags; - _flags = value; - if (hasValidated) { - flagsChanged(from, value); - } - } + int flags = flagsInitialValue; - void flagsChanged(int from, int to); + // int _flags = flagsInitialValue; + // int get flags => _flags; + // + // /// Change the [_flags] field value. + // /// [flagsChanged] will be invoked only if the field's value has changed. + // set flags(int value) { + // if (_flags == value) { + // return; + // } + // int from = _flags; + // _flags = value; + // if (hasValidated) { + // flagsChanged(from, value); + // } + // } + // + // void flagsChanged(int from, int to); @override void copy(Core source) { super.copy(source); if (source is LayerStateBase) { - _flags = source._flags; + // _flags = source._flags; + flags = source.flags; } } } diff --git a/lib/src/generated/animation/state_transition_base.dart b/lib/src/generated/animation/state_transition_base.dart index c34d9367..0a3eb163 100644 --- a/lib/src/generated/animation/state_transition_base.dart +++ b/lib/src/generated/animation/state_transition_base.dart @@ -5,13 +5,14 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/animation/state_machine_layer_component.dart'; +const _coreTypes = {StateTransitionBase.typeKey, StateMachineLayerComponentBase.typeKey}; + abstract class StateTransitionBase extends StateMachineLayerComponent { static const int typeKey = 65; @override int get coreType => StateTransitionBase.typeKey; @override - Set get coreTypes => - {StateTransitionBase.typeKey, StateMachineLayerComponentBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// StateToId field with key 151. @@ -41,23 +42,25 @@ abstract class StateTransitionBase extends StateMachineLayerComponent { /// Flags field with key 152. static const int flagsPropertyKey = 152; static const int flagsInitialValue = 0; - int _flags = flagsInitialValue; - int get flags => _flags; - - /// Change the [_flags] field value. - /// [flagsChanged] will be invoked only if the field's value has changed. - set flags(int value) { - if (_flags == value) { - return; - } - int from = _flags; - _flags = value; - if (hasValidated) { - flagsChanged(from, value); - } - } - void flagsChanged(int from, int to); + int flags = flagsInitialValue; + + // int _flags = flagsInitialValue; + // int get flags => _flags; + // + // /// Change the [_flags] field value. + // /// [flagsChanged] will be invoked only if the field's value has changed. + // set flags(int value) { + // if (_flags == value) { + // return; + // } + // int from = _flags; + // _flags = value; + // if (hasValidated) { + // flagsChanged(from, value); + // } + // } + // void flagsChanged(int from, int to); /// -------------------------------------------------------------------------- /// Duration field with key 158. @@ -191,7 +194,8 @@ abstract class StateTransitionBase extends StateMachineLayerComponent { super.copy(source); if (source is StateTransitionBase) { _stateToId = source._stateToId; - _flags = source._flags; + // _flags = source._flags; + flags = source.flags; _duration = source._duration; _exitTime = source._exitTime; _interpolationType = source._interpolationType; diff --git a/lib/src/generated/animation/transition_bool_condition_base.dart b/lib/src/generated/animation/transition_bool_condition_base.dart index e9bcc130..66e7823d 100644 --- a/lib/src/generated/animation/transition_bool_condition_base.dart +++ b/lib/src/generated/animation/transition_bool_condition_base.dart @@ -6,15 +6,17 @@ import 'package:rive/src/generated/animation/transition_condition_base.dart'; import 'package:rive/src/generated/animation/transition_input_condition_base.dart'; import 'package:rive/src/rive_core/animation/transition_value_condition.dart'; +const _coreTypes = { + TransitionBoolConditionBase.typeKey, + TransitionValueConditionBase.typeKey, + TransitionInputConditionBase.typeKey, + TransitionConditionBase.typeKey +}; + abstract class TransitionBoolConditionBase extends TransitionValueCondition { static const int typeKey = 71; @override int get coreType => TransitionBoolConditionBase.typeKey; @override - Set get coreTypes => { - TransitionBoolConditionBase.typeKey, - TransitionValueConditionBase.typeKey, - TransitionInputConditionBase.typeKey, - TransitionConditionBase.typeKey - }; + Set get coreTypes => _coreTypes; } diff --git a/lib/src/generated/animation/transition_input_condition_base.dart b/lib/src/generated/animation/transition_input_condition_base.dart index 9026c409..45dcf2fc 100644 --- a/lib/src/generated/animation/transition_input_condition_base.dart +++ b/lib/src/generated/animation/transition_input_condition_base.dart @@ -5,31 +5,35 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/animation/transition_condition.dart'; +const _coreTypes = {TransitionInputConditionBase.typeKey, TransitionConditionBase.typeKey}; + abstract class TransitionInputConditionBase extends TransitionCondition { static const int typeKey = 67; @override int get coreType => TransitionInputConditionBase.typeKey; @override - Set get coreTypes => - {TransitionInputConditionBase.typeKey, TransitionConditionBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// InputId field with key 155. static const int inputIdPropertyKey = 155; static const int inputIdInitialValue = -1; - int _inputId = inputIdInitialValue; + + @nonVirtual + int inputId_ = inputIdInitialValue; /// Id of the StateMachineInput referenced. - int get inputId => _inputId; + @nonVirtual + int get inputId => inputId_; - /// Change the [_inputId] field value. + /// Change the [inputId_] field value. /// [inputIdChanged] will be invoked only if the field's value has changed. set inputId(int value) { - if (_inputId == value) { + if (inputId_ == value) { return; } - int from = _inputId; - _inputId = value; + int from = inputId_; + inputId_ = value; if (hasValidated) { inputIdChanged(from, value); } @@ -41,7 +45,7 @@ abstract class TransitionInputConditionBase extends TransitionCondition { void copy(Core source) { super.copy(source); if (source is TransitionInputConditionBase) { - _inputId = source._inputId; + inputId_ = source.inputId_; } } } diff --git a/lib/src/generated/animation/transition_number_condition_base.dart b/lib/src/generated/animation/transition_number_condition_base.dart index 7699a911..21819295 100644 --- a/lib/src/generated/animation/transition_number_condition_base.dart +++ b/lib/src/generated/animation/transition_number_condition_base.dart @@ -7,17 +7,19 @@ import 'package:rive/src/generated/animation/transition_condition_base.dart'; import 'package:rive/src/generated/animation/transition_input_condition_base.dart'; import 'package:rive/src/rive_core/animation/transition_value_condition.dart'; +const _coreTypes = { + TransitionNumberConditionBase.typeKey, + TransitionValueConditionBase.typeKey, + TransitionInputConditionBase.typeKey, + TransitionConditionBase.typeKey +}; + abstract class TransitionNumberConditionBase extends TransitionValueCondition { static const int typeKey = 70; @override int get coreType => TransitionNumberConditionBase.typeKey; @override - Set get coreTypes => { - TransitionNumberConditionBase.typeKey, - TransitionValueConditionBase.typeKey, - TransitionInputConditionBase.typeKey, - TransitionConditionBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Value field with key 157. diff --git a/lib/src/generated/component_base.dart b/lib/src/generated/component_base.dart index 2f795c16..619fb7c6 100644 --- a/lib/src/generated/component_base.dart +++ b/lib/src/generated/component_base.dart @@ -3,31 +3,36 @@ import 'package:rive/src/core/core.dart'; +const _coreTypes = {ComponentBase.typeKey}; + abstract class ComponentBase extends Core { static const int typeKey = 10; @override int get coreType => ComponentBase.typeKey; @override - Set get coreTypes => {ComponentBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Name field with key 4. static const int namePropertyKey = 4; static const String nameInitialValue = ''; - String _name = nameInitialValue; + + @nonVirtual + String name_ = nameInitialValue; /// Non-unique identifier, used to give friendly names to elements in the /// hierarchy. Runtimes provide an API for finding components by this [name]. - String get name => _name; + @nonVirtual + String get name => name_; - /// Change the [_name] field value. + /// Change the [name_] field value. /// [nameChanged] will be invoked only if the field's value has changed. set name(String value) { - if (_name == value) { + if (name_ == value) { return; } - String from = _name; - _name = value; + String from = name_; + name_ = value; if (hasValidated) { nameChanged(from, value); } @@ -39,19 +44,22 @@ abstract class ComponentBase extends Core { /// ParentId field with key 5. static const int parentIdPropertyKey = 5; static const int parentIdInitialValue = 0; - int _parentId = parentIdInitialValue; + + @nonVirtual + int parentId_ = parentIdInitialValue; /// Identifier used to track parent ContainerComponent. - int get parentId => _parentId; + @nonVirtual + int get parentId => parentId_; - /// Change the [_parentId] field value. + /// Change the [parentId_] field value. /// [parentIdChanged] will be invoked only if the field's value has changed. set parentId(int value) { - if (_parentId == value) { + if (parentId_ == value) { return; } - int from = _parentId; - _parentId = value; + int from = parentId_; + parentId_ = value; if (hasValidated) { parentIdChanged(from, value); } @@ -63,8 +71,8 @@ abstract class ComponentBase extends Core { void copy(Core source) { super.copy(source); if (source is ComponentBase) { - _name = source._name; - _parentId = source._parentId; + name_ = source.name_; + parentId_ = source.parentId_; } } } diff --git a/lib/src/generated/constraints/distance_constraint_base.dart b/lib/src/generated/constraints/distance_constraint_base.dart index dc5c38ef..6763178e 100644 --- a/lib/src/generated/constraints/distance_constraint_base.dart +++ b/lib/src/generated/constraints/distance_constraint_base.dart @@ -7,36 +7,41 @@ import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/constraints/constraint_base.dart'; import 'package:rive/src/rive_core/constraints/targeted_constraint.dart'; +const _coreTypes = { + DistanceConstraintBase.typeKey, + TargetedConstraintBase.typeKey, + ConstraintBase.typeKey, + ComponentBase.typeKey +}; + abstract class DistanceConstraintBase extends TargetedConstraint { static const int typeKey = 82; @override int get coreType => DistanceConstraintBase.typeKey; @override - Set get coreTypes => { - DistanceConstraintBase.typeKey, - TargetedConstraintBase.typeKey, - ConstraintBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Distance field with key 177. static const int distancePropertyKey = 177; static const double distanceInitialValue = 100.0; - double _distance = distanceInitialValue; + + @nonVirtual + double distance_ = distanceInitialValue; /// The unit distance the constraint will move the constrained object relative /// to the target. - double get distance => _distance; + @nonVirtual + double get distance => distance_; - /// Change the [_distance] field value. + /// Change the [distance_] field value. /// [distanceChanged] will be invoked only if the field's value has changed. set distance(double value) { - if (_distance == value) { + if (distance_ == value) { return; } - double from = _distance; - _distance = value; + double from = distance_; + distance_ = value; if (hasValidated) { distanceChanged(from, value); } @@ -72,7 +77,7 @@ abstract class DistanceConstraintBase extends TargetedConstraint { void copy(Core source) { super.copy(source); if (source is DistanceConstraintBase) { - _distance = source._distance; + distance_ = source.distance_; _modeValue = source._modeValue; } } diff --git a/lib/src/generated/draw_rules_base.dart b/lib/src/generated/draw_rules_base.dart index 46a81fdc..857d825d 100644 --- a/lib/src/generated/draw_rules_base.dart +++ b/lib/src/generated/draw_rules_base.dart @@ -5,35 +5,40 @@ import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/container_component_base.dart'; import 'package:rive/src/rive_core/container_component.dart'; +const _coreTypes = { + DrawRulesBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class DrawRulesBase extends ContainerComponent { static const int typeKey = 49; @override int get coreType => DrawRulesBase.typeKey; @override - Set get coreTypes => { - DrawRulesBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// DrawTargetId field with key 121. static const int drawTargetIdPropertyKey = 121; static const int drawTargetIdInitialValue = -1; - int _drawTargetId = drawTargetIdInitialValue; + + @nonVirtual + int drawTargetId_ = drawTargetIdInitialValue; /// Id of the DrawTarget that is currently active for this set of rules. - int get drawTargetId => _drawTargetId; + @nonVirtual + int get drawTargetId => drawTargetId_; - /// Change the [_drawTargetId] field value. + /// Change the [drawTargetId_] field value. /// [drawTargetIdChanged] will be invoked only if the field's value has /// changed. set drawTargetId(int value) { - if (_drawTargetId == value) { + if (drawTargetId_ == value) { return; } - int from = _drawTargetId; - _drawTargetId = value; + int from = drawTargetId_; + drawTargetId_ = value; if (hasValidated) { drawTargetIdChanged(from, value); } @@ -45,7 +50,7 @@ abstract class DrawRulesBase extends ContainerComponent { void copy(Core source) { super.copy(source); if (source is DrawRulesBase) { - _drawTargetId = source._drawTargetId; + drawTargetId_ = source.drawTargetId_; } } } diff --git a/lib/src/generated/drawable_base.dart b/lib/src/generated/drawable_base.dart index 30507fd3..5d098ec2 100644 --- a/lib/src/generated/drawable_base.dart +++ b/lib/src/generated/drawable_base.dart @@ -49,18 +49,21 @@ abstract class DrawableBase extends Node { /// DrawableFlags field with key 129. static const int drawableFlagsPropertyKey = 129; static const int drawableFlagsInitialValue = 0; - int _drawableFlags = drawableFlagsInitialValue; - int get drawableFlags => _drawableFlags; + + // exposing it + int drawableFlags_ = drawableFlagsInitialValue; + @nonVirtual + int get drawableFlags => drawableFlags_; /// Change the [_drawableFlags] field value. /// [drawableFlagsChanged] will be invoked only if the field's value has /// changed. set drawableFlags(int value) { - if (_drawableFlags == value) { + if (drawableFlags_ == value) { return; } - int from = _drawableFlags; - _drawableFlags = value; + int from = drawableFlags_; + drawableFlags_ = value; if (hasValidated) { drawableFlagsChanged(from, value); } @@ -73,7 +76,7 @@ abstract class DrawableBase extends Node { super.copy(source); if (source is DrawableBase) { _blendModeValue = source._blendModeValue; - _drawableFlags = source._drawableFlags; + drawableFlags_ = source.drawableFlags_; } } } diff --git a/lib/src/generated/node_base.dart b/lib/src/generated/node_base.dart index f02fe172..9d4066d3 100644 --- a/lib/src/generated/node_base.dart +++ b/lib/src/generated/node_base.dart @@ -7,36 +7,41 @@ import 'package:rive/src/generated/container_component_base.dart'; import 'package:rive/src/generated/world_transform_component_base.dart'; import 'package:rive/src/rive_core/transform_component.dart'; +const _coreTypes = { + NodeBase.typeKey, + TransformComponentBase.typeKey, + WorldTransformComponentBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class NodeBase extends TransformComponent { static const int typeKey = 2; @override int get coreType => NodeBase.typeKey; @override - Set get coreTypes => { - NodeBase.typeKey, - TransformComponentBase.typeKey, - WorldTransformComponentBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// X field with key 13. static const int xPropertyKey = 13; static const double xInitialValue = 0; - double _x = xInitialValue; + @nonVirtual + double x_ = xInitialValue; @override - double get x => _x; + @nonVirtual + double get x => x_; - /// Change the [_x] field value. + /// Change the [x_] field value. /// [xChanged] will be invoked only if the field's value has changed. @override + @nonVirtual set x(double value) { - if (_x == value) { + if (x_ == value) { return; } - double from = _x; - _x = value; + double from = x_; + x_ = value; if (hasValidated) { xChanged(from, value); } @@ -48,19 +53,22 @@ abstract class NodeBase extends TransformComponent { /// Y field with key 14. static const int yPropertyKey = 14; static const double yInitialValue = 0; - double _y = yInitialValue; + @nonVirtual + double y_ = yInitialValue; @override - double get y => _y; + @nonVirtual + double get y => y_; - /// Change the [_y] field value. + /// Change the [y_] field value. /// [yChanged] will be invoked only if the field's value has changed. @override + @nonVirtual set y(double value) { - if (_y == value) { + if (y_ == value) { return; } - double from = _y; - _y = value; + double from = y_; + y_ = value; if (hasValidated) { yChanged(from, value); } @@ -72,8 +80,8 @@ abstract class NodeBase extends TransformComponent { void copy(Core source) { super.copy(source); if (source is NodeBase) { - _x = source._x; - _y = source._y; + x_ = source.x_; + y_ = source.y_; } } } diff --git a/lib/src/generated/rive_core_beans.dart b/lib/src/generated/rive_core_beans.dart new file mode 100644 index 00000000..508501fc --- /dev/null +++ b/lib/src/generated/rive_core_beans.dart @@ -0,0 +1,813 @@ +import 'package:collection/collection.dart'; +import 'package:rive/src/core/core.dart'; +import 'package:rive/src/generated/animation/interpolating_keyframe_base.dart'; +import 'package:rive/src/generated/animation/keyframe_base.dart'; +import 'package:rive/src/generated/animation/transition_input_condition_base.dart'; +import 'package:rive/src/generated/component_base.dart'; +import 'package:rive/src/generated/shapes/vertex_base.dart'; +import 'package:rive/src/generated/transform_component_base.dart'; +import 'package:rive/src/generated/world_transform_component_base.dart'; +import 'package:rive/src/rive_core/animation/keyed_object.dart'; +import 'package:rive/src/rive_core/animation/keyed_property.dart'; +import 'package:rive/src/rive_core/animation/keyframe_double.dart'; +import 'package:rive/src/rive_core/constraints/distance_constraint.dart'; +import 'package:rive/src/rive_core/draw_rules.dart'; +import 'package:rive/src/rive_core/node.dart'; +import 'package:rive/src/rive_core/shapes/cubic_asymmetric_vertex.dart'; +import 'package:rive/src/rive_core/shapes/cubic_detached_vertex.dart'; +import 'package:rive/src/rive_core/shapes/cubic_mirrored_vertex.dart'; +import 'package:rive/src/rive_core/shapes/paint/gradient_stop.dart'; +import 'package:rive/src/rive_core/shapes/paint/solid_color.dart'; +import 'package:rive/src/rive_core/shapes/paint/stroke.dart'; +import 'package:rive/src/rive_core/shapes/straight_vertex.dart'; +import 'package:rive/src/rive_core/solo.dart'; +import 'package:stokanal/core.dart'; + +import '../core/field_types/core_field_type.dart'; + +class PropertyBean { + final int propertyKey; + PropertyBean._(this.propertyKey); + + bool getBool(T o) => throw Exception(); + void setBool(T o, bool v) => throw Exception(); + + double getDouble(T o) => throw Exception(); + void setDouble(T o, double v) => throw Exception(); + + void transformDouble(T o, double Function(double) function) { + setDouble(o, function(getDouble(o))); + } + + void applyDouble(T o, double multiplier, double sum) { + setDouble(o, getDouble(o) * multiplier + sum); + } + + int getColor(T o) => throw Exception(); + void setColor(T o, int v) => throw Exception(); + + int getUint(T o) => throw Exception(); + void setUint(T o, int v) => throw Exception(); + + String getString(T o) => throw Exception(); + void setString(T o, String v) => throw Exception(); + + void setObjectProperty(Core o, Object v) => throw Exception(); + + CoreFieldType? get coreType => throw Exception(); + + void setCallback(T o, CallbackData v) => throw Exception(); +} + +class _DoublePropertyBean extends PropertyBean { + _DoublePropertyBean._(super.propertyKey): super._(); + + @override + @nonVirtual + CoreFieldType? get coreType => RiveCoreContext.doubleType; + + // @override + // void setObjectProperty(Core o, Object v) => o is T && v is double ? setDouble(o, v) : {}; +} + +// class DoublePropertyBean extends _DoublePropertyBean { +// +// final double Function(T) getter; +// final void Function(T, double) setter; +// DoublePropertyBean._(super.propertyKey, this.getter, this.setter): super._(); +// +// @override +// double getDouble(T o) => getter(o); +// +// @override +// void setDouble(T o, double v) => setter(o, v); +// +// @override +// void transformDouble(T o, double Function(double) function) => +// setter(o, function(getter(o))); +// +// @override +// void applyDouble(T o, double multiplier, double sum) => +// setter(o, getter(o) * multiplier + sum); +// +// @override +// void setObjectProperty(Core o, Object v) => o is T && v is double ? setter(o, v) : {}; +// } + +class _UintPropertyBean extends PropertyBean { + _UintPropertyBean._(super.propertyKey): super._(); + + @override + @nonVirtual + CoreFieldType? get coreType => RiveCoreContext.uintType; + + // @override + // void setObjectProperty(Core o, Object v) => o is T && v is int ? setUint(o, v) : {}; +} + +// class UintPropertyBean extends _UintPropertyBean { +// +// final int Function(T) getter; +// final void Function(T, int) setter; +// UintPropertyBean._(super.propertyKey, this.getter, this.setter): super._(); +// +// @override +// int getUint(T o) => getter(o); +// +// @override +// void setUint(T o, int v) => setter(o, v); +// +// @override +// void setObjectProperty(Core o, Object v) => o is T && v is int ? setter(o, v) : {}; +// +// // @override +// // CoreFieldType? get coreType => RiveCoreContext.uintType; +// } + +class _ColorPropertyBean extends PropertyBean { + _ColorPropertyBean._(super.propertyKey): super._(); + + @override + @nonVirtual + CoreFieldType? get coreType => RiveCoreContext.colorType; + + // @override + // void setObjectProperty(Core o, Object v) => o is T && v is int ? setUint(o, v) : {}; +} + +// class ColorPropertyBean extends PropertyBean { +// +// final int Function(T) getter; +// final void Function(T, int) setter; +// ColorPropertyBean._(super.propertyKey, this.getter, this.setter): super._(); +// +// @override +// int getColor(T o) => getter(o); +// +// @override +// void setColor(T o, int v) => setter(o, v); +// +// @override +// void setObjectProperty(Core o, Object v) => o is T && v is int ? setter(o, v) : {}; +// +// @override +// CoreFieldType? get coreType => RiveCoreContext.colorType; +// } + +class _StringPropertyBean extends PropertyBean { + _StringPropertyBean._(super.propertyKey): super._(); + + @override + @nonVirtual + CoreFieldType? get coreType => RiveCoreContext.stringType; + + // @override + // void setObjectProperty(Core o, Object v) => o is T && v is int ? setUint(o, v) : {}; +} + +// class StringPropertyBean extends _StringPropertyBean { +// +// final String Function(T) getter; +// final void Function(T, String) setter; +// StringPropertyBean._(super.propertyKey, this.getter, this.setter): super._(); +// +// @override +// String getString(T o) => getter(o); +// +// @override +// void setString(T o, String v) => setter(o, v); +// +// @override +// void setObjectProperty(Core o, Object v) => o is T && v is String ? setter(o, v) : {}; +// +// // @override +// // CoreFieldType? get coreType => RiveCoreContext.stringType; +// } + +class FallbackBean extends PropertyBean { + + FallbackBean._(super.propertyKey): + super._(); + + // ignore: prefer_final_fields + int _hits = 0; + + // uncomment me to dump stats + // bool dumped = false; + // int get hits => _hits; + // set hits(int hits) { + // _hits = hits; + // if (_hits >= 1000 && !dumped) { + // dumped = true; + // PropertyBeans._dumpFallbacks(); + // } + // } + + @override + bool getBool(Core o) { + // hits++; + return RiveCoreContext.getBool(o, propertyKey); + } + @override + void setBool(Core o, bool v) { + // hits++; + RiveCoreContext.setBool(o, propertyKey, v); + } + + @override + double getDouble(Core o) { + // hits++; + return RiveCoreContext.getDouble(o, propertyKey); + } + @override + void setDouble(Core o, double v) { + // hits++; + RiveCoreContext.setDouble(o, propertyKey, v); + } + + @override + int getColor(Core o) { + // hits++; + return RiveCoreContext.getColor(o, propertyKey); + } + @override + void setColor(Core o, int v) { + // hits++; + RiveCoreContext.setColor(o, propertyKey, v); + } + + @override + int getUint(Core o) { + // hits++; + return RiveCoreContext.getUint(o, propertyKey); + } + @override + void setUint(Core o, int v) { + // hits++; + RiveCoreContext.setUint(o, propertyKey, v); + } + + @override + String getString(Core o) { + // hits++; + return RiveCoreContext.getString(o, propertyKey); + } + @override + void setString(Core o, String v) { + // hits++; + RiveCoreContext.setString(o, propertyKey, v); + } + + @override + void setObjectProperty(Core o, Object v) { + // hits++; + RiveCoreContext.setObjectProperty(o, propertyKey, v); + } + + @override + CoreFieldType? get coreType { + // hits++; + return RiveCoreContext.coreType(propertyKey); + } + + @override + void setCallback(Core o, CallbackData v) { + // hits++; + RiveCoreContext.setCallback(o, propertyKey, v); + } + + @override + String toString() => 'FallbackBean[$propertyKey, $_hits]'; +} + +// final _map = {}; +final _list = List.filled(1000, null); // use a list to map from property keys +final _invalid = PropertyBean._(CoreContext.invalidPropertyKey); +var _first = true; +final _implements = [ + _invalid, + XBean._(), + YBean._(), + VertexBaseXBean._(), + VertexBaseYBean._(), + + OutRotationBean._(), + OutDistanceBean._(), + InRotationBean._(), + InDistanceBean._(), + CubicAsymmetricVertexInDistanceBean._(), + RotationBean._(), + ScaleXBean._(), + ScaleYBean._(), + TransformComponentRotationBean._(), + ValueBean._(), + OpacityBean._(), + + CubicMirroredVertexBaseRotationBean._(), + CubicAsymmetricVertexBaseOutDistanceBean._(), + StraightVertexBaseRadiusBean._(), + StrokeBaseThicknessBean._(), + DistanceConstraintBaseDistanceBean._(), + CubicMirroredVertexBaseDistanceBean._(), + GradientStopBasePositionBean._(), + + InterpolatingKeyFrameBaseInterpolatorIdBean._(), + KeyedPropertyBasePropertyKeyBean._(), + KeyFrameBaseFrameBean._(), + InterpolatingKeyFrameBaseInterpolationTypeBean._(), + SoloBaseActiveComponentIdBean._(), + KeyedObjectBaseObjectIdBean._(), + DrawRulesBaseDrawTargetIdBean._(), + ComponentBaseParentIdBean._(), + TransitionInputConditionBaseInputIdBean._(), + + ComponentBaseNameBean._(), + + SolidColorBaseColorValueBean._(), + GradientStopBaseColorValueBean._(), + +]; + +// ignore: avoid_classes_with_only_static_members +abstract class PropertyBeans { + + static PropertyBean get invalid => _invalid; + + static PropertyBean get(int propertyKey) { + + if (_first) { + _first = false; + // _implements.forEach((bean) => _map[bean.propertyKey] = bean); + _implements.forEach((bean) => _list[bean.propertyKey] = bean); + } + + // return _map.putIfAbsent(propertyKey, () => FallbackBean._(propertyKey)); + return _list[propertyKey] ?? (_list[propertyKey] = FallbackBean._(propertyKey)); + } + + // ignore: unused_element + static void _dumpFallbacks() { + info('\n${ + // _map.values + _list.whereNotNull() + .whereType().sorted((b1, b2) => b2._hits.compareTo(b1._hits)).map((b) => '$b').join('\n')}'); + } +} + +/// See EntityMeta.java for the auto generator + +class XBean extends _DoublePropertyBean { + XBean._(): super._(NodeBase.xPropertyKey); + @override + double getDouble(NodeBase o) => o.x_; + @override + void setDouble(NodeBase o, double v) => o.x = v; + @override + void transformDouble(NodeBase o, double Function(double) function) => o.x = function(o.x_); + @override + void applyDouble(NodeBase o, double multiplier, double sum) => o.x = o.x_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is NodeBase && v is double ? o.x = v : {}; +} +class YBean extends _DoublePropertyBean { + YBean._(): super._(NodeBase.yPropertyKey); + @override + double getDouble(NodeBase o) => o.y_; + @override + void setDouble(NodeBase o, double v) => o.y = v; + @override + void transformDouble(NodeBase o, double Function(double) function) => o.y = function(o.y_); + @override + void applyDouble(NodeBase o, double multiplier, double sum) => o.y = o.y_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is NodeBase && v is double ? o.y = v : {}; +} +class VertexBaseXBean extends _DoublePropertyBean { + VertexBaseXBean._(): super._(VertexBase.xPropertyKey); + @override + double getDouble(VertexBase o) => o.x_; + @override + void setDouble(VertexBase o, double v) => o.x = v; + @override + void transformDouble(VertexBase o, double Function(double) function) => o.x = function(o.x_); + @override + void applyDouble(VertexBase o, double multiplier, double sum) => o.x = o.x_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is VertexBase && v is double ? o.x = v : {}; +} +class VertexBaseYBean extends _DoublePropertyBean { + VertexBaseYBean._(): super._(VertexBase.yPropertyKey); + @override + double getDouble(VertexBase o) => o.y_; + @override + void setDouble(VertexBase o, double v) => o.y = v; + @override + void transformDouble(VertexBase o, double Function(double) function) => o.y = function(o.y_); + @override + void applyDouble(VertexBase o, double multiplier, double sum) => o.y = o.y_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is VertexBase && v is double ? o.y = v : {}; +} + +// DoublePropertyBean._(CubicDetachedVertexBase.outRotationPropertyKey, (o) => o.outRotation_, (o, v) => o.outRotation = v), +class OutRotationBean extends _DoublePropertyBean { + OutRotationBean._(): super._(CubicDetachedVertexBase.outRotationPropertyKey); + @override + double getDouble(CubicDetachedVertexBase o) => o.outRotation_; + @override + void setDouble(CubicDetachedVertexBase o, double v) => o.outRotation = v; + @override + void transformDouble(CubicDetachedVertexBase o, double Function(double) function) => o.outRotation = function(o.outRotation_); + @override + void applyDouble(CubicDetachedVertexBase o, double multiplier, double sum) => o.outRotation = o.outRotation_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicDetachedVertexBase && v is double ? o.outRotation = v : {}; +} + +// DoublePropertyBean._(CubicDetachedVertexBase.outDistancePropertyKey, (o) => o.outDistance_, (o, v) => o.outDistance = v), +class OutDistanceBean extends _DoublePropertyBean { + OutDistanceBean._(): super._(CubicDetachedVertexBase.outDistancePropertyKey); + @override + double getDouble(CubicDetachedVertexBase o) => o.outDistance_; + @override + void setDouble(CubicDetachedVertexBase o, double v) => o.outDistance = v; + @override + void transformDouble(CubicDetachedVertexBase o, double Function(double) function) => o.outDistance = function(o.outDistance_); + @override + void applyDouble(CubicDetachedVertexBase o, double multiplier, double sum) => o.outDistance = o.outDistance_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicDetachedVertexBase && v is double ? o.outDistance = v : {}; +} + +// DoublePropertyBean._(CubicDetachedVertexBase.inRotationPropertyKey, (o) => o.inRotation_, (o, v) => o.inRotation = v), +class InRotationBean extends _DoublePropertyBean { + InRotationBean._(): super._(CubicDetachedVertexBase.inRotationPropertyKey); + @override + double getDouble(CubicDetachedVertexBase o) => o.inRotation_; + @override + void setDouble(CubicDetachedVertexBase o, double v) => o.inRotation = v; + @override + void transformDouble(CubicDetachedVertexBase o, double Function(double) function) => o.inRotation = function(o.inRotation_); + @override + void applyDouble(CubicDetachedVertexBase o, double multiplier, double sum) => o.inRotation = o.inRotation_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicDetachedVertexBase && v is double ? o.inRotation = v : {}; +} + +// DoublePropertyBean._(CubicDetachedVertexBase.inDistancePropertyKey, (o) => o.inDistance_, (o, v) => o.inDistance = v), +class InDistanceBean extends _DoublePropertyBean { + InDistanceBean._(): super._(CubicDetachedVertexBase.inDistancePropertyKey); + @override + double getDouble(CubicDetachedVertexBase o) => o.inDistance_; + @override + void setDouble(CubicDetachedVertexBase o, double v) => o.inDistance = v; + @override + void transformDouble(CubicDetachedVertexBase o, double Function(double) function) => o.inDistance = function(o.inDistance_); + @override + void applyDouble(CubicDetachedVertexBase o, double multiplier, double sum) => o.inDistance = o.inDistance_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicDetachedVertexBase && v is double ? o.inDistance = v : {}; +} + +// DoublePropertyBean._(CubicAsymmetricVertexBase.inDistancePropertyKey, (o) => o.inDistance_, (o, v) => o.inDistance = v), +class CubicAsymmetricVertexInDistanceBean extends _DoublePropertyBean { + CubicAsymmetricVertexInDistanceBean._(): super._(CubicAsymmetricVertexBase.inDistancePropertyKey); + @override + double getDouble(CubicAsymmetricVertexBase o) => o.inDistance_; + @override + void setDouble(CubicAsymmetricVertexBase o, double v) => o.inDistance = v; + @override + void transformDouble(CubicAsymmetricVertexBase o, double Function(double) function) => o.inDistance = function(o.inDistance_); + @override + void applyDouble(CubicAsymmetricVertexBase o, double multiplier, double sum) => o.inDistance = o.inDistance_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicAsymmetricVertexBase && v is double ? o.inDistance = v : {}; +} + +// DoublePropertyBean._(CubicAsymmetricVertexBase.rotationPropertyKey, (o) => o.rotation_, (o, v) => o.rotation = v), +class RotationBean extends _DoublePropertyBean { + RotationBean._(): super._(CubicAsymmetricVertexBase.rotationPropertyKey); + @override + double getDouble(CubicAsymmetricVertexBase o) => o.rotation_; + @override + void setDouble(CubicAsymmetricVertexBase o, double v) => o.rotation = v; + @override + void transformDouble(CubicAsymmetricVertexBase o, double Function(double) function) => o.rotation = function(o.rotation_); + @override + void applyDouble(CubicAsymmetricVertexBase o, double multiplier, double sum) => o.rotation = o.rotation_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicAsymmetricVertexBase && v is double ? o.rotation = v : {}; +} + +// DoublePropertyBean._(TransformComponentBase.scaleXPropertyKey, (o) => o.scaleX_, (o, v) => o.scaleX = v), +class ScaleXBean extends _DoublePropertyBean { + ScaleXBean._(): super._(TransformComponentBase.scaleXPropertyKey); + @override + double getDouble(TransformComponentBase o) => o.scaleX_; + @override + void setDouble(TransformComponentBase o, double v) => o.scaleX = v; + @override + void transformDouble(TransformComponentBase o, double Function(double) function) => o.scaleX = function(o.scaleX_); + @override + void applyDouble(TransformComponentBase o, double multiplier, double sum) => o.scaleX = o.scaleX_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is TransformComponentBase && v is double ? o.scaleX = v : {}; +} + +// DoublePropertyBean._(TransformComponentBase.scaleYPropertyKey, (o) => o.scaleY_, (o, v) => o.scaleY = v), +class ScaleYBean extends _DoublePropertyBean { + ScaleYBean._(): super._(TransformComponentBase.scaleYPropertyKey); + @override + double getDouble(TransformComponentBase o) => o.scaleY_; + @override + void setDouble(TransformComponentBase o, double v) => o.scaleY = v; + @override + void transformDouble(TransformComponentBase o, double Function(double) function) => o.scaleY = function(o.scaleY_); + @override + void applyDouble(TransformComponentBase o, double multiplier, double sum) => o.scaleY = o.scaleY_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is TransformComponentBase && v is double ? o.scaleY = v : {}; +} + +// DoublePropertyBean._(TransformComponentBase.rotationPropertyKey, (o) => o.rotation_, (o, v) => o.rotation = v), +class TransformComponentRotationBean extends _DoublePropertyBean { + TransformComponentRotationBean._(): super._(TransformComponentBase.rotationPropertyKey); + @override + double getDouble(TransformComponentBase o) => o.rotation_; + @override + void setDouble(TransformComponentBase o, double v) => o.rotation = v; + @override + void transformDouble(TransformComponentBase o, double Function(double) function) => o.rotation = function(o.rotation_); + @override + void applyDouble(TransformComponentBase o, double multiplier, double sum) => o.rotation = o.rotation_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is TransformComponentBase && v is double ? o.rotation = v : {}; +} + +// DoublePropertyBean._(KeyFrameDoubleBase.valuePropertyKey, (o) => o.value, (o, v) => o.value = v), +class ValueBean extends _DoublePropertyBean { + ValueBean._(): super._(KeyFrameDoubleBase.valuePropertyKey); + @override + double getDouble(KeyFrameDoubleBase o) => o.value; + @override + void setDouble(KeyFrameDoubleBase o, double v) => o.value = v; + @override + void transformDouble(KeyFrameDoubleBase o, double Function(double) function) => o.value = function(o.value); + @override + void applyDouble(KeyFrameDoubleBase o, double multiplier, double sum) => o.value = o.value * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is KeyFrameDoubleBase && v is double ? o.value = v : {}; +} + +// DoublePropertyBean._(WorldTransformComponentBase.opacityPropertyKey, (o) => o.opacity_, (o, v) => o.opacity = v), +class OpacityBean extends _DoublePropertyBean { + OpacityBean._(): super._(WorldTransformComponentBase.opacityPropertyKey); + @override + double getDouble(WorldTransformComponentBase o) => o.opacity_; + @override + void setDouble(WorldTransformComponentBase o, double v) => o.opacity = v; + @override + void transformDouble(WorldTransformComponentBase o, double Function(double) function) => o.opacity = function(o.opacity_); + @override + void applyDouble(WorldTransformComponentBase o, double multiplier, double sum) => o.opacity = o.opacity_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is WorldTransformComponentBase && v is double ? o.opacity = v : {}; +} + +// DoublePropertyBean._(CubicMirroredVertexBase.rotationPropertyKey, (o) => o.rotation, (o, v) => o.rotation = v), +class CubicMirroredVertexBaseRotationBean extends _DoublePropertyBean { + CubicMirroredVertexBaseRotationBean._(): super._(CubicMirroredVertexBase.rotationPropertyKey); + @override + double getDouble(CubicMirroredVertexBase o) => o.rotation_; + @override + void setDouble(CubicMirroredVertexBase o, double v) => o.rotation = v; + @override + void transformDouble(CubicMirroredVertexBase o, double Function(double) function) => o.rotation = function(o.rotation_); + @override + void applyDouble(CubicMirroredVertexBase o, double multiplier, double sum) => o.rotation = o.rotation_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicMirroredVertexBase && v is double ? o.rotation = v : {}; +} + +// DoublePropertyBean._(CubicAsymmetricVertexBase.outDistancePropertyKey, (o) => o.outDistance, (o, v) => o.outDistance = v), +class CubicAsymmetricVertexBaseOutDistanceBean extends _DoublePropertyBean { + CubicAsymmetricVertexBaseOutDistanceBean._(): super._(CubicAsymmetricVertexBase.outDistancePropertyKey); + @override + double getDouble(CubicAsymmetricVertexBase o) => o.outDistance_; + @override + void setDouble(CubicAsymmetricVertexBase o, double v) => o.outDistance = v; + @override + void transformDouble(CubicAsymmetricVertexBase o, double Function(double) function) => o.outDistance = function(o.outDistance_); + @override + void applyDouble(CubicAsymmetricVertexBase o, double multiplier, double sum) => o.outDistance = o.outDistance_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicAsymmetricVertexBase && v is double ? o.outDistance = v : {}; +} + +// DoublePropertyBean._(StraightVertexBase.radiusPropertyKey, (o) => o.radius, (o, v) => o.radius = v), +class StraightVertexBaseRadiusBean extends _DoublePropertyBean { + StraightVertexBaseRadiusBean._(): super._(StraightVertexBase.radiusPropertyKey); + @override + double getDouble(StraightVertexBase o) => o.radius_; + @override + void setDouble(StraightVertexBase o, double v) => o.radius = v; + @override + void transformDouble(StraightVertexBase o, double Function(double) function) => o.radius = function(o.radius_); + @override + void applyDouble(StraightVertexBase o, double multiplier, double sum) => o.radius = o.radius_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is StraightVertexBase && v is double ? o.radius = v : {}; +} + +// DoublePropertyBean._(StrokeBase.thicknessPropertyKey, (o) => o.thickness, (o, v) => o.thickness = v), +class StrokeBaseThicknessBean extends _DoublePropertyBean { + StrokeBaseThicknessBean._(): super._(StrokeBase.thicknessPropertyKey); + @override + double getDouble(StrokeBase o) => o.thickness_; + @override + void setDouble(StrokeBase o, double v) => o.thickness = v; + @override + void transformDouble(StrokeBase o, double Function(double) function) => o.thickness = function(o.thickness_); + @override + void applyDouble(StrokeBase o, double multiplier, double sum) => o.thickness = o.thickness_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is StrokeBase && v is double ? o.thickness = v : {}; +} + +// DoublePropertyBean._(DistanceConstraintBase.distancePropertyKey, (o) => o.distance, (o, v) => o.distance = v), +class DistanceConstraintBaseDistanceBean extends _DoublePropertyBean { + DistanceConstraintBaseDistanceBean._(): super._(DistanceConstraintBase.distancePropertyKey); + @override + double getDouble(DistanceConstraintBase o) => o.distance_; + @override + void setDouble(DistanceConstraintBase o, double v) => o.distance = v; + @override + void transformDouble(DistanceConstraintBase o, double Function(double) function) => o.distance = function(o.distance_); + @override + void applyDouble(DistanceConstraintBase o, double multiplier, double sum) => o.distance = o.distance_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is DistanceConstraintBase && v is double ? o.distance = v : {}; +} + +// DoublePropertyBean._(CubicMirroredVertexBase.distancePropertyKey, (o) => o.distance, (o, v) => o.distance = v), +class CubicMirroredVertexBaseDistanceBean extends _DoublePropertyBean { + CubicMirroredVertexBaseDistanceBean._(): super._(CubicMirroredVertexBase.distancePropertyKey); + @override + double getDouble(CubicMirroredVertexBase o) => o.distance_; + @override + void setDouble(CubicMirroredVertexBase o, double v) => o.distance = v; + @override + void transformDouble(CubicMirroredVertexBase o, double Function(double) function) => o.distance = function(o.distance_); + @override + void applyDouble(CubicMirroredVertexBase o, double multiplier, double sum) => o.distance = o.distance_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is CubicMirroredVertexBase && v is double ? o.distance = v : {}; +} + +// DoublePropertyBean._(GradientStopBase.positionPropertyKey, (o) => o.position, (o, v) => o.position = v), +class GradientStopBasePositionBean extends _DoublePropertyBean { + GradientStopBasePositionBean._(): super._(GradientStopBase.positionPropertyKey); + @override + double getDouble(GradientStopBase o) => o.position_; + @override + void setDouble(GradientStopBase o, double v) => o.position = v; + @override + void transformDouble(GradientStopBase o, double Function(double) function) => o.position = function(o.position_); + @override + void applyDouble(GradientStopBase o, double multiplier, double sum) => o.position = o.position_ * multiplier + sum; + @override + void setObjectProperty(Core o, Object v) => o is GradientStopBase && v is double ? o.position = v : {}; +} + +// UintPropertyBean._(InterpolatingKeyFrameBase.interpolatorIdPropertyKey, (o) => o.interpolatorId, (o, v) => o.interpolatorId = v), +class InterpolatingKeyFrameBaseInterpolatorIdBean extends _UintPropertyBean { + InterpolatingKeyFrameBaseInterpolatorIdBean._(): super._(InterpolatingKeyFrameBase.interpolatorIdPropertyKey); + @override + int getUint(InterpolatingKeyFrameBase o) => o.interpolatorId; + @override + void setUint(InterpolatingKeyFrameBase o, int v) => o.interpolatorId = v; + @override + void setObjectProperty(Core o, Object v) => o is InterpolatingKeyFrameBase && v is int ? o.interpolatorId = v : {}; +} + +// UintPropertyBean._(KeyedPropertyBase.propertyKeyPropertyKey, (o) => o.propertyKey, (o, v) => o.propertyKey = v), +class KeyedPropertyBasePropertyKeyBean extends _UintPropertyBean { + KeyedPropertyBasePropertyKeyBean._(): super._(KeyedPropertyBase.propertyKeyPropertyKey); + @override + int getUint(KeyedPropertyBase o) => o.propertyKey; + @override + void setUint(KeyedPropertyBase o, int v) => o.propertyKey = v; + @override + void setObjectProperty(Core o, Object v) => o is KeyedPropertyBase && v is int ? o.propertyKey = v : {}; +} + +// UintPropertyBean._(KeyFrameBase.framePropertyKey, (o) => o.frame, (o, v) => o.frame = v), +class KeyFrameBaseFrameBean extends _UintPropertyBean { + KeyFrameBaseFrameBean._(): super._(KeyFrameBase.framePropertyKey); + @override + int getUint(KeyFrameBase o) => o.high; + @override + void setUint(KeyFrameBase o, int v) => o.high = v; + @override + void setObjectProperty(Core o, Object v) => o is KeyFrameBase && v is int ? o.high = v : {}; +} + +// UintPropertyBean._(InterpolatingKeyFrameBase.interpolationTypePropertyKey, (o) => o.interpolationType, (o, v) => o.interpolationType = v), +class InterpolatingKeyFrameBaseInterpolationTypeBean extends _UintPropertyBean { + InterpolatingKeyFrameBaseInterpolationTypeBean._(): super._(InterpolatingKeyFrameBase.interpolationTypePropertyKey); + @override + int getUint(InterpolatingKeyFrameBase o) => o.interpolationType; + @override + void setUint(InterpolatingKeyFrameBase o, int v) => o.interpolationType = v; + @override + void setObjectProperty(Core o, Object v) => o is InterpolatingKeyFrameBase && v is int ? o.interpolationType = v : {}; +} + +// UintPropertyBean._(SoloBase.activeComponentIdPropertyKey, (o) => o.activeComponentId, (o, v) => o.activeComponentId = v), +class SoloBaseActiveComponentIdBean extends _UintPropertyBean { + SoloBaseActiveComponentIdBean._(): super._(SoloBase.activeComponentIdPropertyKey); + @override + int getUint(SoloBase o) => o.activeComponentId_; + @override + void setUint(SoloBase o, int v) => o.activeComponentId = v; + @override + void setObjectProperty(Core o, Object v) => o is SoloBase && v is int ? o.activeComponentId = v : {}; +} + +// UintPropertyBean._(KeyedObjectBase.objectIdPropertyKey, (o) => o.objectId, (o, v) => o.objectId = v), +class KeyedObjectBaseObjectIdBean extends _UintPropertyBean { + KeyedObjectBaseObjectIdBean._(): super._(KeyedObjectBase.objectIdPropertyKey); + @override + int getUint(KeyedObjectBase o) => o.high; + @override + void setUint(KeyedObjectBase o, int v) => o.high = v; + @override + void setObjectProperty(Core o, Object v) => o is KeyedObjectBase && v is int ? o.high = v : {}; +} + +// UintPropertyBean._(DrawRulesBase.drawTargetIdPropertyKey, (o) => o.drawTargetId, (o, v) => o.drawTargetId = v), +class DrawRulesBaseDrawTargetIdBean extends _UintPropertyBean { + DrawRulesBaseDrawTargetIdBean._(): super._(DrawRulesBase.drawTargetIdPropertyKey); + @override + int getUint(DrawRulesBase o) => o.drawTargetId_; + @override + void setUint(DrawRulesBase o, int v) => o.drawTargetId = v; + @override + void setObjectProperty(Core o, Object v) => o is DrawRulesBase && v is int ? o.drawTargetId = v : {}; +} + +// UintPropertyBean._(ComponentBase.parentIdPropertyKey, (o) => o.parentId, (o, v) => o.parentId = v), +class ComponentBaseParentIdBean extends _UintPropertyBean { + ComponentBaseParentIdBean._(): super._(ComponentBase.parentIdPropertyKey); + @override + int getUint(ComponentBase o) => o.parentId_; + @override + void setUint(ComponentBase o, int v) => o.parentId = v; + @override + void setObjectProperty(Core o, Object v) => o is ComponentBase && v is int ? o.parentId = v : {}; +} + +// UintPropertyBean._(TransitionInputConditionBase.inputIdPropertyKey, (o) => o.inputId, (o, v) => o.inputId = v), +class TransitionInputConditionBaseInputIdBean extends _UintPropertyBean { + TransitionInputConditionBaseInputIdBean._(): super._(TransitionInputConditionBase.inputIdPropertyKey); + @override + int getUint(TransitionInputConditionBase o) => o.inputId_; + @override + void setUint(TransitionInputConditionBase o, int v) => o.inputId = v; + @override + void setObjectProperty(Core o, Object v) => o is TransitionInputConditionBase && v is int ? o.inputId = v : {}; +} + +// StringPropertyBean._(ComponentBase.namePropertyKey, (o) => o.name, (o, v) => o.name = v), +class ComponentBaseNameBean extends _StringPropertyBean { + ComponentBaseNameBean._(): super._(ComponentBase.namePropertyKey); + @override + String getString(ComponentBase o) => o.name_; + @override + void setString(ComponentBase o, String v) => o.name = v; + @override + void setObjectProperty(Core o, Object v) => o is ComponentBase && v is String ? o.name = v : {}; +} + +// ColorPropertyBean._(SolidColorBase.colorValuePropertyKey, (o) => o.colorValue, (o, v) => o.colorValue = v), +class SolidColorBaseColorValueBean extends _ColorPropertyBean { + SolidColorBaseColorValueBean._(): super._(SolidColorBase.colorValuePropertyKey); + @override + int getColor(SolidColorBase o) => o.colorValue_; + @override + void setColor(SolidColorBase o, int v) => o.colorValue = v; + @override + void setObjectProperty(Core o, Object v) => o is SolidColorBase && v is int ? o.colorValue = v : {}; +} + +// ColorPropertyBean._(GradientStopBase.colorValuePropertyKey, (o) => o.colorValue, (o, v) => o.colorValue = v), +class GradientStopBaseColorValueBean extends _ColorPropertyBean { + GradientStopBaseColorValueBean._(): super._(GradientStopBase.colorValuePropertyKey); + @override + int getColor(GradientStopBase o) => o.colorValue_; + @override + void setColor(GradientStopBase o, int v) => o.colorValue = v; + @override + void setObjectProperty(Core o, Object v) => o is GradientStopBase && v is int ? o.colorValue = v : {}; +} + diff --git a/lib/src/generated/rive_core_context.dart b/lib/src/generated/rive_core_context.dart index ac4d68e8..47363552 100644 --- a/lib/src/generated/rive_core_context.dart +++ b/lib/src/generated/rive_core_context.dart @@ -10,21 +10,17 @@ import 'package:rive/src/generated/animation/advanceable_state_base.dart'; import 'package:rive/src/generated/animation/blend_animation_base.dart'; import 'package:rive/src/generated/animation/cubic_ease_interpolator_base.dart'; import 'package:rive/src/generated/animation/cubic_interpolator_base.dart'; -import 'package:rive/src/generated/animation/interpolating_keyframe_base.dart'; -import 'package:rive/src/generated/animation/keyframe_base.dart'; import 'package:rive/src/generated/animation/keyframe_string_base.dart'; import 'package:rive/src/generated/animation/layer_state_base.dart'; import 'package:rive/src/generated/animation/listener_input_change_base.dart'; import 'package:rive/src/generated/animation/nested_input_base.dart'; import 'package:rive/src/generated/animation/nested_linear_animation_base.dart'; import 'package:rive/src/generated/animation/state_machine_component_base.dart'; -import 'package:rive/src/generated/animation/transition_input_condition_base.dart'; import 'package:rive/src/generated/animation/transition_value_condition_base.dart'; import 'package:rive/src/generated/assets/asset_base.dart'; import 'package:rive/src/generated/assets/drawable_asset_base.dart'; import 'package:rive/src/generated/assets/export_audio_base.dart'; import 'package:rive/src/generated/assets/file_asset_base.dart'; -import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/constraints/constraint_base.dart'; import 'package:rive/src/generated/constraints/targeted_constraint_base.dart'; import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart'; @@ -36,10 +32,7 @@ import 'package:rive/src/generated/nested_animation_base.dart'; import 'package:rive/src/generated/shapes/paint/shape_paint_base.dart'; import 'package:rive/src/generated/shapes/parametric_path_base.dart'; import 'package:rive/src/generated/shapes/path_base.dart'; -import 'package:rive/src/generated/shapes/vertex_base.dart'; -import 'package:rive/src/generated/transform_component_base.dart'; import 'package:rive/src/generated/viewmodel/viewmodel_instance_value_base.dart'; -import 'package:rive/src/generated/world_transform_component_base.dart'; import 'package:rive/src/rive_core/animation/animation.dart'; import 'package:rive/src/rive_core/animation/animation_state.dart'; import 'package:rive/src/rive_core/animation/any_state.dart'; @@ -190,7 +183,35 @@ import 'package:rive/src/rive_core/viewmodel/viewmodel_property_viewmodel.dart'; // ignore: avoid_classes_with_only_static_members class RiveCoreContext { + + // static final _counter = HashMap(); + + /// STOKANAL-FORK-EDIT static Core? makeCoreInstance(int typeKey) { + + switch (typeKey) { + case KeyFrameDoubleBase.typeKey: return KeyFrameDouble(); + case KeyedPropertyBase.typeKey: return KeyedProperty(); + case KeyedObjectBase.typeKey: return KeyedObject(); + case KeyFrameIdBase.typeKey: return KeyFrameId(); + case TransitionNumberConditionBase.typeKey: return TransitionNumberCondition(); + case TransitionBoolConditionBase.typeKey: return TransitionBoolCondition(); + case CubicEaseInterpolatorBase.typeKey: return CubicEaseInterpolator(); + case CubicDetachedVertexBase.typeKey: return CubicDetachedVertex(); + case StateTransitionBase.typeKey: return StateTransition(); + case CubicValueInterpolatorBase.typeKey: return CubicValueInterpolator(); + case StraightVertexBase.typeKey: return StraightVertex(); + case AnimationStateBase.typeKey: return AnimationState(); + case ImageBase.typeKey: return Image(); + case NodeBase.typeKey: return Node(); + case LinearAnimationBase.typeKey: return LinearAnimation(); + } + + // _counter.putIfAbsent(typeKey, IntCapsule.new).increment(); + // if (Randoms().hit(0.001)) { + // info('makeCoreInstance > ${_counter.entries.sorted((e1, e2) => e2.value.value - e1.value.value).map((e) => '${e.key}:${e.value}').join(',')}'); + // } + switch (typeKey) { case ViewModelInstanceListItemBase.typeKey: return ViewModelInstanceListItem(); @@ -252,8 +273,6 @@ class RiveCoreContext { return ScaleConstraint(); case RotationConstraintBase.typeKey: return RotationConstraint(); - case NodeBase.typeKey: - return Node(); case NestedArtboardBase.typeKey: return NestedArtboard(); case SoloBase.typeKey: @@ -266,40 +285,26 @@ class RiveCoreContext { return KeyFrameUint(); case AnimationBase.typeKey: return Animation(); - case LinearAnimationBase.typeKey: - return LinearAnimation(); case NestedSimpleAnimationBase.typeKey: return NestedSimpleAnimation(); - case AnimationStateBase.typeKey: - return AnimationState(); case NestedTriggerBase.typeKey: return NestedTrigger(); - case KeyedObjectBase.typeKey: - return KeyedObject(); case BlendAnimationDirectBase.typeKey: return BlendAnimationDirect(); case StateMachineNumberBase.typeKey: return StateMachineNumber(); - case CubicValueInterpolatorBase.typeKey: - return CubicValueInterpolator(); case TransitionTriggerConditionBase.typeKey: return TransitionTriggerCondition(); - case KeyedPropertyBase.typeKey: - return KeyedProperty(); case StateMachineListenerBase.typeKey: return StateMachineListener(); case TransitionPropertyViewModelComparatorBase.typeKey: return TransitionPropertyViewModelComparator(); - case KeyFrameIdBase.typeKey: - return KeyFrameId(); case KeyFrameBoolBase.typeKey: return KeyFrameBool(); case ListenerBoolChangeBase.typeKey: return ListenerBoolChange(); case ListenerAlignTargetBase.typeKey: return ListenerAlignTarget(); - case TransitionNumberConditionBase.typeKey: - return TransitionNumberCondition(); case TransitionValueBooleanComparatorBase.typeKey: return TransitionValueBooleanComparator(); case AnyStateBase.typeKey: @@ -314,14 +319,8 @@ class RiveCoreContext { return ListenerNumberChange(); case TransitionViewModelConditionBase.typeKey: return TransitionViewModelCondition(); - case CubicEaseInterpolatorBase.typeKey: - return CubicEaseInterpolator(); - case StateTransitionBase.typeKey: - return StateTransition(); case NestedBoolBase.typeKey: return NestedBool(); - case KeyFrameDoubleBase.typeKey: - return KeyFrameDouble(); case KeyFrameColorBase.typeKey: return KeyFrameColor(); case StateMachineBase.typeKey: @@ -362,8 +361,6 @@ class RiveCoreContext { return TransitionValueStringComparator(); case NestedRemapAnimationBase.typeKey: return NestedRemapAnimation(); - case TransitionBoolConditionBase.typeKey: - return TransitionBoolCondition(); case BlendStateTransitionBase.typeKey: return BlendStateTransition(); case StateMachineBoolBase.typeKey: @@ -388,8 +385,6 @@ class RiveCoreContext { return Shape(); case WeightBase.typeKey: return Weight(); - case StraightVertexBase.typeKey: - return StraightVertex(); case CubicWeightBase.typeKey: return CubicWeight(); case CubicAsymmetricVertexBase.typeKey: @@ -414,10 +409,6 @@ class RiveCoreContext { return Polygon(); case StarBase.typeKey: return Star(); - case ImageBase.typeKey: - return Image(); - case CubicDetachedVertexBase.typeKey: - return CubicDetachedVertex(); case EventBase.typeKey: return Event(); case DrawRulesBase.typeKey: @@ -491,7 +482,15 @@ class RiveCoreContext { } } + /// STOKANAL-FORK-EDIT static void setObjectProperty(Core object, int propertyKey, Object value) { + + switch (propertyKey) { + case LayoutComponentStyleBase.interpolatorIdPropertyKey: + (object as LayoutComponentStyleBase).interpolatorId = value as int; + return; + } + switch (propertyKey) { case ViewModelInstanceListItemBase.useLinkedArtboardPropertyKey: if (object is ViewModelInstanceListItemBase && value is bool) { @@ -548,16 +547,6 @@ class RiveCoreContext { object.viewModelReferenceId = value; } break; - case ComponentBase.namePropertyKey: - if (object is ComponentBase && value is String) { - object.name = value; - } - break; - case ComponentBase.parentIdPropertyKey: - if (object is ComponentBase && value is int) { - object.parentId = value; - } - break; case ViewModelInstanceBase.viewModelIdPropertyKey: if (object is ViewModelInstanceBase && value is int) { object.viewModelId = value; @@ -618,11 +607,6 @@ class RiveCoreContext { object.targetId = value; } break; - case DistanceConstraintBase.distancePropertyKey: - if (object is DistanceConstraintBase && value is double) { - object.distance = value; - } - break; case DistanceConstraintBase.modeValuePropertyKey: if (object is DistanceConstraintBase && value is int) { object.modeValue = value; @@ -743,36 +727,6 @@ class RiveCoreContext { object.originY = value; } break; - case WorldTransformComponentBase.opacityPropertyKey: - if (object is WorldTransformComponentBase && value is double) { - object.opacity = value; - } - break; - case TransformComponentBase.rotationPropertyKey: - if (object is TransformComponentBase && value is double) { - object.rotation = value; - } - break; - case TransformComponentBase.scaleXPropertyKey: - if (object is TransformComponentBase && value is double) { - object.scaleX = value; - } - break; - case TransformComponentBase.scaleYPropertyKey: - if (object is TransformComponentBase && value is double) { - object.scaleY = value; - } - break; - case NodeBase.xPropertyKey: - if (object is NodeBase && value is double) { - object.x = value; - } - break; - case NodeBase.yPropertyKey: - if (object is NodeBase && value is double) { - object.y = value; - } - break; case DrawableBase.blendModeValuePropertyKey: if (object is DrawableBase && value is int) { object.blendModeValue = value; @@ -808,11 +762,6 @@ class RiveCoreContext { object.animationId = value; } break; - case SoloBase.activeComponentIdPropertyKey: - if (object is SoloBase && value is int) { - object.activeComponentId = value; - } - break; case LayoutComponentStyleBase.gapHorizontalPropertyKey: if (object is LayoutComponentStyleBase && value is double) { object.gapHorizontal = value; @@ -968,11 +917,6 @@ class RiveCoreContext { object.interpolationType = value; } break; - case LayoutComponentStyleBase.interpolatorIdPropertyKey: - if (object is LayoutComponentStyleBase && value is int) { - object.interpolatorId = value; - } - break; case LayoutComponentStyleBase.interpolationTimePropertyKey: if (object is LayoutComponentStyleBase && value is double) { object.interpolationTime = value; @@ -1163,21 +1107,6 @@ class RiveCoreContext { object.flags = value; } break; - case KeyFrameBase.framePropertyKey: - if (object is KeyFrameBase && value is int) { - object.frame = value; - } - break; - case InterpolatingKeyFrameBase.interpolationTypePropertyKey: - if (object is InterpolatingKeyFrameBase && value is int) { - object.interpolationType = value; - } - break; - case InterpolatingKeyFrameBase.interpolatorIdPropertyKey: - if (object is InterpolatingKeyFrameBase && value is int) { - object.interpolatorId = value; - } - break; case KeyFrameUintBase.valuePropertyKey: if (object is KeyFrameUintBase && value is int) { object.value = value; @@ -1268,11 +1197,6 @@ class RiveCoreContext { object.inputId = value; } break; - case KeyedObjectBase.objectIdPropertyKey: - if (object is KeyedObjectBase && value is int) { - object.objectId = value; - } - break; case BlendAnimationBase.animationIdPropertyKey: if (object is BlendAnimationBase && value is int) { object.animationId = value; @@ -1323,16 +1247,6 @@ class RiveCoreContext { object.y2 = value; } break; - case TransitionInputConditionBase.inputIdPropertyKey: - if (object is TransitionInputConditionBase && value is int) { - object.inputId = value; - } - break; - case KeyedPropertyBase.propertyKeyPropertyKey: - if (object is KeyedPropertyBase && value is int) { - object.propertyKey = value; - } - break; case StateMachineListenerBase.targetIdPropertyKey: if (object is StateMachineListenerBase && value is int) { object.targetId = value; @@ -1473,11 +1387,6 @@ class RiveCoreContext { object.nestedValue = value; } break; - case KeyFrameDoubleBase.valuePropertyKey: - if (object is KeyFrameDoubleBase && value is double) { - object.value = value; - } - break; case KeyFrameColorBase.valuePropertyKey: if (object is KeyFrameColorBase && value is int) { object.value = value; @@ -1588,11 +1497,6 @@ class RiveCoreContext { object.opacity = value; } break; - case StrokeBase.thicknessPropertyKey: - if (object is StrokeBase && value is double) { - object.thickness = value; - } - break; case StrokeBase.capPropertyKey: if (object is StrokeBase && value is int) { object.cap = value; @@ -1608,21 +1512,6 @@ class RiveCoreContext { object.transformAffectsStroke = value; } break; - case SolidColorBase.colorValuePropertyKey: - if (object is SolidColorBase && value is int) { - object.colorValue = value; - } - break; - case GradientStopBase.colorValuePropertyKey: - if (object is GradientStopBase && value is int) { - object.colorValue = value; - } - break; - case GradientStopBase.positionPropertyKey: - if (object is GradientStopBase && value is double) { - object.position = value; - } - break; case TrimPathBase.startPropertyKey: if (object is TrimPathBase && value is double) { object.start = value; @@ -1648,16 +1537,6 @@ class RiveCoreContext { object.fillRule = value; } break; - case VertexBase.xPropertyKey: - if (object is VertexBase && value is double) { - object.x = value; - } - break; - case VertexBase.yPropertyKey: - if (object is VertexBase && value is double) { - object.y = value; - } - break; case MeshVertexBase.uPropertyKey: if (object is MeshVertexBase && value is double) { object.u = value; @@ -1683,11 +1562,6 @@ class RiveCoreContext { object.indices = value; } break; - case StraightVertexBase.radiusPropertyKey: - if (object is StraightVertexBase && value is double) { - object.radius = value; - } - break; case CubicWeightBase.inValuesPropertyKey: if (object is CubicWeightBase && value is int) { object.inValues = value; @@ -1708,21 +1582,6 @@ class RiveCoreContext { object.outIndices = value; } break; - case CubicAsymmetricVertexBase.rotationPropertyKey: - if (object is CubicAsymmetricVertexBase && value is double) { - object.rotation = value; - } - break; - case CubicAsymmetricVertexBase.inDistancePropertyKey: - if (object is CubicAsymmetricVertexBase && value is double) { - object.inDistance = value; - } - break; - case CubicAsymmetricVertexBase.outDistancePropertyKey: - if (object is CubicAsymmetricVertexBase && value is double) { - object.outDistance = value; - } - break; case MeshBase.triangleIndexBytesPropertyKey: if (object is MeshBase && value is Uint8List) { object.triangleIndexBytes = value; @@ -1778,16 +1637,6 @@ class RiveCoreContext { object.cornerRadiusBR = value; } break; - case CubicMirroredVertexBase.rotationPropertyKey: - if (object is CubicMirroredVertexBase && value is double) { - object.rotation = value; - } - break; - case CubicMirroredVertexBase.distancePropertyKey: - if (object is CubicMirroredVertexBase && value is double) { - object.distance = value; - } - break; case ClippingShapeBase.sourceIdPropertyKey: if (object is ClippingShapeBase && value is int) { object.sourceId = value; @@ -1833,31 +1682,6 @@ class RiveCoreContext { object.originY = value; } break; - case CubicDetachedVertexBase.inRotationPropertyKey: - if (object is CubicDetachedVertexBase && value is double) { - object.inRotation = value; - } - break; - case CubicDetachedVertexBase.inDistancePropertyKey: - if (object is CubicDetachedVertexBase && value is double) { - object.inDistance = value; - } - break; - case CubicDetachedVertexBase.outRotationPropertyKey: - if (object is CubicDetachedVertexBase && value is double) { - object.outRotation = value; - } - break; - case CubicDetachedVertexBase.outDistancePropertyKey: - if (object is CubicDetachedVertexBase && value is double) { - object.outDistance = value; - } - break; - case DrawRulesBase.drawTargetIdPropertyKey: - if (object is DrawRulesBase && value is int) { - object.drawTargetId = value; - } - break; case CustomPropertyBooleanBase.propertyValuePropertyKey: if (object is CustomPropertyBooleanBase && value is bool) { object.propertyValue = value; @@ -2393,8 +2217,12 @@ class RiveCoreContext { static CoreFieldType doubleType = CoreDoubleType(); static CoreFieldType bytesType = CoreBytesType(); static CoreFieldType callbackType = CoreCallbackType(); + + /// STOKANAL-FORK-EDIT static CoreFieldType? coreType(int propertyKey) { + switch (propertyKey) { + case ViewModelInstanceListItemBase.useLinkedArtboardPropertyKey: case ViewModelInstanceBooleanBase.propertyValuePropertyKey: case TransformComponentConstraintBase.offsetPropertyKey: @@ -2434,7 +2262,6 @@ class RiveCoreContext { case ViewModelInstanceEnumBase.propertyValuePropertyKey: case ViewModelBase.defaultInstanceIdPropertyKey: case ViewModelPropertyViewModelBase.viewModelReferenceIdPropertyKey: - case ComponentBase.parentIdPropertyKey: case ViewModelInstanceBase.viewModelIdPropertyKey: case ViewModelPropertyEnumBase.enumIdPropertyKey: case ViewModelInstanceViewModelBase.propertyValuePropertyKey: @@ -2452,11 +2279,9 @@ class RiveCoreContext { case NestedArtboardBase.fitPropertyKey: case NestedArtboardBase.alignmentPropertyKey: case NestedAnimationBase.animationIdPropertyKey: - case SoloBase.activeComponentIdPropertyKey: case LayoutComponentStyleBase.scaleTypePropertyKey: case LayoutComponentStyleBase.layoutAlignmentTypePropertyKey: case LayoutComponentStyleBase.animationStyleTypePropertyKey: - case LayoutComponentStyleBase.interpolationTypePropertyKey: case LayoutComponentStyleBase.interpolatorIdPropertyKey: case LayoutComponentStyleBase.displayValuePropertyKey: case LayoutComponentStyleBase.positionTypeValuePropertyKey: @@ -2494,9 +2319,6 @@ class RiveCoreContext { case LayoutComponentStyleBase.maxHeightUnitsValuePropertyKey: case ListenerFireEventBase.eventIdPropertyKey: case LayerStateBase.flagsPropertyKey: - case KeyFrameBase.framePropertyKey: - case InterpolatingKeyFrameBase.interpolationTypePropertyKey: - case InterpolatingKeyFrameBase.interpolatorIdPropertyKey: case KeyFrameUintBase.valuePropertyKey: case LinearAnimationBase.fpsPropertyKey: case LinearAnimationBase.durationPropertyKey: @@ -2507,12 +2329,9 @@ class RiveCoreContext { case ListenerInputChangeBase.nestedInputIdPropertyKey: case AnimationStateBase.animationIdPropertyKey: case NestedInputBase.inputIdPropertyKey: - case KeyedObjectBase.objectIdPropertyKey: case BlendAnimationBase.animationIdPropertyKey: case BlendAnimationDirectBase.inputIdPropertyKey: case BlendAnimationDirectBase.blendSourcePropertyKey: - case TransitionInputConditionBase.inputIdPropertyKey: - case KeyedPropertyBase.propertyKeyPropertyKey: case StateMachineListenerBase.targetIdPropertyKey: case StateMachineListenerBase.listenerTypeValuePropertyKey: case StateMachineListenerBase.eventIdPropertyKey: @@ -2551,7 +2370,6 @@ class RiveCoreContext { case ClippingShapeBase.fillRulePropertyKey: case PolygonBase.pointsPropertyKey: case ImageBase.assetIdPropertyKey: - case DrawRulesBase.drawTargetIdPropertyKey: case LayoutComponentBase.styleIdPropertyKey: case ArtboardBase.defaultStateMachineIdPropertyKey: case ArtboardBase.viewModelIdPropertyKey: @@ -2584,17 +2402,15 @@ class RiveCoreContext { case TextValueRunBase.styleIdPropertyKey: case FileAssetBase.assetIdPropertyKey: case AudioEventBase.assetIdPropertyKey: + case LayoutComponentStyleBase.interpolationTypePropertyKey: return uintType; case ViewModelInstanceColorBase.propertyValuePropertyKey: case KeyFrameColorBase.valuePropertyKey: case TransitionValueColorComparatorBase.valuePropertyKey: - case SolidColorBase.colorValuePropertyKey: - case GradientStopBase.colorValuePropertyKey: case BindablePropertyColorBase.propertyValuePropertyKey: return colorType; case ViewModelComponentBase.namePropertyKey: case ViewModelInstanceStringBase.propertyValuePropertyKey: - case ComponentBase.namePropertyKey: case DataEnumValueBase.keyPropertyKey: case DataEnumValueBase.valuePropertyKey: case AnimationBase.namePropertyKey: @@ -2612,7 +2428,6 @@ class RiveCoreContext { case ViewModelInstanceNumberBase.propertyValuePropertyKey: case CustomPropertyNumberBase.propertyValuePropertyKey: case ConstraintBase.strengthPropertyKey: - case DistanceConstraintBase.distancePropertyKey: case TransformComponentConstraintBase.copyFactorPropertyKey: case TransformComponentConstraintBase.minValuePropertyKey: case TransformComponentConstraintBase.maxValuePropertyKey: @@ -2622,12 +2437,6 @@ class RiveCoreContext { case FollowPathConstraintBase.distancePropertyKey: case TransformConstraintBase.originXPropertyKey: case TransformConstraintBase.originYPropertyKey: - case WorldTransformComponentBase.opacityPropertyKey: - case TransformComponentBase.rotationPropertyKey: - case TransformComponentBase.scaleXPropertyKey: - case TransformComponentBase.scaleYPropertyKey: - case NodeBase.xPropertyKey: - case NodeBase.yPropertyKey: case LayoutComponentStyleBase.gapHorizontalPropertyKey: case LayoutComponentStyleBase.gapVerticalPropertyKey: case LayoutComponentStyleBase.maxWidthPropertyKey: @@ -2672,7 +2481,6 @@ class RiveCoreContext { case CubicInterpolatorComponentBase.x2PropertyKey: case CubicInterpolatorComponentBase.y2PropertyKey: case ListenerNumberChangeBase.valuePropertyKey: - case KeyFrameDoubleBase.valuePropertyKey: case TransitionValueNumberComparatorBase.valuePropertyKey: case ElasticInterpolatorBase.amplitudePropertyKey: case ElasticInterpolatorBase.periodPropertyKey: @@ -2684,19 +2492,11 @@ class RiveCoreContext { case LinearGradientBase.endXPropertyKey: case LinearGradientBase.endYPropertyKey: case LinearGradientBase.opacityPropertyKey: - case StrokeBase.thicknessPropertyKey: - case GradientStopBase.positionPropertyKey: case TrimPathBase.startPropertyKey: case TrimPathBase.endPropertyKey: case TrimPathBase.offsetPropertyKey: - case VertexBase.xPropertyKey: - case VertexBase.yPropertyKey: case MeshVertexBase.uPropertyKey: case MeshVertexBase.vPropertyKey: - case StraightVertexBase.radiusPropertyKey: - case CubicAsymmetricVertexBase.rotationPropertyKey: - case CubicAsymmetricVertexBase.inDistancePropertyKey: - case CubicAsymmetricVertexBase.outDistancePropertyKey: case ParametricPathBase.widthPropertyKey: case ParametricPathBase.heightPropertyKey: case ParametricPathBase.originXPropertyKey: @@ -2705,16 +2505,10 @@ class RiveCoreContext { case RectangleBase.cornerRadiusTRPropertyKey: case RectangleBase.cornerRadiusBLPropertyKey: case RectangleBase.cornerRadiusBRPropertyKey: - case CubicMirroredVertexBase.rotationPropertyKey: - case CubicMirroredVertexBase.distancePropertyKey: case PolygonBase.cornerRadiusPropertyKey: case StarBase.innerRadiusPropertyKey: case ImageBase.originXPropertyKey: case ImageBase.originYPropertyKey: - case CubicDetachedVertexBase.inRotationPropertyKey: - case CubicDetachedVertexBase.inDistancePropertyKey: - case CubicDetachedVertexBase.outRotationPropertyKey: - case CubicDetachedVertexBase.outDistancePropertyKey: case LayoutComponentBase.widthPropertyKey: case LayoutComponentBase.heightPropertyKey: case ArtboardBase.xPropertyKey: @@ -2787,16 +2581,6 @@ class RiveCoreContext { } } - static bool isCallback(int propertyKey) { - switch (propertyKey) { - case NestedTriggerBase.firePropertyKey: - case EventBase.triggerPropertyKey: - return true; - default: - return false; - } - } - static bool getBool(Core object, int propertyKey) { switch (propertyKey) { case ViewModelInstanceListItemBase.useLinkedArtboardPropertyKey: @@ -2866,6 +2650,7 @@ class RiveCoreContext { } static int getUint(Core object, int propertyKey) { + switch (propertyKey) { case ViewModelInstanceListItemBase.viewModelIdPropertyKey: return (object as ViewModelInstanceListItemBase).viewModelId; @@ -2881,8 +2666,6 @@ class RiveCoreContext { return (object as ViewModelBase).defaultInstanceId; case ViewModelPropertyViewModelBase.viewModelReferenceIdPropertyKey: return (object as ViewModelPropertyViewModelBase).viewModelReferenceId; - case ComponentBase.parentIdPropertyKey: - return (object as ComponentBase).parentId; case ViewModelInstanceBase.viewModelIdPropertyKey: return (object as ViewModelInstanceBase).viewModelId; case ViewModelPropertyEnumBase.enumIdPropertyKey: @@ -2908,7 +2691,7 @@ class RiveCoreContext { case DrawableBase.blendModeValuePropertyKey: return (object as DrawableBase).blendModeValue; case DrawableBase.drawableFlagsPropertyKey: - return (object as DrawableBase).drawableFlags; + return (object as DrawableBase).drawableFlags_; case NestedArtboardBase.artboardIdPropertyKey: return (object as NestedArtboardBase).artboardId; case NestedArtboardBase.fitPropertyKey: @@ -2917,8 +2700,6 @@ class RiveCoreContext { return (object as NestedArtboardBase).alignment; case NestedAnimationBase.animationIdPropertyKey: return (object as NestedAnimationBase).animationId; - case SoloBase.activeComponentIdPropertyKey: - return (object as SoloBase).activeComponentId; case LayoutComponentStyleBase.scaleTypePropertyKey: return (object as LayoutComponentStyleBase).scaleType; case LayoutComponentStyleBase.layoutAlignmentTypePropertyKey: @@ -3001,12 +2782,6 @@ class RiveCoreContext { return (object as ListenerFireEventBase).eventId; case LayerStateBase.flagsPropertyKey: return (object as LayerStateBase).flags; - case KeyFrameBase.framePropertyKey: - return (object as KeyFrameBase).frame; - case InterpolatingKeyFrameBase.interpolationTypePropertyKey: - return (object as InterpolatingKeyFrameBase).interpolationType; - case InterpolatingKeyFrameBase.interpolatorIdPropertyKey: - return (object as InterpolatingKeyFrameBase).interpolatorId; case KeyFrameUintBase.valuePropertyKey: return (object as KeyFrameUintBase).value; case LinearAnimationBase.fpsPropertyKey: @@ -3027,18 +2802,12 @@ class RiveCoreContext { return (object as AnimationStateBase).animationId; case NestedInputBase.inputIdPropertyKey: return (object as NestedInputBase).inputId; - case KeyedObjectBase.objectIdPropertyKey: - return (object as KeyedObjectBase).objectId; case BlendAnimationBase.animationIdPropertyKey: return (object as BlendAnimationBase).animationId; case BlendAnimationDirectBase.inputIdPropertyKey: return (object as BlendAnimationDirectBase).inputId; case BlendAnimationDirectBase.blendSourcePropertyKey: return (object as BlendAnimationDirectBase).blendSource; - case TransitionInputConditionBase.inputIdPropertyKey: - return (object as TransitionInputConditionBase).inputId; - case KeyedPropertyBase.propertyKeyPropertyKey: - return (object as KeyedPropertyBase).propertyKey; case StateMachineListenerBase.targetIdPropertyKey: return (object as StateMachineListenerBase).targetId; case StateMachineListenerBase.listenerTypeValuePropertyKey: @@ -3115,8 +2884,6 @@ class RiveCoreContext { return (object as PolygonBase).points; case ImageBase.assetIdPropertyKey: return (object as ImageBase).assetId; - case DrawRulesBase.drawTargetIdPropertyKey: - return (object as DrawRulesBase).drawTargetId; case LayoutComponentBase.styleIdPropertyKey: return (object as LayoutComponentBase).styleId; case ArtboardBase.defaultStateMachineIdPropertyKey: @@ -3186,6 +2953,7 @@ class RiveCoreContext { } static int getColor(Core object, int propertyKey) { + switch (propertyKey) { case ViewModelInstanceColorBase.propertyValuePropertyKey: return (object as ViewModelInstanceColorBase).propertyValue; @@ -3193,10 +2961,6 @@ class RiveCoreContext { return (object as KeyFrameColorBase).value; case TransitionValueColorComparatorBase.valuePropertyKey: return (object as TransitionValueColorComparatorBase).value; - case SolidColorBase.colorValuePropertyKey: - return (object as SolidColorBase).colorValue; - case GradientStopBase.colorValuePropertyKey: - return (object as GradientStopBase).colorValue; case BindablePropertyColorBase.propertyValuePropertyKey: return (object as BindablePropertyColorBase).propertyValue; } @@ -3204,13 +2968,12 @@ class RiveCoreContext { } static String getString(Core object, int propertyKey) { + switch (propertyKey) { case ViewModelComponentBase.namePropertyKey: return (object as ViewModelComponentBase).name; case ViewModelInstanceStringBase.propertyValuePropertyKey: return (object as ViewModelInstanceStringBase).propertyValue; - case ComponentBase.namePropertyKey: - return (object as ComponentBase).name; case DataEnumValueBase.keyPropertyKey: return (object as DataEnumValueBase).key; case DataEnumValueBase.valuePropertyKey: @@ -3241,7 +3004,9 @@ class RiveCoreContext { return ''; } + /// STOKANAL-FORK-EDIT static double getDouble(Core object, int propertyKey) { + switch (propertyKey) { case ViewModelInstanceNumberBase.propertyValuePropertyKey: return (object as ViewModelInstanceNumberBase).propertyValue; @@ -3249,8 +3014,6 @@ class RiveCoreContext { return (object as CustomPropertyNumberBase).propertyValue; case ConstraintBase.strengthPropertyKey: return (object as ConstraintBase).strength; - case DistanceConstraintBase.distancePropertyKey: - return (object as DistanceConstraintBase).distance; case TransformComponentConstraintBase.copyFactorPropertyKey: return (object as TransformComponentConstraintBase).copyFactor; case TransformComponentConstraintBase.minValuePropertyKey: @@ -3269,18 +3032,6 @@ class RiveCoreContext { return (object as TransformConstraintBase).originX; case TransformConstraintBase.originYPropertyKey: return (object as TransformConstraintBase).originY; - case WorldTransformComponentBase.opacityPropertyKey: - return (object as WorldTransformComponentBase).opacity; - case TransformComponentBase.rotationPropertyKey: - return (object as TransformComponentBase).rotation; - case TransformComponentBase.scaleXPropertyKey: - return (object as TransformComponentBase).scaleX; - case TransformComponentBase.scaleYPropertyKey: - return (object as TransformComponentBase).scaleY; - case NodeBase.xPropertyKey: - return (object as NodeBase).x; - case NodeBase.yPropertyKey: - return (object as NodeBase).y; case LayoutComponentStyleBase.gapHorizontalPropertyKey: return (object as LayoutComponentStyleBase).gapHorizontal; case LayoutComponentStyleBase.gapVerticalPropertyKey: @@ -3301,6 +3052,9 @@ class RiveCoreContext { return (object as LayoutComponentStyleBase).borderTop; case LayoutComponentStyleBase.borderBottomPropertyKey: return (object as LayoutComponentStyleBase).borderBottom; + } + + switch (propertyKey) { case LayoutComponentStyleBase.marginLeftPropertyKey: return (object as LayoutComponentStyleBase).marginLeft; case LayoutComponentStyleBase.marginRightPropertyKey: @@ -3369,8 +3123,6 @@ class RiveCoreContext { return (object as CubicInterpolatorComponentBase).y2; case ListenerNumberChangeBase.valuePropertyKey: return (object as ListenerNumberChangeBase).value; - case KeyFrameDoubleBase.valuePropertyKey: - return (object as KeyFrameDoubleBase).value; case TransitionValueNumberComparatorBase.valuePropertyKey: return (object as TransitionValueNumberComparatorBase).value; case ElasticInterpolatorBase.amplitudePropertyKey: @@ -3393,32 +3145,16 @@ class RiveCoreContext { return (object as LinearGradientBase).endY; case LinearGradientBase.opacityPropertyKey: return (object as LinearGradientBase).opacity; - case StrokeBase.thicknessPropertyKey: - return (object as StrokeBase).thickness; - case GradientStopBase.positionPropertyKey: - return (object as GradientStopBase).position; case TrimPathBase.startPropertyKey: return (object as TrimPathBase).start; case TrimPathBase.endPropertyKey: return (object as TrimPathBase).end; case TrimPathBase.offsetPropertyKey: return (object as TrimPathBase).offset; - case VertexBase.xPropertyKey: - return (object as VertexBase).x; - case VertexBase.yPropertyKey: - return (object as VertexBase).y; case MeshVertexBase.uPropertyKey: return (object as MeshVertexBase).u; case MeshVertexBase.vPropertyKey: return (object as MeshVertexBase).v; - case StraightVertexBase.radiusPropertyKey: - return (object as StraightVertexBase).radius; - case CubicAsymmetricVertexBase.rotationPropertyKey: - return (object as CubicAsymmetricVertexBase).rotation; - case CubicAsymmetricVertexBase.inDistancePropertyKey: - return (object as CubicAsymmetricVertexBase).inDistance; - case CubicAsymmetricVertexBase.outDistancePropertyKey: - return (object as CubicAsymmetricVertexBase).outDistance; case ParametricPathBase.widthPropertyKey: return (object as ParametricPathBase).width; case ParametricPathBase.heightPropertyKey: @@ -3435,10 +3171,6 @@ class RiveCoreContext { return (object as RectangleBase).cornerRadiusBL; case RectangleBase.cornerRadiusBRPropertyKey: return (object as RectangleBase).cornerRadiusBR; - case CubicMirroredVertexBase.rotationPropertyKey: - return (object as CubicMirroredVertexBase).rotation; - case CubicMirroredVertexBase.distancePropertyKey: - return (object as CubicMirroredVertexBase).distance; case PolygonBase.cornerRadiusPropertyKey: return (object as PolygonBase).cornerRadius; case StarBase.innerRadiusPropertyKey: @@ -3447,14 +3179,6 @@ class RiveCoreContext { return (object as ImageBase).originX; case ImageBase.originYPropertyKey: return (object as ImageBase).originY; - case CubicDetachedVertexBase.inRotationPropertyKey: - return (object as CubicDetachedVertexBase).inRotation; - case CubicDetachedVertexBase.inDistancePropertyKey: - return (object as CubicDetachedVertexBase).inDistance; - case CubicDetachedVertexBase.outRotationPropertyKey: - return (object as CubicDetachedVertexBase).outRotation; - case CubicDetachedVertexBase.outDistancePropertyKey: - return (object as CubicDetachedVertexBase).outDistance; case LayoutComponentBase.widthPropertyKey: return (object as LayoutComponentBase).width; case LayoutComponentBase.heightPropertyKey: @@ -3574,6 +3298,7 @@ class RiveCoreContext { } static Uint8List getBytes(Core object, int propertyKey) { + switch (propertyKey) { case NestedArtboardBase.dataBindPathIdsPropertyKey: return (object as NestedArtboardBase).dataBindPathIds; @@ -3589,8 +3314,18 @@ class RiveCoreContext { return Uint8List(0); } + /// STOKANAL-FORK-EDIT static void setBool(Core object, int propertyKey, bool value) { + switch (propertyKey) { + + case NestedSimpleAnimationBase.isPlayingPropertyKey: + (object as NestedSimpleAnimationBase).isPlaying = value; + // if (object is NestedSimpleAnimationBase) { + // object.isPlaying = value; + // } + break; + case ViewModelInstanceListItemBase.useLinkedArtboardPropertyKey: if (object is ViewModelInstanceListItemBase) { object.useLinkedArtboard = value; @@ -3666,11 +3401,6 @@ class RiveCoreContext { object.quantize = value; } break; - case NestedSimpleAnimationBase.isPlayingPropertyKey: - if (object is NestedSimpleAnimationBase) { - object.isPlaying = value; - } - break; case KeyFrameBoolBase.valuePropertyKey: if (object is KeyFrameBoolBase) { object.value = value; @@ -3749,8 +3479,11 @@ class RiveCoreContext { } } + /// STOKANAL-FORK-EDIT static void setUint(Core object, int propertyKey, int value) { + switch (propertyKey) { + case ViewModelInstanceListItemBase.viewModelIdPropertyKey: if (object is ViewModelInstanceListItemBase) { object.viewModelId = value; @@ -3786,11 +3519,6 @@ class RiveCoreContext { object.viewModelReferenceId = value; } break; - case ComponentBase.parentIdPropertyKey: - if (object is ComponentBase) { - object.parentId = value; - } - break; case ViewModelInstanceBase.viewModelIdPropertyKey: if (object is ViewModelInstanceBase) { object.viewModelId = value; @@ -3876,11 +3604,6 @@ class RiveCoreContext { object.animationId = value; } break; - case SoloBase.activeComponentIdPropertyKey: - if (object is SoloBase) { - object.activeComponentId = value; - } - break; case LayoutComponentStyleBase.scaleTypePropertyKey: if (object is LayoutComponentStyleBase) { object.scaleType = value; @@ -4086,21 +3809,6 @@ class RiveCoreContext { object.flags = value; } break; - case KeyFrameBase.framePropertyKey: - if (object is KeyFrameBase) { - object.frame = value; - } - break; - case InterpolatingKeyFrameBase.interpolationTypePropertyKey: - if (object is InterpolatingKeyFrameBase) { - object.interpolationType = value; - } - break; - case InterpolatingKeyFrameBase.interpolatorIdPropertyKey: - if (object is InterpolatingKeyFrameBase) { - object.interpolatorId = value; - } - break; case KeyFrameUintBase.valuePropertyKey: if (object is KeyFrameUintBase) { object.value = value; @@ -4151,11 +3859,6 @@ class RiveCoreContext { object.inputId = value; } break; - case KeyedObjectBase.objectIdPropertyKey: - if (object is KeyedObjectBase) { - object.objectId = value; - } - break; case BlendAnimationBase.animationIdPropertyKey: if (object is BlendAnimationBase) { object.animationId = value; @@ -4171,16 +3874,6 @@ class RiveCoreContext { object.blendSource = value; } break; - case TransitionInputConditionBase.inputIdPropertyKey: - if (object is TransitionInputConditionBase) { - object.inputId = value; - } - break; - case KeyedPropertyBase.propertyKeyPropertyKey: - if (object is KeyedPropertyBase) { - object.propertyKey = value; - } - break; case StateMachineListenerBase.targetIdPropertyKey: if (object is StateMachineListenerBase) { object.targetId = value; @@ -4371,11 +4064,6 @@ class RiveCoreContext { object.assetId = value; } break; - case DrawRulesBase.drawTargetIdPropertyKey: - if (object is DrawRulesBase) { - object.drawTargetId = value; - } - break; case LayoutComponentBase.styleIdPropertyKey: if (object is LayoutComponentBase) { object.styleId = value; @@ -4539,7 +4227,10 @@ class RiveCoreContext { } } + /// STOKANAL-FORK-EDIT static void setColor(Core object, int propertyKey, int value) { + + // reordered switch (propertyKey) { case ViewModelInstanceColorBase.propertyValuePropertyKey: if (object is ViewModelInstanceColorBase) { @@ -4556,16 +4247,6 @@ class RiveCoreContext { object.value = value; } break; - case SolidColorBase.colorValuePropertyKey: - if (object is SolidColorBase) { - object.colorValue = value; - } - break; - case GradientStopBase.colorValuePropertyKey: - if (object is GradientStopBase) { - object.colorValue = value; - } - break; case BindablePropertyColorBase.propertyValuePropertyKey: if (object is BindablePropertyColorBase) { object.propertyValue = value; @@ -4575,6 +4256,7 @@ class RiveCoreContext { } static void setString(Core object, int propertyKey, String value) { + switch (propertyKey) { case ViewModelComponentBase.namePropertyKey: if (object is ViewModelComponentBase) { @@ -4586,11 +4268,6 @@ class RiveCoreContext { object.propertyValue = value; } break; - case ComponentBase.namePropertyKey: - if (object is ComponentBase) { - object.name = value; - } - break; case DataEnumValueBase.keyPropertyKey: if (object is DataEnumValueBase) { object.key = value; @@ -4659,7 +4336,9 @@ class RiveCoreContext { } } + /// STOKANAL-FORK-EDIT static void setDouble(Core object, int propertyKey, double value) { + switch (propertyKey) { case ViewModelInstanceNumberBase.propertyValuePropertyKey: if (object is ViewModelInstanceNumberBase) { @@ -4676,11 +4355,6 @@ class RiveCoreContext { object.strength = value; } break; - case DistanceConstraintBase.distancePropertyKey: - if (object is DistanceConstraintBase) { - object.distance = value; - } - break; case TransformComponentConstraintBase.copyFactorPropertyKey: if (object is TransformComponentConstraintBase) { object.copyFactor = value; @@ -4726,36 +4400,6 @@ class RiveCoreContext { object.originY = value; } break; - case WorldTransformComponentBase.opacityPropertyKey: - if (object is WorldTransformComponentBase) { - object.opacity = value; - } - break; - case TransformComponentBase.rotationPropertyKey: - if (object is TransformComponentBase) { - object.rotation = value; - } - break; - case TransformComponentBase.scaleXPropertyKey: - if (object is TransformComponentBase) { - object.scaleX = value; - } - break; - case TransformComponentBase.scaleYPropertyKey: - if (object is TransformComponentBase) { - object.scaleY = value; - } - break; - case NodeBase.xPropertyKey: - if (object is NodeBase) { - object.x = value; - } - break; - case NodeBase.yPropertyKey: - if (object is NodeBase) { - object.y = value; - } - break; case LayoutComponentStyleBase.gapHorizontalPropertyKey: if (object is LayoutComponentStyleBase) { object.gapHorizontal = value; @@ -4976,11 +4620,6 @@ class RiveCoreContext { object.value = value; } break; - case KeyFrameDoubleBase.valuePropertyKey: - if (object is KeyFrameDoubleBase) { - object.value = value; - } - break; case TransitionValueNumberComparatorBase.valuePropertyKey: if (object is TransitionValueNumberComparatorBase) { object.value = value; @@ -5036,16 +4675,6 @@ class RiveCoreContext { object.opacity = value; } break; - case StrokeBase.thicknessPropertyKey: - if (object is StrokeBase) { - object.thickness = value; - } - break; - case GradientStopBase.positionPropertyKey: - if (object is GradientStopBase) { - object.position = value; - } - break; case TrimPathBase.startPropertyKey: if (object is TrimPathBase) { object.start = value; @@ -5061,16 +4690,6 @@ class RiveCoreContext { object.offset = value; } break; - case VertexBase.xPropertyKey: - if (object is VertexBase) { - object.x = value; - } - break; - case VertexBase.yPropertyKey: - if (object is VertexBase) { - object.y = value; - } - break; case MeshVertexBase.uPropertyKey: if (object is MeshVertexBase) { object.u = value; @@ -5081,26 +4700,6 @@ class RiveCoreContext { object.v = value; } break; - case StraightVertexBase.radiusPropertyKey: - if (object is StraightVertexBase) { - object.radius = value; - } - break; - case CubicAsymmetricVertexBase.rotationPropertyKey: - if (object is CubicAsymmetricVertexBase) { - object.rotation = value; - } - break; - case CubicAsymmetricVertexBase.inDistancePropertyKey: - if (object is CubicAsymmetricVertexBase) { - object.inDistance = value; - } - break; - case CubicAsymmetricVertexBase.outDistancePropertyKey: - if (object is CubicAsymmetricVertexBase) { - object.outDistance = value; - } - break; case ParametricPathBase.widthPropertyKey: if (object is ParametricPathBase) { object.width = value; @@ -5141,16 +4740,6 @@ class RiveCoreContext { object.cornerRadiusBR = value; } break; - case CubicMirroredVertexBase.rotationPropertyKey: - if (object is CubicMirroredVertexBase) { - object.rotation = value; - } - break; - case CubicMirroredVertexBase.distancePropertyKey: - if (object is CubicMirroredVertexBase) { - object.distance = value; - } - break; case PolygonBase.cornerRadiusPropertyKey: if (object is PolygonBase) { object.cornerRadius = value; @@ -5171,26 +4760,6 @@ class RiveCoreContext { object.originY = value; } break; - case CubicDetachedVertexBase.inRotationPropertyKey: - if (object is CubicDetachedVertexBase) { - object.inRotation = value; - } - break; - case CubicDetachedVertexBase.inDistancePropertyKey: - if (object is CubicDetachedVertexBase) { - object.inDistance = value; - } - break; - case CubicDetachedVertexBase.outRotationPropertyKey: - if (object is CubicDetachedVertexBase) { - object.outRotation = value; - } - break; - case CubicDetachedVertexBase.outDistancePropertyKey: - if (object is CubicDetachedVertexBase) { - object.outDistance = value; - } - break; case LayoutComponentBase.widthPropertyKey: if (object is LayoutComponentBase) { object.width = value; diff --git a/lib/src/generated/shapes/cubic_asymmetric_vertex_base.dart b/lib/src/generated/shapes/cubic_asymmetric_vertex_base.dart index 216364bd..c51d5ed4 100644 --- a/lib/src/generated/shapes/cubic_asymmetric_vertex_base.dart +++ b/lib/src/generated/shapes/cubic_asymmetric_vertex_base.dart @@ -9,37 +9,43 @@ import 'package:rive/src/generated/shapes/path_vertex_base.dart'; import 'package:rive/src/generated/shapes/vertex_base.dart'; import 'package:rive/src/rive_core/shapes/cubic_vertex.dart'; +const _coreTypes = { + CubicAsymmetricVertexBase.typeKey, + CubicVertexBase.typeKey, + PathVertexBase.typeKey, + VertexBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class CubicAsymmetricVertexBase extends CubicVertex { static const int typeKey = 34; @override int get coreType => CubicAsymmetricVertexBase.typeKey; @override - Set get coreTypes => { - CubicAsymmetricVertexBase.typeKey, - CubicVertexBase.typeKey, - PathVertexBase.typeKey, - VertexBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Rotation field with key 79. static const int rotationPropertyKey = 79; static const double rotationInitialValue = 0; - double _rotation = rotationInitialValue; + + @nonVirtual + double rotation_ = rotationInitialValue; /// The control points' angle. - double get rotation => _rotation; + @nonVirtual + double get rotation => rotation_; - /// Change the [_rotation] field value. + /// Change the [rotation_] field value. /// [rotationChanged] will be invoked only if the field's value has changed. + @nonVirtual set rotation(double value) { - if (_rotation == value) { + if (rotation_ == value) { return; } - double from = _rotation; - _rotation = value; + double from = rotation_; + rotation_ = value; if (hasValidated) { rotationChanged(from, value); } @@ -51,19 +57,23 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex { /// InDistance field with key 80. static const int inDistancePropertyKey = 80; static const double inDistanceInitialValue = 0; - double _inDistance = inDistanceInitialValue; + + @nonVirtual + double inDistance_ = inDistanceInitialValue; /// The in point's distance from the translation of the point. - double get inDistance => _inDistance; + @nonVirtual + double get inDistance => inDistance_; - /// Change the [_inDistance] field value. + /// Change the [inDistance_] field value. /// [inDistanceChanged] will be invoked only if the field's value has changed. + @nonVirtual set inDistance(double value) { - if (_inDistance == value) { + if (inDistance_ == value) { return; } - double from = _inDistance; - _inDistance = value; + double from = inDistance_; + inDistance_ = value; if (hasValidated) { inDistanceChanged(from, value); } @@ -75,20 +85,23 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex { /// OutDistance field with key 81. static const int outDistancePropertyKey = 81; static const double outDistanceInitialValue = 0; - double _outDistance = outDistanceInitialValue; + + @nonVirtual + double outDistance_ = outDistanceInitialValue; /// The out point's distance from the translation of the point. - double get outDistance => _outDistance; + @nonVirtual + double get outDistance => outDistance_; - /// Change the [_outDistance] field value. + /// Change the [outDistance_] field value. /// [outDistanceChanged] will be invoked only if the field's value has /// changed. set outDistance(double value) { - if (_outDistance == value) { + if (outDistance_ == value) { return; } - double from = _outDistance; - _outDistance = value; + double from = outDistance_; + outDistance_ = value; if (hasValidated) { outDistanceChanged(from, value); } @@ -100,9 +113,9 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex { void copy(Core source) { super.copy(source); if (source is CubicAsymmetricVertexBase) { - _rotation = source._rotation; - _inDistance = source._inDistance; - _outDistance = source._outDistance; + rotation_ = source.rotation_; + inDistance_ = source.inDistance_; + outDistance_ = source.outDistance_; } } } diff --git a/lib/src/generated/shapes/cubic_detached_vertex_base.dart b/lib/src/generated/shapes/cubic_detached_vertex_base.dart index 8e44fc9e..a92ff58f 100644 --- a/lib/src/generated/shapes/cubic_detached_vertex_base.dart +++ b/lib/src/generated/shapes/cubic_detached_vertex_base.dart @@ -9,37 +9,43 @@ import 'package:rive/src/generated/shapes/path_vertex_base.dart'; import 'package:rive/src/generated/shapes/vertex_base.dart'; import 'package:rive/src/rive_core/shapes/cubic_vertex.dart'; +const _coreTypes = { + CubicDetachedVertexBase.typeKey, + CubicVertexBase.typeKey, + PathVertexBase.typeKey, + VertexBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class CubicDetachedVertexBase extends CubicVertex { static const int typeKey = 6; @override int get coreType => CubicDetachedVertexBase.typeKey; @override - Set get coreTypes => { - CubicDetachedVertexBase.typeKey, - CubicVertexBase.typeKey, - PathVertexBase.typeKey, - VertexBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// InRotation field with key 84. static const int inRotationPropertyKey = 84; static const double inRotationInitialValue = 0; - double _inRotation = inRotationInitialValue; + + @nonVirtual + double inRotation_ = inRotationInitialValue; /// The in point's angle. - double get inRotation => _inRotation; + @nonVirtual + double get inRotation => inRotation_; - /// Change the [_inRotation] field value. + /// Change the [inRotation_] field value. /// [inRotationChanged] will be invoked only if the field's value has changed. + @nonVirtual set inRotation(double value) { - if (_inRotation == value) { + if (inRotation_ == value) { return; } - double from = _inRotation; - _inRotation = value; + double from = inRotation_; + inRotation_ = value; if (hasValidated) { inRotationChanged(from, value); } @@ -51,19 +57,23 @@ abstract class CubicDetachedVertexBase extends CubicVertex { /// InDistance field with key 85. static const int inDistancePropertyKey = 85; static const double inDistanceInitialValue = 0; - double _inDistance = inDistanceInitialValue; + + @nonVirtual + double inDistance_ = inDistanceInitialValue; /// The in point's distance from the translation of the point. - double get inDistance => _inDistance; + @nonVirtual + double get inDistance => inDistance_; - /// Change the [_inDistance] field value. + /// Change the [inDistance_] field value. /// [inDistanceChanged] will be invoked only if the field's value has changed. + @nonVirtual set inDistance(double value) { - if (_inDistance == value) { + if (inDistance_ == value) { return; } - double from = _inDistance; - _inDistance = value; + double from = inDistance_; + inDistance_ = value; if (hasValidated) { inDistanceChanged(from, value); } @@ -75,20 +85,24 @@ abstract class CubicDetachedVertexBase extends CubicVertex { /// OutRotation field with key 86. static const int outRotationPropertyKey = 86; static const double outRotationInitialValue = 0; - double _outRotation = outRotationInitialValue; + + @nonVirtual + double outRotation_ = outRotationInitialValue; /// The out point's angle. - double get outRotation => _outRotation; + @nonVirtual + double get outRotation => outRotation_; - /// Change the [_outRotation] field value. + /// Change the [outRotation_] field value. /// [outRotationChanged] will be invoked only if the field's value has /// changed. + @nonVirtual set outRotation(double value) { - if (_outRotation == value) { + if (outRotation_ == value) { return; } - double from = _outRotation; - _outRotation = value; + double from = outRotation_; + outRotation_ = value; if (hasValidated) { outRotationChanged(from, value); } @@ -100,20 +114,24 @@ abstract class CubicDetachedVertexBase extends CubicVertex { /// OutDistance field with key 87. static const int outDistancePropertyKey = 87; static const double outDistanceInitialValue = 0; - double _outDistance = outDistanceInitialValue; + + @nonVirtual + double outDistance_ = outDistanceInitialValue; /// The out point's distance from the translation of the point. - double get outDistance => _outDistance; + @nonVirtual + double get outDistance => outDistance_; - /// Change the [_outDistance] field value. + /// Change the [outDistance_] field value. /// [outDistanceChanged] will be invoked only if the field's value has /// changed. + @nonVirtual set outDistance(double value) { - if (_outDistance == value) { + if (outDistance_ == value) { return; } - double from = _outDistance; - _outDistance = value; + double from = outDistance_; + outDistance_ = value; if (hasValidated) { outDistanceChanged(from, value); } @@ -125,10 +143,10 @@ abstract class CubicDetachedVertexBase extends CubicVertex { void copy(Core source) { super.copy(source); if (source is CubicDetachedVertexBase) { - _inRotation = source._inRotation; - _inDistance = source._inDistance; - _outRotation = source._outRotation; - _outDistance = source._outDistance; + inRotation_ = source.inRotation_; + inDistance_ = source.inDistance_; + outRotation_ = source.outRotation_; + outDistance_ = source.outDistance_; } } } diff --git a/lib/src/generated/shapes/cubic_mirrored_vertex_base.dart b/lib/src/generated/shapes/cubic_mirrored_vertex_base.dart index 4a0b68cb..17ad525e 100644 --- a/lib/src/generated/shapes/cubic_mirrored_vertex_base.dart +++ b/lib/src/generated/shapes/cubic_mirrored_vertex_base.dart @@ -9,37 +9,42 @@ import 'package:rive/src/generated/shapes/path_vertex_base.dart'; import 'package:rive/src/generated/shapes/vertex_base.dart'; import 'package:rive/src/rive_core/shapes/cubic_vertex.dart'; +const _coreTypes = { + CubicMirroredVertexBase.typeKey, + CubicVertexBase.typeKey, + PathVertexBase.typeKey, + VertexBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class CubicMirroredVertexBase extends CubicVertex { static const int typeKey = 35; @override int get coreType => CubicMirroredVertexBase.typeKey; @override - Set get coreTypes => { - CubicMirroredVertexBase.typeKey, - CubicVertexBase.typeKey, - PathVertexBase.typeKey, - VertexBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Rotation field with key 82. static const int rotationPropertyKey = 82; static const double rotationInitialValue = 0; - double _rotation = rotationInitialValue; + + @nonVirtual + double rotation_ = rotationInitialValue; /// The control points' angle. - double get rotation => _rotation; + @nonVirtual + double get rotation => rotation_; - /// Change the [_rotation] field value. + /// Change the [rotation_] field value. /// [rotationChanged] will be invoked only if the field's value has changed. set rotation(double value) { - if (_rotation == value) { + if (rotation_ == value) { return; } - double from = _rotation; - _rotation = value; + double from = rotation_; + rotation_ = value; if (hasValidated) { rotationChanged(from, value); } @@ -51,19 +56,22 @@ abstract class CubicMirroredVertexBase extends CubicVertex { /// Distance field with key 83. static const int distancePropertyKey = 83; static const double distanceInitialValue = 0; - double _distance = distanceInitialValue; + + @nonVirtual + double distance_ = distanceInitialValue; /// The control points' distance from the translation of the point. - double get distance => _distance; + @nonVirtual + double get distance => distance_; - /// Change the [_distance] field value. + /// Change the [distance_] field value. /// [distanceChanged] will be invoked only if the field's value has changed. set distance(double value) { - if (_distance == value) { + if (distance_ == value) { return; } - double from = _distance; - _distance = value; + double from = distance_; + distance_ = value; if (hasValidated) { distanceChanged(from, value); } @@ -75,8 +83,8 @@ abstract class CubicMirroredVertexBase extends CubicVertex { void copy(Core source) { super.copy(source); if (source is CubicMirroredVertexBase) { - _rotation = source._rotation; - _distance = source._distance; + rotation_ = source.rotation_; + distance_ = source.distance_; } } } diff --git a/lib/src/generated/shapes/paint/gradient_stop_base.dart b/lib/src/generated/shapes/paint/gradient_stop_base.dart index bf6117c6..3e6adb93 100644 --- a/lib/src/generated/shapes/paint/gradient_stop_base.dart +++ b/lib/src/generated/shapes/paint/gradient_stop_base.dart @@ -5,28 +5,33 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/component.dart'; +const _coreTypes = {GradientStopBase.typeKey, ComponentBase.typeKey}; + abstract class GradientStopBase extends Component { static const int typeKey = 19; @override int get coreType => GradientStopBase.typeKey; @override - Set get coreTypes => {GradientStopBase.typeKey, ComponentBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// ColorValue field with key 38. static const int colorValuePropertyKey = 38; static const int colorValueInitialValue = 0xFFFFFFFF; - int _colorValue = colorValueInitialValue; - int get colorValue => _colorValue; - /// Change the [_colorValue] field value. + @nonVirtual + int colorValue_ = colorValueInitialValue; + @nonVirtual + int get colorValue => colorValue_; + + /// Change the [colorValue_] field value. /// [colorValueChanged] will be invoked only if the field's value has changed. set colorValue(int value) { - if (_colorValue == value) { + if (colorValue_ == value) { return; } - int from = _colorValue; - _colorValue = value; + int from = colorValue_; + colorValue_ = value; if (hasValidated) { colorValueChanged(from, value); } @@ -38,17 +43,20 @@ abstract class GradientStopBase extends Component { /// Position field with key 39. static const int positionPropertyKey = 39; static const double positionInitialValue = 0; - double _position = positionInitialValue; - double get position => _position; - /// Change the [_position] field value. + @nonVirtual + double position_ = positionInitialValue; + @nonVirtual + double get position => position_; + + /// Change the [position_] field value. /// [positionChanged] will be invoked only if the field's value has changed. set position(double value) { - if (_position == value) { + if (position_ == value) { return; } - double from = _position; - _position = value; + double from = position_; + position_ = value; if (hasValidated) { positionChanged(from, value); } @@ -60,8 +68,8 @@ abstract class GradientStopBase extends Component { void copy(Core source) { super.copy(source); if (source is GradientStopBase) { - _colorValue = source._colorValue; - _position = source._position; + colorValue_ = source.colorValue_; + position_ = source.position_; } } } diff --git a/lib/src/generated/shapes/paint/solid_color_base.dart b/lib/src/generated/shapes/paint/solid_color_base.dart index d4da4ac3..fab83ac2 100644 --- a/lib/src/generated/shapes/paint/solid_color_base.dart +++ b/lib/src/generated/shapes/paint/solid_color_base.dart @@ -5,28 +5,33 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/component.dart'; +const _coreTypes = {SolidColorBase.typeKey, ComponentBase.typeKey}; + abstract class SolidColorBase extends Component { static const int typeKey = 18; @override int get coreType => SolidColorBase.typeKey; @override - Set get coreTypes => {SolidColorBase.typeKey, ComponentBase.typeKey}; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// ColorValue field with key 37. static const int colorValuePropertyKey = 37; static const int colorValueInitialValue = 0xFF747474; - int _colorValue = colorValueInitialValue; - int get colorValue => _colorValue; - /// Change the [_colorValue] field value. + @nonVirtual + int colorValue_ = colorValueInitialValue; + @nonVirtual + int get colorValue => colorValue_; + + /// Change the [colorValue_] field value. /// [colorValueChanged] will be invoked only if the field's value has changed. set colorValue(int value) { - if (_colorValue == value) { + if (colorValue_ == value) { return; } - int from = _colorValue; - _colorValue = value; + int from = colorValue_; + colorValue_ = value; if (hasValidated) { colorValueChanged(from, value); } @@ -38,7 +43,7 @@ abstract class SolidColorBase extends Component { void copy(Core source) { super.copy(source); if (source is SolidColorBase) { - _colorValue = source._colorValue; + colorValue_ = source.colorValue_; } } } diff --git a/lib/src/generated/shapes/paint/stroke_base.dart b/lib/src/generated/shapes/paint/stroke_base.dart index 91a83c44..1e28da91 100644 --- a/lib/src/generated/shapes/paint/stroke_base.dart +++ b/lib/src/generated/shapes/paint/stroke_base.dart @@ -7,33 +7,38 @@ import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/container_component_base.dart'; import 'package:rive/src/rive_core/shapes/paint/shape_paint.dart'; +const _coreTypes = { + StrokeBase.typeKey, + ShapePaintBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class StrokeBase extends ShapePaint { static const int typeKey = 24; @override int get coreType => StrokeBase.typeKey; @override - Set get coreTypes => { - StrokeBase.typeKey, - ShapePaintBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Thickness field with key 47. static const int thicknessPropertyKey = 47; static const double thicknessInitialValue = 1; - double _thickness = thicknessInitialValue; - double get thickness => _thickness; - /// Change the [_thickness] field value. + @nonVirtual + double thickness_ = thicknessInitialValue; + @nonVirtual + double get thickness => thickness_; + + /// Change the [thickness_] field value. /// [thicknessChanged] will be invoked only if the field's value has changed. set thickness(double value) { - if (_thickness == value) { + if (thickness_ == value) { return; } - double from = _thickness; - _thickness = value; + double from = thickness_; + thickness_ = value; if (hasValidated) { thicknessChanged(from, value); } @@ -112,7 +117,7 @@ abstract class StrokeBase extends ShapePaint { void copy(Core source) { super.copy(source); if (source is StrokeBase) { - _thickness = source._thickness; + thickness_ = source.thickness_; _cap = source._cap; _join = source._join; _transformAffectsStroke = source._transformAffectsStroke; diff --git a/lib/src/generated/shapes/straight_vertex_base.dart b/lib/src/generated/shapes/straight_vertex_base.dart index 7f3b5927..a5480d76 100644 --- a/lib/src/generated/shapes/straight_vertex_base.dart +++ b/lib/src/generated/shapes/straight_vertex_base.dart @@ -9,36 +9,41 @@ import 'package:rive/src/generated/shapes/vertex_base.dart'; import 'package:rive/src/rive_core/bones/weight.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; +const _coreTypes = { + StraightVertexBase.typeKey, + PathVertexBase.typeKey, + VertexBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class StraightVertexBase extends PathVertex { static const int typeKey = 5; @override int get coreType => StraightVertexBase.typeKey; @override - Set get coreTypes => { - StraightVertexBase.typeKey, - PathVertexBase.typeKey, - VertexBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Radius field with key 26. static const int radiusPropertyKey = 26; static const double radiusInitialValue = 0; - double _radius = radiusInitialValue; + + @nonVirtual + double radius_ = radiusInitialValue; /// Radius of the vertex - double get radius => _radius; + @nonVirtual + double get radius => radius_; - /// Change the [_radius] field value. + /// Change the [radius_] field value. /// [radiusChanged] will be invoked only if the field's value has changed. set radius(double value) { - if (_radius == value) { + if (radius_ == value) { return; } - double from = _radius; - _radius = value; + double from = radius_; + radius_ = value; if (hasValidated) { radiusChanged(from, value); } @@ -50,7 +55,7 @@ abstract class StraightVertexBase extends PathVertex { void copy(Core source) { super.copy(source); if (source is StraightVertexBase) { - _radius = source._radius; + radius_ = source.radius_; } } } diff --git a/lib/src/generated/shapes/vertex_base.dart b/lib/src/generated/shapes/vertex_base.dart index 58fb3278..17557986 100644 --- a/lib/src/generated/shapes/vertex_base.dart +++ b/lib/src/generated/shapes/vertex_base.dart @@ -5,34 +5,40 @@ import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/container_component_base.dart'; import 'package:rive/src/rive_core/container_component.dart'; +const _coreTypes = { + VertexBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class VertexBase extends ContainerComponent { static const int typeKey = 107; @override int get coreType => VertexBase.typeKey; @override - Set get coreTypes => { - VertexBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// X field with key 24. static const int xPropertyKey = 24; static const double xInitialValue = 0; - double _x = xInitialValue; + + @nonVirtual + double x_ = xInitialValue; /// X value for the translation of the vertex. - double get x => _x; + @nonVirtual + double get x => x_; - /// Change the [_x] field value. + /// Change the [x_] field value. /// [xChanged] will be invoked only if the field's value has changed. + @nonVirtual set x(double value) { - if (_x == value) { + if (x_ == value) { return; } - double from = _x; - _x = value; + double from = x_; + x_ = value; if (hasValidated) { xChanged(from, value); } @@ -44,19 +50,23 @@ abstract class VertexBase extends ContainerComponent { /// Y field with key 25. static const int yPropertyKey = 25; static const double yInitialValue = 0; - double _y = yInitialValue; + + @nonVirtual + double y_ = yInitialValue; /// Y value for the translation of the vertex. - double get y => _y; + @nonVirtual + double get y => y_; - /// Change the [_y] field value. + /// Change the [y_] field value. /// [yChanged] will be invoked only if the field's value has changed. + @nonVirtual set y(double value) { - if (_y == value) { + if (y_ == value) { return; } - double from = _y; - _y = value; + double from = y_; + y_ = value; if (hasValidated) { yChanged(from, value); } @@ -68,8 +78,8 @@ abstract class VertexBase extends ContainerComponent { void copy(Core source) { super.copy(source); if (source is VertexBase) { - _x = source._x; - _y = source._y; + x_ = source.x_; + y_ = source.y_; } } } diff --git a/lib/src/generated/solo_base.dart b/lib/src/generated/solo_base.dart index 1ef44bb0..8bd2928a 100644 --- a/lib/src/generated/solo_base.dart +++ b/lib/src/generated/solo_base.dart @@ -8,38 +8,43 @@ import 'package:rive/src/generated/transform_component_base.dart'; import 'package:rive/src/generated/world_transform_component_base.dart'; import 'package:rive/src/rive_core/node.dart'; +const _coreTypes = { + SoloBase.typeKey, + NodeBase.typeKey, + TransformComponentBase.typeKey, + WorldTransformComponentBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class SoloBase extends Node { static const int typeKey = 147; @override int get coreType => SoloBase.typeKey; @override - Set get coreTypes => { - SoloBase.typeKey, - NodeBase.typeKey, - TransformComponentBase.typeKey, - WorldTransformComponentBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// ActiveComponentId field with key 296. static const int activeComponentIdPropertyKey = 296; static const int activeComponentIdInitialValue = 0; - int _activeComponentId = activeComponentIdInitialValue; + + @nonVirtual + int activeComponentId_ = activeComponentIdInitialValue; /// Identifier of the active child in the solo set. - int get activeComponentId => _activeComponentId; + @nonVirtual + int get activeComponentId => activeComponentId_; - /// Change the [_activeComponentId] field value. + /// Change the [activeComponentId_] field value. /// [activeComponentIdChanged] will be invoked only if the field's value has /// changed. set activeComponentId(int value) { - if (_activeComponentId == value) { + if (activeComponentId_ == value) { return; } - int from = _activeComponentId; - _activeComponentId = value; + int from = activeComponentId_; + activeComponentId_ = value; if (hasValidated) { activeComponentIdChanged(from, value); } @@ -51,7 +56,7 @@ abstract class SoloBase extends Node { void copy(Core source) { super.copy(source); if (source is SoloBase) { - _activeComponentId = source._activeComponentId; + activeComponentId_ = source.activeComponentId_; } } } diff --git a/lib/src/generated/transform_component_base.dart b/lib/src/generated/transform_component_base.dart index f80dc189..6ad19156 100644 --- a/lib/src/generated/transform_component_base.dart +++ b/lib/src/generated/transform_component_base.dart @@ -7,33 +7,38 @@ import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/container_component_base.dart'; import 'package:rive/src/rive_core/world_transform_component.dart'; +const _coreTypes = { + TransformComponentBase.typeKey, + WorldTransformComponentBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class TransformComponentBase extends WorldTransformComponent { static const int typeKey = 38; @override int get coreType => TransformComponentBase.typeKey; @override - Set get coreTypes => { - TransformComponentBase.typeKey, - WorldTransformComponentBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Rotation field with key 15. static const int rotationPropertyKey = 15; static const double rotationInitialValue = 0; - double _rotation = rotationInitialValue; - double get rotation => _rotation; - /// Change the [_rotation] field value. + @nonVirtual + double rotation_ = rotationInitialValue; + @nonVirtual + double get rotation => rotation_; + + /// Change the [rotation_] field value. /// [rotationChanged] will be invoked only if the field's value has changed. set rotation(double value) { - if (_rotation == value) { + if (rotation_ == value) { return; } - double from = _rotation; - _rotation = value; + double from = rotation_; + rotation_ = value; if (hasValidated) { rotationChanged(from, value); } @@ -45,17 +50,21 @@ abstract class TransformComponentBase extends WorldTransformComponent { /// ScaleX field with key 16. static const int scaleXPropertyKey = 16; static const double scaleXInitialValue = 1; - double _scaleX = scaleXInitialValue; - double get scaleX => _scaleX; - /// Change the [_scaleX] field value. + @nonVirtual + double scaleX_ = scaleXInitialValue; + + @nonVirtual + double get scaleX => scaleX_; + + /// Change the [scaleX_] field value. /// [scaleXChanged] will be invoked only if the field's value has changed. set scaleX(double value) { - if (_scaleX == value) { + if (scaleX_ == value) { return; } - double from = _scaleX; - _scaleX = value; + double from = scaleX_; + scaleX_ = value; if (hasValidated) { scaleXChanged(from, value); } @@ -67,17 +76,21 @@ abstract class TransformComponentBase extends WorldTransformComponent { /// ScaleY field with key 17. static const int scaleYPropertyKey = 17; static const double scaleYInitialValue = 1; - double _scaleY = scaleYInitialValue; - double get scaleY => _scaleY; - /// Change the [_scaleY] field value. + @nonVirtual + double scaleY_ = scaleYInitialValue; + + @nonVirtual + double get scaleY => scaleY_; + + /// Change the [scaleY_] field value. /// [scaleYChanged] will be invoked only if the field's value has changed. set scaleY(double value) { - if (_scaleY == value) { + if (scaleY_ == value) { return; } - double from = _scaleY; - _scaleY = value; + double from = scaleY_; + scaleY_ = value; if (hasValidated) { scaleYChanged(from, value); } @@ -89,9 +102,9 @@ abstract class TransformComponentBase extends WorldTransformComponent { void copy(Core source) { super.copy(source); if (source is TransformComponentBase) { - _rotation = source._rotation; - _scaleX = source._scaleX; - _scaleY = source._scaleY; + rotation_ = source.rotation_; + scaleX_ = source.scaleX_; + scaleY_ = source.scaleY_; } } } diff --git a/lib/src/generated/world_transform_component_base.dart b/lib/src/generated/world_transform_component_base.dart index cdcaf19b..ebbb3236 100644 --- a/lib/src/generated/world_transform_component_base.dart +++ b/lib/src/generated/world_transform_component_base.dart @@ -6,32 +6,37 @@ import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/container_component_base.dart'; import 'package:rive/src/rive_core/container_component.dart'; +const _coreTypes = { + WorldTransformComponentBase.typeKey, + ContainerComponentBase.typeKey, + ComponentBase.typeKey +}; + abstract class WorldTransformComponentBase extends ContainerComponent { static const int typeKey = 91; @override int get coreType => WorldTransformComponentBase.typeKey; @override - Set get coreTypes => { - WorldTransformComponentBase.typeKey, - ContainerComponentBase.typeKey, - ComponentBase.typeKey - }; + Set get coreTypes => _coreTypes; /// -------------------------------------------------------------------------- /// Opacity field with key 18. static const int opacityPropertyKey = 18; static const double opacityInitialValue = 1; - double _opacity = opacityInitialValue; - double get opacity => _opacity; - /// Change the [_opacity] field value. + @nonVirtual + double opacity_ = opacityInitialValue; + @nonVirtual + double get opacity => opacity_; + + /// Change the [opacity_] field value. /// [opacityChanged] will be invoked only if the field's value has changed. set opacity(double value) { - if (_opacity == value) { + if (opacity_ == value) { return; } - double from = _opacity; - _opacity = value; + double from = opacity_; + opacity_ = value; if (hasValidated) { opacityChanged(from, value); } @@ -43,7 +48,7 @@ abstract class WorldTransformComponentBase extends ContainerComponent { void copy(Core source) { super.copy(source); if (source is WorldTransformComponentBase) { - _opacity = source._opacity; + opacity_ = source.opacity_; } } } diff --git a/lib/src/layer_component_events.dart b/lib/src/layer_component_events.dart index 2c39dc7c..34b8715f 100644 --- a/lib/src/layer_component_events.dart +++ b/lib/src/layer_component_events.dart @@ -3,9 +3,16 @@ import 'dart:collection'; import 'package:rive/src/rive_core/animation/state_machine_fire_event.dart'; class LayerComponentEvents extends ListBase { - final List _values = []; - List get values => - _values.cast(); + // final List _values = []; + final List _values = []; + // List get values => + // _values.cast(); + + @override + Iterator get iterator => _values.iterator; + + @override + StateMachineFireEvent elementAt(int index) => _values[index]; @override int get length => _values.length; @@ -14,7 +21,7 @@ class LayerComponentEvents extends ListBase { set length(int value) => _values.length = value; @override - StateMachineFireEvent operator [](int index) => _values[index]!; + StateMachineFireEvent operator [](int index) => _values[index]; @override void operator []=(int index, StateMachineFireEvent value) => diff --git a/lib/src/rive.dart b/lib/src/rive.dart index 0a8af09c..849cdc12 100644 --- a/lib/src/rive.dart +++ b/lib/src/rive.dart @@ -207,8 +207,7 @@ class RiveRenderObject extends RiveRenderBox implements MouseTrackerAnnotation { void _hitHelper(PointerEvent event, void Function(StateMachineController, Vec2D) callback) { final artboardPosition = _toArtboard(event.localPosition); - final stateMachineControllers = - _artboard.animationControllers.whereType(); + final stateMachineControllers = _artboard.animationControllers.whereType(); for (final stateMachineController in stateMachineControllers) { callback(stateMachineController, artboardPosition); } @@ -367,6 +366,7 @@ class RiveRenderObject extends RiveRenderBox implements MouseTrackerAnnotation { @override void dispose() { _artboard.redraw.removeListener(scheduleRepaint); + _artboard.dispose(); _recognizer.dispose(); super.dispose(); } diff --git a/lib/src/rive_core/animation/animation_reset_factory.dart b/lib/src/rive_core/animation/animation_reset_factory.dart index 7840cade..ada63dca 100644 --- a/lib/src/rive_core/animation/animation_reset_factory.dart +++ b/lib/src/rive_core/animation/animation_reset_factory.dart @@ -1,3 +1,5 @@ +import 'dart:collection'; + import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/animation/animation_state.dart'; import 'package:rive/src/rive_core/animation/blend_state.dart'; @@ -9,15 +11,13 @@ import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; import 'package:rive_common/utilities.dart'; -bool _isDouble(int propertyKey, Core object) { - final coreType = RiveCoreContext.coreType(propertyKey); - return coreType == RiveCoreContext.doubleType; -} +import '../../generated/rive_core_beans.dart'; -bool _isColor(int propertyKey, Core object) { - final coreType = RiveCoreContext.coreType(propertyKey); - return coreType == RiveCoreContext.colorType; -} +bool _isDouble(int propertyKey, Core object) => + PropertyBeans.get(propertyKey).coreType == RiveCoreContext.doubleType; + +bool _isColor(int propertyKey, Core object) => + PropertyBeans.get(propertyKey).coreType == RiveCoreContext.colorType; class AnimationReset { BinaryReader? _reader; @@ -86,10 +86,10 @@ class AnimationReset { // Fourth we read the property value for each property if (_isDouble(propertyKey, object!)) { double value = reader.readFloat32(); - RiveCoreContext.setDouble(object, propertyKey, value); + PropertyBeans.get(propertyKey).setDouble(object, value); } else if (_isColor(propertyKey, object)) { int value = reader.readInt32(); - RiveCoreContext.setColor(object, propertyKey, value); + PropertyBeans.get(propertyKey).setColor(object, value); } currentPropertyIndex += 1; } @@ -108,27 +108,26 @@ class _KeyedProperty { return false; } - int get propertyKey { - return property.propertyKey; - } - - int get size { - return 1 + 4; // property id + float value - } + int get propertyKey => property.propertyKey; + PropertyBean get propertyBean => property.propertyBean; + int get size => 1 + 4; // property id + float value } class _KeyedObject { final List<_KeyedProperty> properties = []; final KeyedObject data; - final Set visitedProperties = {}; + final visitedProperties = {}; _KeyedObject(this.data); + void addProperties( - List props, Core object, bool storeAsBaseline) { + Iterable props, Core object, bool storeAsBaseline) { for (final property in props) { - if (!visitedProperties.contains(property.propertyKey)) { - visitedProperties.add(property.propertyKey); - if (_isColor(property.propertyKey, object) || - _isDouble(property.propertyKey, object)) { + var prop = property.propertyKey; + + if (visitedProperties.add(prop)) { + // visitedProperties.add(prop); + if (_isColor(prop, object) || + _isDouble(prop, object)) { properties.add(_KeyedProperty(property, storeAsBaseline)); } } @@ -151,12 +150,15 @@ class _AnimationsData { int size = 0; List<_KeyedObject> keyedObjects = []; - Map visitedObjects = {}; - _AnimationsData(List animations, CoreContext core, + Map visitedObjects = HashMap();//{}; + + _AnimationsData(Iterable animations, CoreContext core, bool useFirstAsBaseline) { bool isFirstAnimation = useFirstAsBaseline; + for (final animation in animations) { - animation.keyedObjects.forEach((keyedObject) { + + for (final keyedObject in animation.keyedObjects) { final objectIntId = resolveId(keyedObject.objectId); final object = core.resolve(keyedObject.objectId); if (!visitedObjects.containsKey(objectIntId)) { @@ -164,13 +166,19 @@ class _AnimationsData { keyedObjects.add(visitedObjects[objectIntId]!); } visitedObjects[objectIntId]!.addProperties( - keyedObject.keyedProperties.toList(), object!, isFirstAnimation); - }); + keyedObject.keyedProperties, object!, isFirstAnimation); + } isFirstAnimation = false; } - for (final object in keyedObjects) { - size += object.size; + + var t = keyedObjects.length; + for (var i = 0; i < t; i++) { + size += keyedObjects[i].size; } + + // for (final object in keyedObjects) { + // size += object.size; + // } } int resolveId(int intId) { @@ -178,7 +186,9 @@ class _AnimationsData { } void writeObjects(AnimationReset animationReset, CoreContext core) { - keyedObjects.forEach((keyedObject) { + + // keyedObjects.forEach((keyedObject) { + for (final keyedObject in keyedObjects) { // We might have added keyed objects but no properties need resetting if (keyedObject.properties.isNotEmpty) { int objectIntId = resolveId(keyedObject.data.objectId); @@ -194,9 +204,9 @@ class _AnimationsData { animationReset.writeColor( (property.property.keyframes.first as KeyFrameColor).value); } else { - animationReset.writeColor(RiveCoreContext.getColor( - core.resolve(keyedObject.data.objectId), - property.propertyKey)); + + animationReset.writeColor(PropertyBeans.get(property.propertyKey).getColor(core.resolve(keyedObject.data.objectId))); + } } else if (_isDouble(property.propertyKey, object)) { animationReset.writePropertyKey(property.propertyKey); @@ -204,21 +214,25 @@ class _AnimationsData { animationReset.writeDouble( (property.property.keyframes.first as KeyFrameDouble).value); } else { - animationReset.writeDouble(RiveCoreContext.getDouble( - core.resolve(keyedObject.data.objectId), - property.propertyKey)); + + // animationReset.writeDouble(RiveCoreContext.getDouble( + // core.resolve(keyedObject.data.objectId), + // property.propertyKey)); + animationReset.writeDouble( + property.propertyBean.getDouble( + core.resolve(keyedObject.data.objectId))); } } } } - }); + }//); animationReset.createReader(); } } List _pool = []; -AnimationReset fromAnimations(List animations, +AnimationReset fromAnimations(Iterable animations, CoreContext core, bool useFirstAsBaseline) { final animationData = _AnimationsData(animations, core, useFirstAsBaseline); AnimationReset? animationReset; @@ -247,13 +261,15 @@ List _fromState( if (state is AnimationState && state.animation != null) { animations.add(state.animation!); } else if (state is BlendState) { - state.animations.forEach((blend1DAnimation) { + + // state.animations.forEach((blend1DAnimation) { + for (final blend1DAnimation in state.animations) { final animation = core.resolve(blend1DAnimation.animationId); if (animation != null) { animations.add(animation); } - }); + }//); } } return animations; @@ -270,9 +286,10 @@ AnimationReset fromStates( void release(AnimationReset value) { value.clear(); int index = 0; - while (index < _pool.length) { - final animationReset = _pool.elementAt(index); - if (animationReset.size > value.size) { + final length = _pool.length; + final valueSize = value.size; + while (index < length) { + if (_pool[index].size > valueSize) { break; } index++; diff --git a/lib/src/rive_core/animation/blend_state_1d_instance.dart b/lib/src/rive_core/animation/blend_state_1d_instance.dart index 5016852d..9732e6bc 100644 --- a/lib/src/rive_core/animation/blend_state_1d_instance.dart +++ b/lib/src/rive_core/animation/blend_state_1d_instance.dart @@ -20,8 +20,8 @@ class BlendState1DInstance ? animation_reset_factory.fromAnimations( animationInstances .map((animationInstance) => - animationInstance.animationInstance.animation) - .toList(growable: false), + animationInstance.animationInstance.animation), + // .toList(growable: false), state.context, true) : null; diff --git a/lib/src/rive_core/animation/cubic_interpolator.dart b/lib/src/rive_core/animation/cubic_interpolator.dart index 5d85770f..5378110e 100644 --- a/lib/src/rive_core/animation/cubic_interpolator.dart +++ b/lib/src/rive_core/animation/cubic_interpolator.dart @@ -81,16 +81,33 @@ class InterpolatorCubicFactor { int currentSample = 1; int lastSample = splineTableSize - 1; - for (; - currentSample != lastSample && _values[currentSample] <= x; - ++currentSample) { + // for (; + // currentSample != lastSample && _values[currentSample] <= x; + // ++currentSample) { + // intervalStart += sampleStepSize; + // } + // --currentSample; + // // Interpolate to provide an initial guess for t + // var dist = (x - _values[currentSample]) / + // (_values[currentSample + 1] - _values[currentSample]); + + // if (currentSample-1 < 0) { + // throw Exception('review me'); + // } + double last = _values[currentSample]; + double? previous;// = _values[currentSample-1]; + while (true) { + if (!(currentSample != lastSample && last <= x)) { + break; + } intervalStart += sampleStepSize; + currentSample++; + previous = last; + last = _values[currentSample]; } - --currentSample; + previous ??= _values[currentSample-1]; + var dist = (x - previous) / (last - previous); - // Interpolate to provide an initial guess for t - var dist = (x - _values[currentSample]) / - (_values[currentSample + 1] - _values[currentSample]); var guessForT = intervalStart + dist * sampleStepSize; var initialSlope = getSlope(guessForT, x1, x2); diff --git a/lib/src/rive_core/animation/cubic_interpolator_component.dart b/lib/src/rive_core/animation/cubic_interpolator_component.dart index 74380e19..b4a63c7a 100644 --- a/lib/src/rive_core/animation/cubic_interpolator_component.dart +++ b/lib/src/rive_core/animation/cubic_interpolator_component.dart @@ -10,6 +10,9 @@ class CubicInterpolatorComponent extends CubicInterpolatorComponentBase implements Interpolator, CubicInterface { CubicEase _ease = CubicEase.make(0.42, 0, 0.58, 1); + @override + bool get late => false; + @override void update(int dirt) {} diff --git a/lib/src/rive_core/animation/interpolating_keyframe.dart b/lib/src/rive_core/animation/interpolating_keyframe.dart index a9851f17..a8e160b3 100644 --- a/lib/src/rive_core/animation/interpolating_keyframe.dart +++ b/lib/src/rive_core/animation/interpolating_keyframe.dart @@ -12,38 +12,61 @@ abstract class InterpolatingKeyFrame extends InterpolatingKeyFrameBase { @override bool get canInterpolate => true; - KeyFrameInterpolation get interpolation => - enumAt(KeyFrameInterpolation.values, interpolationType); - set interpolation(KeyFrameInterpolation value) { - interpolationType = value.index; - } - - @override - void interpolationTypeChanged(int from, int to) {} + KeyFrameInterpolation get interpolation => enumAt(KeyFrameInterpolation.values, interpolationType); + set interpolation(KeyFrameInterpolation value) => interpolationType = value.index; - Interpolator? _interpolator; - Interpolator? get interpolator => _interpolator; + Interpolator _interpolator = Interpolators.initial; + Interpolator? get interpolator => _interpolator == Interpolators.initial ? null : _interpolator; set interpolator(Interpolator? value) { if (_interpolator == value) { return; } - _interpolator = value; - interpolatorId = value?.id ?? Core.missingId; + _interpolator = value ?? Interpolators.initial; + // interpolatorId = value?.id ?? Core.missingId; + // interpolatorId = value;//?.id ?? Core.missingId; } + @override + void copy(Core source) { + super.copy(source); + if (source is InterpolatingKeyFrame) { + _interpolator = source._interpolator; + } + } + + /// The id of the custom interpolator used when interpolation is Cubic. + @override + // int get interpolatorId => _interpolator?.id ?? Core.missingId; + int get interpolatorId => _interpolator.id; + + // Interpolator _interpolator = nullInterpolator; + // Interpolator? get interpolator => _interpolator == nullInterpolator ? null : _interpolator; + // set interpolator(Interpolator? value) { + // if (_interpolator == value) { + // return; + // } + // + // _interpolator = value == null ? nullInterpolator : value; + // interpolatorId = value?.id ?? Core.missingId; + // } + @override void interpolatorIdChanged(int from, int to) { // This might resolve to null during a load or if context isn't available // yet so we also do this in onAddedDirty. - interpolator = context.resolve(to); + if (hasValidated) { + _interpolator = context.resolve(to) ?? Interpolators.late(to); + } else { + _interpolator = Interpolators.late(to); + } } @override void onAddedDirty() { super.onAddedDirty(); - if (interpolatorId != Core.missingId) { - interpolator = context.resolve(interpolatorId); + if (interpolatorId != Core.missingId && _interpolator.late) { + _interpolator = context.resolve(interpolatorId) ?? Interpolators.late(interpolatorId); } // Ensure interpolation types are valid, correct them if not. switch (interpolation) { diff --git a/lib/src/rive_core/animation/interpolator.dart b/lib/src/rive_core/animation/interpolator.dart index b785de04..58202ecd 100644 --- a/lib/src/rive_core/animation/interpolator.dart +++ b/lib/src/rive_core/animation/interpolator.dart @@ -1,4 +1,5 @@ abstract class Interpolator { + const Interpolator(); int get id; /// Convert a linear interpolation factor to an eased one. Returns a factor @@ -9,4 +10,30 @@ abstract class Interpolator { double transformValue(double from, double to, double f); bool equalParameters(Interpolator other); + + bool get late; +} + +abstract class Interpolators { + + static const initial = LateInterpolator._(-1); + static LateInterpolator late(int id) => LateInterpolator._(id); +} + +class LateInterpolator extends Interpolator { + @override + final int id; + + @override + bool get late => id != 0; + + const LateInterpolator._(this.id); + @override + bool equalParameters(Interpolator other) => throw UnimplementedError(); + + @override + double transform(double f) => throw UnimplementedError(); + + @override + double transformValue(double from, double to, double f) => throw UnimplementedError(); } diff --git a/lib/src/rive_core/animation/keyed_object.dart b/lib/src/rive_core/animation/keyed_object.dart index 114871cf..a711267b 100644 --- a/lib/src/rive_core/animation/keyed_object.dart +++ b/lib/src/rive_core/animation/keyed_object.dart @@ -1,5 +1,6 @@ import 'dart:collection'; +import 'package:collection/collection.dart'; import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyed_object_base.dart'; import 'package:rive/src/rive_core/animation/keyed_property.dart'; @@ -15,10 +16,21 @@ abstract class KeyedCallbackReporter { } class KeyedObject extends KeyedObjectBase { - final HashMap _keyedProperties = - HashMap(); - Iterable get keyedProperties => _keyedProperties.values; + final Map _keyedProperties = HashMap(); + + /// STOKANAL-FORK-EDIT: Keeping a copy of values lazily + List? _props; + List get keyedProperties => + _props ??= _keyedProperties.values.toList(); + + List? _propsNonCallback; + List get propsNonCallback => + _propsNonCallback ??= keyedProperties.whereNot((p) => p.isCallback).toList(); + + /// STOKANAL-FORK-EDIT: Reuse this object for every animation + @override + K? clone() => this as K; @override void onAddedDirty() {} @@ -48,6 +60,7 @@ class KeyedObject extends KeyedObjectBase { return false; } _keyedProperties[property.propertyKey] = property; + _propsNonCallback = _props = null; return true; } @@ -56,6 +69,7 @@ class KeyedObject extends KeyedObjectBase { /// be @internal when it's supported. bool internalRemoveKeyedProperty(KeyedProperty property) { var removed = _keyedProperties.remove(property.propertyKey); + _propsNonCallback = _props = null; if (_keyedProperties.isEmpty) { // Remove this keyed property. @@ -73,8 +87,18 @@ class KeyedObject extends KeyedObjectBase { required KeyedCallbackReporter reporter, bool isAtStartFrame = false, }) { - for (final keyedProperty - in _keyedProperties.values.where((property) => property.isCallback)) { + + var ps = keyedProperties; + var t = ps.length; + KeyedProperty keyedProperty; + for (var i = 0; i < t; i++) { + keyedProperty = ps[i]; + // for (final keyedProperty in keyedProperties) { + + if (!keyedProperty.isCallback) { + continue; + } + keyedProperty.reportKeyedCallbacks( objectId, secondsFrom, @@ -90,20 +114,23 @@ class KeyedObject extends KeyedObjectBase { double mix, CoreContext coreContext, ) { - Core? object = coreContext.resolve(objectId); + var object = coreContext.resolve(objectId); if (object == null) { return; } - for (final keyedProperty in _keyedProperties.values) { - if (keyedProperty.isCallback) { - continue; - } - keyedProperty.apply(time, mix, object); + + var ps = propsNonCallback; + var t = ps.length; + for (var i = 0; i < t; i++) { + ps[i].apply(time, mix, object); } + // for (final keyedProperty in propsNonCallback) { + // keyedProperty.apply(time, mix, object); + // } } - @override - void objectIdChanged(int from, int to) {} + // @override + // void objectIdChanged(int from, int to) {} @override bool import(ImportStack stack) { diff --git a/lib/src/rive_core/animation/keyed_property.dart b/lib/src/rive_core/animation/keyed_property.dart index afb97eb6..bf7b43e9 100644 --- a/lib/src/rive_core/animation/keyed_property.dart +++ b/lib/src/rive_core/animation/keyed_property.dart @@ -3,6 +3,10 @@ import 'package:rive/src/generated/animation/keyed_property_base.dart'; import 'package:rive/src/rive_core/animation/interpolating_keyframe.dart'; import 'package:rive/src/rive_core/animation/keyed_object.dart'; import 'package:rive/src/rive_core/animation/keyframe.dart'; +import 'package:stokanal/core.dart' as rive_settings; + +import '../../../rive.dart'; +import '../../generated/animation/nested_trigger_base.dart'; export 'package:rive/src/generated/animation/keyed_property_base.dart'; @@ -11,15 +15,27 @@ abstract class KeyFrameInterface { } class KeyFrameList { - List _keyframes = []; - List get keyframes => _keyframes; - set keyframes(Iterable frames) => _keyframes = frames.toList(); + + @nonVirtual + List keyframes = []; + + // var _keyframes = []; + // List get keyframes => _keyframes; + // set keyframes(Iterable frames) => _keyframes = frames.toList(); + + // T get firstKeyframe => _keyframes.first; + // void remove(T keyframe) { + // _keyframes.remove(keyframe); + // onKeyframesChanged(); + // } + + void onKeyframesChanged() {} /// Get the keyframe immediately following the provided one. T? after(T keyframe) { - var index = _keyframes.indexOf(keyframe); - if (index != -1 && index + 1 < _keyframes.length) { - return _keyframes[index + 1]; + var index = keyframes.indexOf(keyframe); + if (index != -1 && index + 1 < keyframes.length) { + return keyframes[index + 1]; } return null; } @@ -31,11 +47,11 @@ class KeyFrameList { int mid = 0; int closestFrame = 0; int start = 0; - int end = _keyframes.length - 1; + int end = keyframes.length - 1; while (start <= end) { mid = (start + end) >> 1; - closestFrame = _keyframes[mid].frame; + closestFrame = keyframes[mid].frame; if (closestFrame < frame) { start = mid + 1; } else if (closestFrame > frame) { @@ -51,12 +67,17 @@ class KeyFrameList { } void sort() { - _keyframes.sort((a, b) => a.frame.compareTo(b.frame)); + keyframes.sort((a, b) => a.frame.compareTo(b.frame)); } } class KeyedProperty extends KeyedPropertyBase with KeyFrameList { + + /// STOKANAL-FORK-EDIT: Reuse this object for every animation + @override + K? clone() => this as K; + @override void onAdded() {} @@ -66,19 +87,20 @@ class KeyedProperty extends KeyedPropertyBase /// Called by rive_core to add a KeyFrame to this KeyedProperty. This should /// be @internal when it's supported. bool internalAddKeyFrame(KeyFrame frame) { - if (_keyframes.contains(frame)) { + if (keyframes.contains(frame)) { return false; } - _keyframes.add(frame); + keyframes.add(frame); markKeyFrameOrderDirty(); + onKeyframesChanged(); return true; } /// Called by rive_core to remove a KeyFrame from this KeyedProperty. This /// should be @internal when it's supported. bool internalRemoveKeyFrame(KeyFrame frame) { - var removed = _keyframes.remove(frame); - if (_keyframes.isEmpty) { + var removed = keyframes.remove(frame); + if (keyframes.isEmpty) { // If they keyframes are now empty, we might want to remove this keyed // property. Wait for any other pending changes to complete before // checking. @@ -86,12 +108,13 @@ class KeyedProperty extends KeyedPropertyBase } else { markKeyFrameOrderDirty(); } + onKeyframesChanged(); return removed; } void _checkShouldRemove() { - if (_keyframes.isEmpty) { + if (keyframes.isEmpty) { // Remove this keyed property. context.removeObject(this); } @@ -110,26 +133,85 @@ class KeyedProperty extends KeyedPropertyBase } /// Number of keyframes for this keyed property. - int get numFrames => _keyframes.length; + int get numFrames => keyframes.length; - KeyFrame getFrameAt(int index) => _keyframes[index]; + KeyFrame getFrameAt(int index) => keyframes[index]; + + /// Return from and to frames + _ClosestFrame _closestFramePair(final double seconds) { - int closestFrameIndex(double seconds, {int exactOffset = 0}) { // Binary find the keyframe index (use timeInSeconds here as opposed to the // finder above which operates in frames). - int mid = 0; - double closestSeconds = 0; - int start = 0; - int end = _keyframes.length - 1; + final lastIndex = keyframes.length - 1; + + // If it's the last keyframe, we skip the binary search + final last = keyframes[lastIndex]; + + final double secondsMin; + final double secondsMax; + if (_skipInterpolation) { // no interpolation + secondsMin = seconds; + secondsMax = seconds; + } else { + secondsMin = seconds - rive_settings.interpolationExactSecondsTolerance; + secondsMax = seconds + rive_settings.interpolationExactSecondsTolerance; + } + + if (seconds >= last.seconds) { + return _ClosestFrame(null, last, secondsMin, secondsMax); + } + + var first = keyframes[0]; + if (seconds <= first.seconds) { + return _ClosestFrame(null, first, secondsMin, secondsMax); + } + + int start = 1; + int end = lastIndex; + while (start <= end) { + int mid = (start + end) >> 1; + var keyframe = keyframes[mid]; + if (keyframe.seconds < secondsMin) { + start = mid + 1; + } else if (keyframe.seconds > secondsMax) { + end = mid - 1; + } else { + return _ClosestFrame(null, keyframe, secondsMin, secondsMax); + } + } + + return _ClosestFrame(keyframes[start-1] as InterpolatingKeyFrame, keyframes[start], secondsMin, secondsMax); + } + + int _closestFrameIndex(double seconds, {int exactOffset = 0}) { + + // Binary find the keyframe index (use timeInSeconds here as opposed to the + // finder above which operates in frames). + var length = keyframes.length; + int end = length - 1; + var totalSeconds = keyframes[end].seconds; // If it's the last keyframe, we skip the binary search - if (seconds > _keyframes[end].seconds) { + if (seconds > totalSeconds) { return end + 1; } + if (seconds == totalSeconds) { + return end + exactOffset; + } + if (seconds < keyframes[0].seconds) { + return 0; + } + int mid = (length * seconds/totalSeconds).toInt(); // try to guess an optimal starting seconds + if (mid > end) { + mid = end; + } + + int start = 0; + double closestSeconds; + while (start <= end) { - mid = (start + end) >> 1; - closestSeconds = _keyframes[mid].seconds; + closestSeconds = keyframes[mid].seconds; if (closestSeconds < seconds) { start = mid + 1; } else if (closestSeconds > seconds) { @@ -137,11 +219,43 @@ class KeyedProperty extends KeyedPropertyBase } else { return mid + exactOffset; } + mid = (start + end) >> 1; } return start; } - bool get isCallback => RiveCoreContext.isCallback(propertyKey); + /// Original method (DO NOT DELETE FOR REFERENCE) + // int closestFrameIndex(double seconds, {int exactOffset = 0}) { + // // Binary find the keyframe index (use timeInSeconds here as opposed to the + // // finder above which operates in frames). + // int mid = 0; + // double closestSeconds = 0; + // int start = 0; + // int end = _keyframes.length - 1; + // + // // If it's the last keyframe, we skip the binary search + // if (seconds > _keyframes[end].seconds) { + // return end + 1; + // } + // + // while (start <= end) { + // mid = (start + end) >> 1; + // closestSeconds = _keyframes[mid].seconds; + // if (closestSeconds < seconds) { + // start = mid + 1; + // } else if (closestSeconds > seconds) { + // end = mid - 1; + // } else { + // return mid + exactOffset; + // } + // } + // return start; + // } + + bool get isCallback => + propertyKey == EventBase.triggerPropertyKey || + propertyKey == NestedTriggerBase.firePropertyKey; + // RiveCoreContext.isCallback(propertyKey_); /// Report any keyframes that occured between secondsFrom and secondsTo. void reportKeyedCallbacks( @@ -166,8 +280,15 @@ class KeyedProperty extends KeyedPropertyBase fromExactOffset = 1; } } - int idx = closestFrameIndex(secondsFrom, exactOffset: fromExactOffset); - int idxTo = closestFrameIndex(secondsTo, exactOffset: toExactOffset); + int idx = _closestFrameIndex(secondsFrom, exactOffset: fromExactOffset); + int idxTo = _closestFrameIndex(secondsTo, exactOffset: toExactOffset); + + // validate _closestFrameIndex method + // int _idx = closestFrameIndex(secondsFrom, exactOffset: fromExactOffset); + // int _idxTo = closestFrameIndex(secondsTo, exactOffset: toExactOffset); + // if (_idx != idx || idxTo != _idxTo) { + // throw Exception('$_idx != $idx, $idxTo != $_idxTo'); + // } // going backwards? if (idxTo < idx) { @@ -177,51 +298,82 @@ class KeyedProperty extends KeyedPropertyBase } while (idxTo > idx) { - var frame = _keyframes[idx]; + var frame = keyframes[idx]; reporter.reportKeyedCallback( objectId, propertyKey, secondsTo - frame.seconds); idx++; } } + @override + void onKeyframesChanged() { + // if (_pair is! _SkipInterpolation) { + _pair = null; + // } + } + + _ClosestFrame? _pair; + + var _skipInterpolation = false; + void skipInterpolationTolerance() { + // _pair = _skipInterpolation; + _skipInterpolation = true; + } + + // // uncomment me for stats + // static var _applies = 0; + // static var _hits = 0; + // static var _toleranceHits = 0; + // var _skips = 0; + /// Apply keyframe values at a given time expressed in [seconds]. void apply(double seconds, double mix, Core object) { - if (_keyframes.isEmpty) { + if (keyframes.length == 0) { return; } - int idx = closestFrameIndex(seconds); - int pk = propertyKey; - if (idx == 0) { - var first = _keyframes[0]; + // _applies++; - first.apply(object, pk, mix); - } else { - if (idx < _keyframes.length) { - InterpolatingKeyFrame fromFrame = - _keyframes[idx - 1] as InterpolatingKeyFrame; - KeyFrame toFrame = _keyframes[idx]; - if (seconds == toFrame.seconds) { - toFrame.apply(object, pk, mix); - } else { - /// Equivalent to fromFrame.interpolation == - /// KeyFrameInterpolation.hold. - if (fromFrame.interpolationType == 0) { - fromFrame.apply(object, pk, mix); - } else { - fromFrame.applyInterpolation(object, pk, seconds, toFrame, mix); - } - } - } else { - var last = _keyframes[idx - 1]; + // final _ClosestFrame pair; + + if (_pair != null && seconds >= _pair!.secondsMin && seconds <= _pair!.secondsMax) { // reuse + // _hits++; + // if (seconds != _pair!._seconds) { + // _toleranceHits++; + // } + // if (_hits % 1000000 == 0) { + // print('HITS > $_hits $_toleranceHits > hits=${(_hits/_applies).toStringAsFixed(2)} tolerance=${(_toleranceHits/_hits).toStringAsFixed(2)}'); + // } - last.apply(object, pk, mix); + if (_skipInterpolation) { // no interpolation, lookup and don't reset + _pair = _closestFramePair(seconds); + // if (_skips++ % 1000 == 0) { + // log('SKIP INTERPOLATION'); + // } } + } else { // lookup and reset + _pair = _closestFramePair(seconds); } - } - @override - void propertyKeyChanged(int from, int to) {} + // if (_pair != null && + // seconds >= _pair!.secondsMin && + // seconds <= _pair!.secondsMax) { // it's a hit + // } else { + // _pair = _closestFramePair(seconds); + // } + + var fromFrame = _pair!.fromFrame; + + if (fromFrame != null) { // interpolation + if (fromFrame.interpolationType == 0) { + fromFrame.apply(object, propertyBean, mix); + } else { + fromFrame.applyInterpolation(object, propertyBean, seconds, _pair!.toFrame, mix); + } + } else { + _pair!.toFrame.apply(object, propertyBean, mix); + } + } @override bool import(ImportStack stack) { @@ -234,3 +386,17 @@ class KeyedProperty extends KeyedPropertyBase return super.import(stack); } } + +class _ClosestFrame { + final InterpolatingKeyFrame? fromFrame; + final KeyFrame toFrame; + final double secondsMin; + final double secondsMax; + const _ClosestFrame(this.fromFrame, this.toFrame, this.secondsMin, this.secondsMax); +} + +// class _SkipInterpolation extends _ClosestFrame { +// _SkipInterpolation(): super(null, KeyFrameString(), 0, 0); +// } +// +// final _skipInterpolation = _SkipInterpolation(); diff --git a/lib/src/rive_core/animation/keyframe.dart b/lib/src/rive_core/animation/keyframe.dart index 8e5cde64..4e476f56 100644 --- a/lib/src/rive_core/animation/keyframe.dart +++ b/lib/src/rive_core/animation/keyframe.dart @@ -3,33 +3,39 @@ import 'package:rive/src/generated/animation/keyframe_base.dart'; import 'package:rive/src/rive_core/animation/keyed_property.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart'; +import '../../generated/rive_core_beans.dart'; + export 'package:rive/src/generated/animation/keyframe_base.dart'; abstract class KeyFrame extends KeyFrameBase implements KeyFrameInterface { bool get canInterpolate => false; - double _timeInSeconds = 0; - double get seconds => _timeInSeconds; + + @nonVirtual + double seconds = 0; // avoid getter + // double _timeInSeconds = 0; + // double get seconds => _timeInSeconds; @override void onAdded() {} void computeSeconds(LinearAnimation animation) { - _timeInSeconds = frame / animation.fps; + // _timeInSeconds = frame / animation.fps; + seconds = frame / animation.fps; } @override void onAddedDirty() {} - @override - void frameChanged(int from, int to) {} + // @override + // void frameChanged(int from, int to) {} /// Apply the value of this keyframe to the object's property. - void apply(Core object, int propertyKey, double mix) {} + void apply(Core object, PropertyBean bean, double mix) {} /// Interpolate the value between this keyframe and the next and apply it to /// the object's property. - void applyInterpolation(Core object, int propertyKey, double seconds, + void applyInterpolation(Core object, PropertyBean bean, double seconds, covariant KeyFrame nextFrame, double mix) {} @override diff --git a/lib/src/rive_core/animation/keyframe_bool.dart b/lib/src/rive_core/animation/keyframe_bool.dart index 837cfb07..b0096125 100644 --- a/lib/src/rive_core/animation/keyframe_bool.dart +++ b/lib/src/rive_core/animation/keyframe_bool.dart @@ -1,5 +1,6 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_bool_base.dart'; +import 'package:rive/src/generated/rive_core_beans.dart'; export 'package:rive/src/generated/animation/keyframe_bool_base.dart'; /// KeyFrame for animating bool properties. @@ -8,14 +9,16 @@ class KeyFrameBool extends KeyFrameBoolBase { bool get canInterpolate => false; @override - void apply(Core object, int propertyKey, double mix) { - RiveCoreContext.setBool(object, propertyKey, value); + void apply(Core object, PropertyBean bean, double mix) { + // RiveCoreContext.setBool(object, bean, value); + bean.setBool(object, value); } @override - void applyInterpolation(Core object, int propertyKey, + void applyInterpolation(Core object, PropertyBean bean, double currentTime, KeyFrameBool nextFrame, double mix) { - RiveCoreContext.setBool(object, propertyKey, value); + // RiveCoreContext.setBool(object, bean, value); + bean.setBool(object, value); } @override diff --git a/lib/src/rive_core/animation/keyframe_callback.dart b/lib/src/rive_core/animation/keyframe_callback.dart index 1510deaf..928c4a0a 100644 --- a/lib/src/rive_core/animation/keyframe_callback.dart +++ b/lib/src/rive_core/animation/keyframe_callback.dart @@ -2,13 +2,15 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_callback_base.dart'; import 'package:rive/src/rive_core/animation/keyframe.dart'; +import '../../generated/rive_core_beans.dart'; + export 'package:rive/src/generated/animation/keyframe_callback_base.dart'; class KeyFrameCallback extends KeyFrameCallbackBase { @override - void apply(Core object, int propertyKey, double mix) {} + void apply(Core object, PropertyBean bean, double mix) {} @override - void applyInterpolation(Core object, int propertyKey, + void applyInterpolation(Core object, PropertyBean bean, double seconds, covariant KeyFrame nextFrame, double mix) {} } diff --git a/lib/src/rive_core/animation/keyframe_color.dart b/lib/src/rive_core/animation/keyframe_color.dart index 899fea56..a1f928f9 100644 --- a/lib/src/rive_core/animation/keyframe_color.dart +++ b/lib/src/rive_core/animation/keyframe_color.dart @@ -2,29 +2,32 @@ import 'dart:ui'; import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_color_base.dart'; + +import '../../generated/rive_core_beans.dart'; export 'package:rive/src/generated/animation/keyframe_color_base.dart'; -void _apply(Core object, int propertyKey, double mix, int value) { +void _apply(Core object, PropertyBean bean, double mix, int value) { if (mix == 1) { - RiveCoreContext.setColor(object, propertyKey, value); + // RiveCoreContext.setColor(object, propertyKey, value); + bean.setColor(object, value); } else { var mixedColor = Color.lerp( - Color(RiveCoreContext.getColor(object, propertyKey)), + Color(bean.getColor(object)), Color(value), mix); if (mixedColor != null) { - RiveCoreContext.setColor(object, propertyKey, mixedColor.value); + bean.setColor(object, mixedColor.value); } } } class KeyFrameColor extends KeyFrameColorBase { @override - void apply(Core object, int propertyKey, double mix) => - _apply(object, propertyKey, mix, value); + void apply(Core object, PropertyBean bean, double mix) => + _apply(object, bean, mix, value); @override - void applyInterpolation(Core object, int propertyKey, + void applyInterpolation(Core object, PropertyBean bean, double currentTime, KeyFrameColor nextFrame, double mix) { var f = (currentTime - seconds) / (nextFrame.seconds - seconds); @@ -34,7 +37,7 @@ class KeyFrameColor extends KeyFrameColorBase { var color = Color.lerp(Color(value), Color(nextFrame.value), f); if (color != null) { - _apply(object, propertyKey, mix, color.value); + _apply(object, bean, mix, color.value); } } diff --git a/lib/src/rive_core/animation/keyframe_double.dart b/lib/src/rive_core/animation/keyframe_double.dart index 39d55448..545873c5 100644 --- a/lib/src/rive_core/animation/keyframe_double.dart +++ b/lib/src/rive_core/animation/keyframe_double.dart @@ -1,34 +1,48 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_double_base.dart'; + +import '../../generated/rive_core_beans.dart'; export 'package:rive/src/generated/animation/keyframe_double_base.dart'; -void _apply( - Core object, int propertyKey, double mix, double value) { - if (mix == 1) { - RiveCoreContext.setDouble(object, propertyKey, value); - } else { - var mixi = 1.0 - mix; - RiveCoreContext.setDouble(object, propertyKey, - RiveCoreContext.getDouble(object, propertyKey) * mixi + value * mix); - } -} +// void _apply( +// Core object, int propertyKey, double mix, double value) { +// RiveCoreContext.setDouble(object, propertyKey, +// mix == 1 ? value : RiveCoreContext.getDouble(object, propertyKey) * (1.0 - mix) + value * mix); +// } class KeyFrameDouble extends KeyFrameDoubleBase { + + /// STOKANAL-FORK-EDIT: Reuse this object for every animation @override - void apply(Core object, int propertyKey, double mix) => - _apply(object, propertyKey, mix, value); + K? clone() => this as K; @override - void applyInterpolation(Core object, int propertyKey, + void apply(Core object, PropertyBean bean, double mix) { + if (mix == 1) { + bean.setDouble(object, value); + } else { + // bean.transformDouble(object, (v) => v * (1.0 - mix) + value * mix); + bean.applyDouble(object, 1.0 - mix, value * mix); + } + } + + @override + void applyInterpolation(Core object, PropertyBean bean, double currentTime, KeyFrameDouble nextFrame, double mix) { var f = (currentTime - seconds) / (nextFrame.seconds - seconds); var frameValue = interpolator?.transformValue(value, nextFrame.value, f) ?? value + (nextFrame.value - value) * f; - _apply(object, propertyKey, mix, frameValue); + // _apply(object, propertyKey, mix, frameValue); + + if (mix == 1) { + bean.setDouble(object, frameValue); + } else { + bean.setDouble(object, bean.getDouble(object) * (1.0 - mix) + frameValue * mix); + } } - @override - void valueChanged(double from, double to) {} + // @override + // void valueChanged(double from, double to) {} } diff --git a/lib/src/rive_core/animation/keyframe_id.dart b/lib/src/rive_core/animation/keyframe_id.dart index 9a688c39..18be7788 100644 --- a/lib/src/rive_core/animation/keyframe_id.dart +++ b/lib/src/rive_core/animation/keyframe_id.dart @@ -1,6 +1,8 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_id_base.dart'; +import '../../generated/rive_core_beans.dart'; + export 'package:rive/src/generated/animation/keyframe_id_base.dart'; class KeyFrameId extends KeyFrameIdBase { @@ -8,14 +10,14 @@ class KeyFrameId extends KeyFrameIdBase { bool get canInterpolate => false; @override - void apply(Core object, int propertyKey, double mix) { - RiveCoreContext.setUint(object, propertyKey, value); + void apply(Core object, PropertyBean bean, double mix) { + bean.setUint(object, value); } @override - void applyInterpolation(Core object, int propertyKey, + void applyInterpolation(Core object, PropertyBean bean, double currentTime, KeyFrameId nextFrame, double mix) { - RiveCoreContext.setUint(object, propertyKey, value); + bean.setUint(object, value); } @override diff --git a/lib/src/rive_core/animation/keyframe_interpolator.dart b/lib/src/rive_core/animation/keyframe_interpolator.dart index 742b4843..10a65501 100644 --- a/lib/src/rive_core/animation/keyframe_interpolator.dart +++ b/lib/src/rive_core/animation/keyframe_interpolator.dart @@ -7,6 +7,10 @@ export 'package:rive/src/generated/animation/keyframe_interpolator_base.dart'; abstract class KeyFrameInterpolator extends KeyFrameInterpolatorBase implements Interpolator { + + @override + bool get late => false; + @override void onAdded() => updateInterpolator(); diff --git a/lib/src/rive_core/animation/keyframe_string.dart b/lib/src/rive_core/animation/keyframe_string.dart index 737d1d5f..20bd5bf3 100644 --- a/lib/src/rive_core/animation/keyframe_string.dart +++ b/lib/src/rive_core/animation/keyframe_string.dart @@ -1,6 +1,8 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_string_base.dart'; +import '../../generated/rive_core_beans.dart'; + export 'package:rive/src/generated/animation/keyframe_id_base.dart'; class KeyFrameString extends KeyFrameStringBase { @@ -8,14 +10,14 @@ class KeyFrameString extends KeyFrameStringBase { bool get canInterpolate => false; @override - void apply(Core object, int propertyKey, double mix) { - RiveCoreContext.setString(object, propertyKey, value); + void apply(Core object, PropertyBean bean, double mix) { + bean.setString(object, value); } @override - void applyInterpolation(Core object, int propertyKey, + void applyInterpolation(Core object, PropertyBean bean, double currentTime, KeyFrameString nextFrame, double mix) { - RiveCoreContext.setString(object, propertyKey, value); + bean.setString(object, value); } @override diff --git a/lib/src/rive_core/animation/keyframe_uint.dart b/lib/src/rive_core/animation/keyframe_uint.dart index 692f71a3..fe64d787 100644 --- a/lib/src/rive_core/animation/keyframe_uint.dart +++ b/lib/src/rive_core/animation/keyframe_uint.dart @@ -1,5 +1,7 @@ import 'package:rive/src/core/core.dart'; import 'package:rive/src/generated/animation/keyframe_uint_base.dart'; + +import '../../generated/rive_core_beans.dart'; export 'package:rive/src/generated/animation/keyframe_uint_base.dart'; /// KeyFrame for animating uint properties. @@ -8,14 +10,14 @@ class KeyFrameUint extends KeyFrameUintBase { bool get canInterpolate => false; @override - void apply(Core object, int propertyKey, double mix) { - RiveCoreContext.setUint(object, propertyKey, value); + void apply(Core object, PropertyBean bean, double mix) { + bean.setUint(object, value); } @override - void applyInterpolation(Core object, int propertyKey, + void applyInterpolation(Core object, PropertyBean bean, double currentTime, KeyFrameUint nextFrame, double mix) { - RiveCoreContext.setUint(object, propertyKey, value); + bean.setUint(object, value); } @override diff --git a/lib/src/rive_core/animation/layer_state.dart b/lib/src/rive_core/animation/layer_state.dart index 72bbafd4..a524cb5b 100644 --- a/lib/src/rive_core/animation/layer_state.dart +++ b/lib/src/rive_core/animation/layer_state.dart @@ -7,8 +7,10 @@ import 'package:rive/src/rive_core/animation/state_transition.dart'; export 'package:rive/src/generated/animation/layer_state_base.dart'; abstract class LayerState extends LayerStateBase { - final StateTransitions _transitions = StateTransitions(); - StateTransitions get transitions => _transitions; + + @nonVirtual + final StateTransitions transitions = StateTransitions(); + // StateTransitions get transitions => _transitions; @override void onAdded() {} @@ -17,17 +19,17 @@ abstract class LayerState extends LayerStateBase { void onAddedDirty() {} void internalAddTransition(StateTransition transition) { - assert(!_transitions.contains(transition), + assert(!transitions.contains(transition), 'shouldn\'t already contain the transition'); - _transitions.add(transition); + transitions.add(transition); } void internalRemoveTransition(StateTransition transition) { - _transitions.remove(transition); + transitions.remove(transition); } - @override - void flagsChanged(int from, int to) {} + // @override + // void flagsChanged(int from, int to) {} StateInstance makeInstance(); diff --git a/lib/src/rive_core/animation/linear_animation.dart b/lib/src/rive_core/animation/linear_animation.dart index b6b5212c..6f55f893 100644 --- a/lib/src/rive_core/animation/linear_animation.dart +++ b/lib/src/rive_core/animation/linear_animation.dart @@ -42,16 +42,21 @@ class LinearAnimation extends LinearAnimationBase { objects.any((element) => _keyedObjects.containsKey(element.id)); bool isObjectKeyed(Core object) => _keyedObjects.containsKey(object.id); + bool removeObjectKeys(Core object) { var value = _keyedObjects[object.id]; if (value == null) { return false; } bool found = false; + for (final kp in value.keyedProperties) { - for (final kf in kp.keyframes.toList()) { + for (final kf in kp.keyframes){ kf.remove(); - found = true; + if (!found) { + kp.onKeyframesChanged(); + found = true; + } } } return found; @@ -73,6 +78,9 @@ class LinearAnimation extends LinearAnimationBase { /// Returns the start time of the animation in seconds, considering speed double get startTime => (speed >= 0) ? startSeconds : endSeconds; + /// STOKANAL-FORK-EDIT: iterate properties with a list rather than with a map + late final List _objects = _keyedObjects.values.toList(growable: false); + void reportKeyedCallbacks( double secondsFrom, double secondsTo, { @@ -88,7 +96,9 @@ class LinearAnimation extends LinearAnimationBase { // Do not report a callback twice if it comes from the "pong" part of a // "ping pong" loop if (!isAtStartFrame || !fromPong) { - for (final keyedObject in _keyedObjects.values) { + // for (final keyedObject in _keyedObjects.values) { + /// STOKANAL-FORK-EDIT: iterate properties with a list rather than with a map + for (final keyedObject in _objects) { keyedObject.reportKeyedCallbacks( secondsFrom, secondsTo, @@ -110,9 +120,15 @@ class LinearAnimation extends LinearAnimationBase { // ignore: parameter_assignments time = (time * fps).floor() / fps; } - for (final keyedObject in _keyedObjects.values) { - keyedObject.apply(time, mix, coreContext); + // for (final keyedObject in _keyedObjects.values) { + /// STOKANAL-FORK-EDIT: iterate properties with a list rather than with a map + var t = _objects.length; + for (var i = 0; i < t; i++) { + _objects[i].apply(time, mix, coreContext); } + // for (final keyedObject in _objects) { + // keyedObject.apply(time, mix, coreContext); + // } } Loop get loop => Loop.values[loopValue]; diff --git a/lib/src/rive_core/animation/nested_state_machine.dart b/lib/src/rive_core/animation/nested_state_machine.dart index 403871e5..05dcf81f 100644 --- a/lib/src/rive_core/animation/nested_state_machine.dart +++ b/lib/src/rive_core/animation/nested_state_machine.dart @@ -41,7 +41,7 @@ class NestedStateMachine extends NestedStateMachineBase { @override bool get isEnabled => _stateMachineInstance?.isActive ?? false; - final Set _nestedInputs = {}; + final _nestedInputs = {}; Set get nestedInputs => _nestedInputs; NestedStateMachineInstance? _stateMachineInstance; diff --git a/lib/src/rive_core/animation/state_machine_component.dart b/lib/src/rive_core/animation/state_machine_component.dart index 1d451cf9..a929c211 100644 --- a/lib/src/rive_core/animation/state_machine_component.dart +++ b/lib/src/rive_core/animation/state_machine_component.dart @@ -41,7 +41,6 @@ abstract class StateMachineComponent @override void onRemoved() { super.onRemoved(); - stateMachine = null; } diff --git a/lib/src/rive_core/animation/state_transition.dart b/lib/src/rive_core/animation/state_transition.dart index 56247894..3df75159 100644 --- a/lib/src/rive_core/animation/state_transition.dart +++ b/lib/src/rive_core/animation/state_transition.dart @@ -158,8 +158,8 @@ class StateTransition extends StateTransitionBase { return removed; } - @override - void flagsChanged(int from, int to) {} + // @override + // void flagsChanged(int from, int to) {} @override void durationChanged(int from, int to) {} @@ -183,7 +183,12 @@ class StateTransition extends StateTransitionBase { if (isDisabled) { return AllowTransition.no; } - for (final condition in conditions) { + + var conditions = this.conditions.values; + final t = conditions.length; + for (var i = 0; i < t; i++) { + // for (final condition in conditions) { + var condition = conditions[i]; if (condition is TransitionViewModelCondition) { return AllowTransition.no; } else if (condition is TransitionInputCondition && diff --git a/lib/src/rive_core/artboard.dart b/lib/src/rive_core/artboard.dart index 74a598b7..53e378c9 100644 --- a/lib/src/rive_core/artboard.dart +++ b/lib/src/rive_core/artboard.dart @@ -1,4 +1,3 @@ -import 'dart:collection'; import 'dart:ui'; import 'package:meta/meta.dart'; @@ -30,11 +29,12 @@ import 'package:rive/src/rive_core/viewmodel/viewmodel_instance.dart'; import 'package:rive_common/layout_engine.dart'; import 'package:rive_common/math.dart'; import 'package:rive_common/utilities.dart'; +import 'package:stokanal/core.dart' hide Event; export 'package:rive/src/generated/artboard_base.dart'; class Artboard extends ArtboardBase with ShapePaintContainer { - final HashSet _dirtyLayout = HashSet(); + final _dirtyLayout = {}; void markLayoutDirty(LayoutComponent layoutComponent) { _dirtyLayout.add(layoutComponent); @@ -102,39 +102,47 @@ class Artboard extends ArtboardBase with ShapePaintContainer { final Path path = Path(); List _dependencyOrder = []; - final List _drawables = []; final List _rules = []; List _sortedDrawRules = []; - final Set _components = {}; + final _components = UniqueList.of(); - List get drawables => _drawables; + @nonVirtual + final List drawables = []; + // List get drawables => _drawables; - final AnimationList _animations = AnimationList(); - final EventList _events = EventList(); + @nonVirtual + final AnimationList animations = AnimationList(); + @nonVirtual + final EventList events = EventList(); /// List of animations and state machines in the artboard. - AnimationList get animations => _animations; + // AnimationList get animations => _animations; /// List of events in the artboard. - EventList get events => _events; + // EventList get events => _events; DataContext? dataContext; final List globalDataBinds = []; /// List of linear animations in the artboard. Iterable get linearAnimations => - _animations.whereType(); + animations.whereType(); /// List of state machines in the artboard. Iterable get stateMachines => - _animations.whereType(); + animations.whereType(); int _dirtDepth = 0; /// Iterate each component and call callback for it. - void forEachComponent(void Function(Component) callback) => - _components.forEach(callback); + void forEachComponent(void Function(Component) callback) { + var t = _components.length; + for (var i = 0; i < t; i++) { + // for (final c in _components) { + callback(_components[i]); + } + } /// Find a component of a specific type with a specific name. T? component(String name) { @@ -205,20 +213,22 @@ class Artboard extends ArtboardBase with ShapePaintContainer { return didUpdate; } - final Set _activeNestedArtboards = {}; - Iterable get activeNestedArtboards => _activeNestedArtboards; + @nonVirtual + final activeNestedArtboards = UniqueList.of(); + // Iterable get activeNestedArtboards => _activeNestedArtboards; - final List _joysticks = []; - Iterable get joysticks => _joysticks; + @nonVirtual + final List joysticks = []; + // Iterable get joysticks => _joysticks; - final List _dataBinds = []; - Iterable get dataBinds => _dataBinds; + final List dataBinds = []; + // Iterable get dataBinds => _dataBinds; bool canPreApplyJoysticks() { - if (_joysticks.isEmpty) { + if (joysticks.length == 0) { return false; } - if (_joysticks.any((joystick) => joystick.isComplex)) { + if (joysticks.any((joystick) => joystick.isComplex)) { return false; } return true; @@ -237,10 +247,10 @@ class Artboard extends ArtboardBase with ShapePaintContainer { } bool applyJoysticks({bool isRoot = false}) { - if (_joysticks.isEmpty) { + if (joysticks.isEmpty) { return false; } - for (final joystick in _joysticks) { + for (final joystick in joysticks) { if (isRoot) { updateDataBinds(); } @@ -311,8 +321,8 @@ class Artboard extends ArtboardBase with ShapePaintContainer { } if (nested) { - var active = _activeNestedArtboards.toList(growable: false); - for (final activeNestedArtboard in active) { + // var active = _activeNestedArtboards.toList(growable: false); + for (final activeNestedArtboard in activeNestedArtboards){//.toList(growable: false)) { if (activeNestedArtboard.advance(elapsedSeconds)) { didUpdate = true; } @@ -431,11 +441,11 @@ class Artboard extends ArtboardBase with ShapePaintContainer { case NestedTriggerBase.typeKey: break; case JoystickBase.typeKey: - _joysticks.add(component as Joystick); + joysticks.add(component as Joystick); break; case DataBindBase.typeKey: case DataBindContextBase.typeKey: - _dataBinds.add(component as DataBind); + dataBinds.add(component as DataBind); break; } } @@ -453,21 +463,21 @@ class Artboard extends ArtboardBase with ShapePaintContainer { case NestedTriggerBase.typeKey: break; case JoystickBase.typeKey: - _joysticks.remove(component as Joystick); + joysticks.remove(component as Joystick); break; case DataBindBase.typeKey: case DataBindContextBase.typeKey: - _dataBinds.remove(component as DataBind); + dataBinds.remove(component as DataBind); break; } } void addNestedArtboard(NestedArtboard artboard) { - _activeNestedArtboards.add(artboard); + activeNestedArtboards.add(artboard); } void removeNestedArtboard(NestedArtboard artboard) { - _activeNestedArtboards.remove(artboard); + activeNestedArtboards.remove(artboard); } /// Let the artboard know that the drawables need to be resorted before @@ -536,10 +546,10 @@ class Artboard extends ArtboardBase with ShapePaintContainer { /// Called by rive_core to add an Animation to an Artboard. This should be /// @internal when it's supported. bool internalAddAnimation(Animation animation) { - if (_animations.contains(animation)) { + if (animations.contains(animation)) { return false; } - _animations.add(animation); + animations.add(animation); return true; } @@ -547,7 +557,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer { /// Called by rive_core to remove an Animation from an Artboard. This should /// be @internal when it's supported. bool internalRemoveAnimation(Animation animation) { - bool removed = _animations.remove(animation); + bool removed = animations.remove(animation); return removed; } @@ -555,10 +565,10 @@ class Artboard extends ArtboardBase with ShapePaintContainer { /// Called by rive_core to add an Event to an Artboard. This should be /// @internal when it's supported. bool internalAddEvent(Event event) { - if (_events.contains(event)) { + if (events.contains(event)) { return false; } - _events.add(event); + events.add(event); return true; } @@ -566,14 +576,14 @@ class Artboard extends ArtboardBase with ShapePaintContainer { /// Called by rive_core to remove an Event from an Artboard. This should /// be @internal when it's supported. bool internalRemoveEvent(Event event) { - bool removed = _events.remove(event); + bool removed = events.remove(event); return removed; } /// The animation controllers that are called back whenever the artboard /// advances. - final Set _animationControllers = {}; + final _animationControllers = UniqueList.of(); /// Access a read-only iterator of currently applied animation controllers. Iterable get animationControllers => @@ -630,9 +640,9 @@ class Artboard extends ArtboardBase with ShapePaintContainer { Drawable? firstDrawable; void computeDrawOrder() { - _drawables.clear(); + drawables.clear(); _rules.clear(); - buildDrawOrder(_drawables, null, _rules); + buildDrawOrder(drawables, null, _rules); // Build rule dependencies. In practice this'll need to happen anytime a // target drawable is changed or rule is added/removed. @@ -665,11 +675,9 @@ class Artboard extends ArtboardBase with ShapePaintContainer { } void populateDataBinds(List globalDataBinds) { - dataBinds.forEach((dataBind) { - globalDataBinds.add(dataBind); - }); + dataBinds.forEach(globalDataBinds.add); - for (final nestedArtboard in _activeNestedArtboards) { + for (final nestedArtboard in activeNestedArtboards) { final mountedArtboard = nestedArtboard.mountedArtboard; if (mountedArtboard != null) { mountedArtboard.populateDataBinds(globalDataBinds); @@ -685,9 +693,13 @@ class Artboard extends ArtboardBase with ShapePaintContainer { if (dataContext == null) { return; } - for (final dataBind in dataBinds) { - dataBind.bind(dataContext); + + var length = dataBinds.length; + for (var i = 0; i < length; i++) { + // for (final dataBind in dataBinds) { + dataBinds[i].bind(dataContext); } + if (isRoot) { globalDataBinds.clear(); populateDataBinds(globalDataBinds); @@ -697,14 +709,21 @@ class Artboard extends ArtboardBase with ShapePaintContainer { void sortDrawOrder() { hasChangedDrawOrderInLastUpdate = true; + // Clear out rule first/last items. - for (final rule in _sortedDrawRules) { + var length = _sortedDrawRules.length; + for (var i = 0; i < length; i++) { + // for (final rule in _sortedDrawRules) { + final rule = _sortedDrawRules[i]; rule.first = rule.last = null; } firstDrawable = null; Drawable? lastDrawable; - for (final drawable in _drawables) { + length = drawables.length; + for (var i = 0; i < length; i++) { + // for (final drawable in _drawables) { + final drawable = drawables[i]; var rules = drawable.flattenedDrawRules; var target = rules?.activeTarget; @@ -730,7 +749,10 @@ class Artboard extends ArtboardBase with ShapePaintContainer { } } - for (final rule in _sortedDrawRules) { + length = _sortedDrawRules.length; + for (var i = 0; i < length; i++) { + // for (final rule in _sortedDrawRules) { + final rule = _sortedDrawRules[i]; if (rule.first == null) { continue; } @@ -818,7 +840,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer { DataContext? parentDataContext, bool isRoot) { dataContext = dataContextValue; dataContext!.parent = parentDataContext; - for (final nestedArtboard in _activeNestedArtboards) { + for (final nestedArtboard in activeNestedArtboards) { final mountedArtboard = nestedArtboard.mountedArtboard; if (mountedArtboard != null) { ViewModelInstance? nestedViewModelInstance = diff --git a/lib/src/rive_core/assets/font_asset.dart b/lib/src/rive_core/assets/font_asset.dart index 3b9739d7..6c92b852 100644 --- a/lib/src/rive_core/assets/font_asset.dart +++ b/lib/src/rive_core/assets/font_asset.dart @@ -9,7 +9,7 @@ import 'package:rive_common/rive_text.dart'; export 'package:rive/src/generated/assets/font_asset_base.dart'; class FontAsset extends FontAssetBase { - final Set _callbacks = {}; + final _callbacks = {}; /// Call [callback] when the font is ready. Set [notifyAlreadySet] to /// specify if you want to be called if the font is already set. diff --git a/lib/src/rive_core/audio_player.dart b/lib/src/rive_core/audio_player.dart index 258121c6..007fa0c3 100644 --- a/lib/src/rive_core/audio_player.dart +++ b/lib/src/rive_core/audio_player.dart @@ -95,7 +95,7 @@ class AudioPlayer { return; } - var completed = _sounds.where((sound) => sound.completed).toList(); + var completed = _sounds.where((sound) => sound.completed);//.toList(); _sounds.removeWhere((sound) => sound.completed); for (final sound in completed) { diff --git a/lib/src/rive_core/bones/bone.dart b/lib/src/rive_core/bones/bone.dart index d83e6c48..16c9b39c 100644 --- a/lib/src/rive_core/bones/bone.dart +++ b/lib/src/rive_core/bones/bone.dart @@ -9,7 +9,7 @@ typedef bool BoneCallback(Bone bone); class Bone extends BoneBase { /// Child constraints applied to some child of this bone which also affect /// this bone. - final Set _peerConstraints = {}; + final _peerConstraints = {}; Iterable get peerConstraints => _peerConstraints; bool addPeerConstraint(Constraint child) => _peerConstraints.add(child); diff --git a/lib/src/rive_core/component.dart b/lib/src/rive_core/component.dart index 5f57567e..32f2743f 100644 --- a/lib/src/rive_core/component.dart +++ b/lib/src/rive_core/component.dart @@ -4,6 +4,7 @@ import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/container_component.dart'; import 'package:rive/src/rive_core/dependency_helper.dart'; import 'package:rive_common/utilities.dart'; +import 'package:stokanal/core.dart'; export 'package:rive/src/generated/component_base.dart'; @@ -27,7 +28,9 @@ abstract class Component extends ComponentBase dirt &= ~ComponentDirt.collapsed; } onDirty(dirt); - _dependencyHelper.onComponentDirty(this); + + // _dependencyHelper.onComponentDirty(this); + _dependencyHelper.dependencyRoot?.onComponentDirty(this); // avoid invocking return true; } @@ -54,7 +57,7 @@ abstract class Component extends ComponentBase dirt |= value; onDirty(dirt); - _dependencyHelper.onComponentDirty(this); + _dependencyHelper.dependencyRoot?.onComponentDirty(this); // avoid calling one method if (!recurse) { return true; @@ -163,13 +166,16 @@ abstract class Component extends ComponentBase } /// Components that this component depends on. - final Set _dependsOn = {}; + final _dependsOn = UniqueList.of(); @override Set get dependents => _dependencyHelper.dependents; + @nonVirtual + UniqueList get dependentsList => _dependencyHelper.dependents; + Set get dependencies { - Set components = {}; + var components = {}; allDependencies(components); return components; } diff --git a/lib/src/rive_core/constraints/follow_path_constraint.dart b/lib/src/rive_core/constraints/follow_path_constraint.dart index eda76937..4ec5f4cf 100644 --- a/lib/src/rive_core/constraints/follow_path_constraint.dart +++ b/lib/src/rive_core/constraints/follow_path_constraint.dart @@ -19,7 +19,8 @@ class FollowPathConstraint extends FollowPathConstraintBase { Mat2D get targetTransform { if (target is Shape || target is Path) { - var metrics = _worldPath.computeMetrics().toList(growable: false); + // var metrics = _worldPath.computeMetrics().toList(growable: false); + var metrics = _worldPath.computeMetrics(); if (metrics.isEmpty) { return Mat2D(); } diff --git a/lib/src/rive_core/constraints/ik_constraint.dart b/lib/src/rive_core/constraints/ik_constraint.dart index 2cacc486..40700245 100644 --- a/lib/src/rive_core/constraints/ik_constraint.dart +++ b/lib/src/rive_core/constraints/ik_constraint.dart @@ -96,7 +96,7 @@ class IKConstraint extends IKConstraintBase { // tip (constrainedComponent). var tip = parent as Bone; - var bones = _fkChain.reversed.map((link) => link.bone).toSet(); + var bones = _fkChain.reversed.map((link) => link.bone).toSet(); // to set to preserve order for (final bone in bones.skip(1)) { for (final child in bone.children) { if (child is TransformComponent && !bones.contains(child)) { diff --git a/lib/src/rive_core/container_component.dart b/lib/src/rive_core/container_component.dart index ca936b67..3b5626f6 100644 --- a/lib/src/rive_core/container_component.dart +++ b/lib/src/rive_core/container_component.dart @@ -62,7 +62,11 @@ abstract class ContainerComponent extends ContainerComponentBase { void removeRecursive() { Set deathRow = {this}; forEachChild((child) => deathRow.add(child)); - deathRow.forEach(context.removeObject); + + // deathRow.forEach(context.removeObject); + for (final c in deathRow) { + context.removeObject(c); + } } void buildDrawOrder( diff --git a/lib/src/rive_core/data_bind/context/context_value_boolean.dart b/lib/src/rive_core/data_bind/context/context_value_boolean.dart index 07a82656..d10c2e77 100644 --- a/lib/src/rive_core/data_bind/context/context_value_boolean.dart +++ b/lib/src/rive_core/data_bind/context/context_value_boolean.dart @@ -1,4 +1,5 @@ import 'package:rive/src/core/core.dart'; +import 'package:rive/src/generated/rive_core_beans.dart'; import 'package:rive/src/rive_core/data_bind/context/context_value.dart'; import 'package:rive/src/rive_core/viewmodel/viewmodel_instance_boolean.dart'; @@ -12,13 +13,13 @@ class ContextValueBoolean extends ContextValue { if (source?.coreType == ViewModelInstanceBooleanBase.typeKey) { final sourceBoolean = source as ViewModelInstanceBoolean; - RiveCoreContext.setBool(core, propertyKey, sourceBoolean.propertyValue); + PropertyBeans.get(propertyKey).setBool(core, sourceBoolean.propertyValue); } } @override void applyToSource(Core core, int propertyKey) { - final value = RiveCoreContext.getBool(core, propertyKey); + final value = PropertyBeans.get(propertyKey).getBool(core); final sourceBoolean = source as ViewModelInstanceBoolean; sourceBoolean.propertyValue = value; } diff --git a/lib/src/rive_core/data_bind/context/context_value_color.dart b/lib/src/rive_core/data_bind/context/context_value_color.dart index 9e4eacd1..c6ff06f6 100644 --- a/lib/src/rive_core/data_bind/context/context_value_color.dart +++ b/lib/src/rive_core/data_bind/context/context_value_color.dart @@ -1,4 +1,5 @@ import 'package:rive/src/core/core.dart'; +import 'package:rive/src/generated/rive_core_beans.dart'; import 'package:rive/src/rive_core/data_bind/context/context_value.dart'; import 'package:rive/src/rive_core/viewmodel/viewmodel_instance_color.dart'; @@ -12,13 +13,13 @@ class ContextValueColor extends ContextValue { if (source?.coreType == ViewModelInstanceColorBase.typeKey) { final sourceColor = source as ViewModelInstanceColor; - RiveCoreContext.setColor(core, propertyKey, sourceColor.propertyValue); + PropertyBeans.get(propertyKey).setColor(core, sourceColor.propertyValue); } } @override void applyToSource(Core core, int propertyKey) { - final value = RiveCoreContext.getColor(core, propertyKey); + final value = PropertyBeans.get(propertyKey).getColor(core); final sourceColor = source as ViewModelInstanceColor; sourceColor.propertyValue = value; } diff --git a/lib/src/rive_core/data_bind/context/context_value_number.dart b/lib/src/rive_core/data_bind/context/context_value_number.dart index 15d6415c..599e8c6f 100644 --- a/lib/src/rive_core/data_bind/context/context_value_number.dart +++ b/lib/src/rive_core/data_bind/context/context_value_number.dart @@ -1,4 +1,5 @@ import 'package:rive/src/core/core.dart'; +import 'package:rive/src/generated/rive_core_beans.dart'; import 'package:rive/src/rive_core/data_bind/context/context_value.dart'; import 'package:rive/src/rive_core/viewmodel/viewmodel_instance_number.dart'; @@ -12,13 +13,13 @@ class ContextValueNumber extends ContextValue { if (source?.coreType == ViewModelInstanceNumberBase.typeKey) { final sourceNumber = source as ViewModelInstanceNumber; - RiveCoreContext.setDouble(core, propertyKey, sourceNumber.propertyValue); + PropertyBeans.get(propertyKey).setDouble(core, sourceNumber.propertyValue); } } @override void applyToSource(Core core, int propertyKey) { - final value = RiveCoreContext.getDouble(core, propertyKey); + final value = PropertyBeans.get(propertyKey).getDouble(core); final sourceNumber = source as ViewModelInstanceNumber; sourceNumber.propertyValue = value; } diff --git a/lib/src/rive_core/data_bind/context/context_value_string.dart b/lib/src/rive_core/data_bind/context/context_value_string.dart index 221cfcfd..05d6c210 100644 --- a/lib/src/rive_core/data_bind/context/context_value_string.dart +++ b/lib/src/rive_core/data_bind/context/context_value_string.dart @@ -1,4 +1,5 @@ import 'package:rive/src/core/core.dart'; +import 'package:rive/src/generated/rive_core_beans.dart'; import 'package:rive/src/rive_core/data_bind/context/context_value.dart'; import 'package:rive/src/rive_core/viewmodel/viewmodel_instance_string.dart'; @@ -12,13 +13,13 @@ class ContextValueString extends ContextValue { if (source?.coreType == ViewModelInstanceStringBase.typeKey) { final sourceString = source as ViewModelInstanceString; - RiveCoreContext.setString(core, propertyKey, sourceString.propertyValue); + PropertyBeans.get(propertyKey).setString(core, sourceString.propertyValue); } } @override void applyToSource(Core core, int propertyKey) { - final value = RiveCoreContext.getString(core, propertyKey); + final value = PropertyBeans.get(propertyKey).getString(core); final sourceString = source as ViewModelInstanceString; sourceString.propertyValue = value; } diff --git a/lib/src/rive_core/dependency_helper.dart b/lib/src/rive_core/dependency_helper.dart index fb0383be..f7b4c586 100644 --- a/lib/src/rive_core/dependency_helper.dart +++ b/lib/src/rive_core/dependency_helper.dart @@ -1,27 +1,41 @@ +import 'package:stokanal/core.dart'; + class DependencyHelper { - Set dependents = {}; + + final dependents = UniqueList.of(); // set should stay ordered T? dependencyRoot; DependencyHelper(); bool addDependent(U value) { - if (!dependents.contains(value)) { - dependents.add(value); - return true; - } - return false; + + // if (!dependents.contains(value)) { + // dependents.add(value); + // return true; + // } + // return false; + + // using set or unique list + return dependents.add(value); } void addDirt(int dirt, {bool recurse = false}) { - dependents - .forEach((dependent) => dependent.addDirt(dirt, recurse: recurse)); - } - void onComponentDirty(U component) { - dependencyRoot?.onComponentDirty(component); + /// STOKANAL-FORK-EDIT: do not use forEach + + // UniqueList + var list = dependents.list; + final t = list.length; + for (var i = 0; i < t; i++) { + list[i].addDirt(dirt, recurse: recurse); + } + + // // Set + // for (final dependent in dependents) { + // dependent.addDirt(dirt, recurse: recurse); + // } } - void clear() { + void clear() => dependents.clear(); - } } diff --git a/lib/src/rive_core/drawable.dart b/lib/src/rive_core/drawable.dart index d42aa3f7..6d6d4df3 100644 --- a/lib/src/rive_core/drawable.dart +++ b/lib/src/rive_core/drawable.dart @@ -43,7 +43,7 @@ abstract class Drawable extends DrawableBase { List _clippingShapes = []; bool clip(Canvas canvas) { - if (_clippingShapes.isEmpty) { + if (_clippingShapes.length == 0) { return false; } canvas.save(); @@ -86,10 +86,9 @@ abstract class Drawable extends DrawableBase { void drawableFlagsChanged(int from, int to) => addDirt(ComponentDirt.paint); bool get isHidden => - (drawableFlags & ComponentFlags.hidden) != 0 || + (drawableFlags_ & ComponentFlags.hidden) != 0 || (dirt & ComponentDirt.collapsed) != 0; - bool get isTargetOpaque { - return (drawableFlags & ComponentFlags.opaque) != 0; - } + bool get isTargetOpaque => + (drawableFlags_ & ComponentFlags.opaque) != 0; } diff --git a/lib/src/rive_core/event.dart b/lib/src/rive_core/event.dart index 38e0ce4f..53effd61 100644 --- a/lib/src/rive_core/event.dart +++ b/lib/src/rive_core/event.dart @@ -26,7 +26,7 @@ class Event extends EventBase { } void _syncCustomProperties() { - var nextCustomProperties = children.whereType().toSet(); + var nextCustomProperties = children.whereType().toSet();//.toSet(); if (!iterableEquals(customProperties, nextCustomProperties)) { customProperties.clear(); customProperties.addAll(nextCustomProperties); diff --git a/lib/src/rive_core/layout_component.dart b/lib/src/rive_core/layout_component.dart index a407c23d..a51cb4a5 100644 --- a/lib/src/rive_core/layout_component.dart +++ b/lib/src/rive_core/layout_component.dart @@ -554,10 +554,11 @@ class LayoutComponent extends LayoutComponentBase with ShapePaintContainer { } void syncLayoutChildren() { - final layoutChildren = children.whereType(); + final layoutChildren = children.whereType().toList(); layoutNode.clearChildren(); - for (var i = 0; i < layoutChildren.length; i++) { - layoutNode.insertChild(layoutChildren.elementAt(i).layoutNode, i); + final length = layoutChildren.length; + for (var i = 0; i < length; i++) { + layoutNode.insertChild(layoutChildren[i].layoutNode, i); } } diff --git a/lib/src/rive_core/shapes/image.dart b/lib/src/rive_core/shapes/image.dart index f0ab2e68..cce2e60c 100644 --- a/lib/src/rive_core/shapes/image.dart +++ b/lib/src/rive_core/shapes/image.dart @@ -13,6 +13,8 @@ import 'package:rive_common/math.dart'; export 'package:rive/src/generated/shapes/image_base.dart'; +// const _logr = Debugr(true, prefix: 'image'); + class Image extends ImageBase with FileAssetReferencer, @@ -53,6 +55,11 @@ class Image extends ImageBase } bool clipped = clip(canvas); + // if (width == 256 && height == 256 && {'badge_outline', 'ai_badge'}.contains(name) && Randoms().hit(0.005)) { + // _logr.log(() => 'DRAW > $runtimeType $name:$name_ assetId=$assetId size=$width:$height asset=${asset?.fileExtension}'); + // debugPrintStack(); + // } + final paint = ui.Paint() ..color = ui.Color.fromRGBO(0, 0, 0, renderOpacity) ..filterQuality = ui.FilterQuality.high diff --git a/lib/src/rive_core/shapes/paint/trim_path_drawing.dart b/lib/src/rive_core/shapes/paint/trim_path_drawing.dart index 5baf13b3..01dd2af2 100644 --- a/lib/src/rive_core/shapes/paint/trim_path_drawing.dart +++ b/lib/src/rive_core/shapes/paint/trim_path_drawing.dart @@ -78,7 +78,7 @@ void _appendPathSegmentSync( void _trimPathSequential( Path path, Path result, double startT, double stopT, bool complement) { // Measure length of all the contours. - var metrics = path.computeMetrics().toList(growable: false); + var metrics = path.computeMetrics();//.toList(growable: false); double totalLength = 0.0; for (final metric in metrics) { totalLength += metric.length; @@ -114,7 +114,7 @@ void _trimPathSequential( void _trimPathSync( Path path, Path result, double startT, double stopT, bool complement) { - final metrics = path.computeMetrics().toList(growable: false); + final metrics = path.computeMetrics();//.toList(growable: false); for (final metric in metrics) { double length = metric.length; double trimStart = length * startT; diff --git a/lib/src/rive_core/shapes/shape.dart b/lib/src/rive_core/shapes/shape.dart index 35729995..0abd25a0 100644 --- a/lib/src/rive_core/shapes/shape.dart +++ b/lib/src/rive_core/shapes/shape.dart @@ -14,7 +14,7 @@ import 'package:rive_common/math.dart'; export 'package:rive/src/generated/shapes/shape_base.dart'; class Shape extends ShapeBase with ShapePaintContainer { - final Set paths = {}; + final paths = {}; bool _wantWorldPath = false; bool _wantLocalPath = false; diff --git a/lib/src/rive_core/shapes/shape_paint_container.dart b/lib/src/rive_core/shapes/shape_paint_container.dart index d7935d64..fa80cb42 100644 --- a/lib/src/rive_core/shapes/shape_paint_container.dart +++ b/lib/src/rive_core/shapes/shape_paint_container.dart @@ -5,13 +5,13 @@ import 'package:rive/src/rive_core/shapes/paint/fill.dart'; import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart'; import 'package:rive/src/rive_core/shapes/paint/stroke.dart'; import 'package:rive_common/math.dart'; +import 'package:stokanal/core.dart'; /// An abstraction to give a common interface to any component that can contain /// fills and strokes. abstract class ShapePaintContainer { - final Set fills = {}; - - final Set strokes = {}; + final fills = UniqueList.of(); + final strokes = UniqueList.of(); /// Called whenever a new paint mutator is added/removed from the shape paints /// (for example a linear gradient is added to a stroke). diff --git a/lib/src/rive_core/state_machine_controller.dart b/lib/src/rive_core/state_machine_controller.dart index 1e5ef31a..7c5f4dd0 100644 --- a/lib/src/rive_core/state_machine_controller.dart +++ b/lib/src/rive_core/state_machine_controller.dart @@ -39,6 +39,9 @@ import 'package:rive/src/rive_core/shapes/shape.dart'; import 'package:rive/src/rive_core/viewmodel/viewmodel_instance.dart'; import 'package:rive/src/runtime_event.dart'; import 'package:rive_common/math.dart'; +import 'package:stokanal/core.dart' hide Event, Node; + +import '../generated/rive_core_beans.dart'; /// Callback signature for state machine state changes typedef OnStateChange = void Function( @@ -53,6 +56,9 @@ typedef OnLayerStateChange = void Function(LayerState); /// Callback signature for events firing. typedef OnEvent = void Function(RiveEvent); +int _maxIterations = 0; +final _tooManyIterationsCollected = {}; + class LayerController { final StateMachineLayer layer; final StateInstance anyStateInstance; @@ -163,6 +169,15 @@ class LayerController { } } + String _dumpState(StateInstance? state) { + if (state == null) { + return 'null'; + } + var animationState = state.state is AnimationState ? state.state as AnimationState : null; + // return '${state.runtimeType}:${state.state.runtimeType} ${animationState?.animation?.name} > $state ${state.state}'; + return '${animationState?.animation?.name}'; + } + bool apply(CoreContext core, double elapsedSeconds) { if (_currentState != null) { _currentState!.advance(elapsedSeconds, controller); @@ -179,18 +194,27 @@ class LayerController { } _apply(core); - for (int i = 0; updateState(i != 0); i++) { + int i = 0; + for (; updateState(i != 0); i++) { _apply(core); - - if (i == 100) { + if (i == 10) { // Escape hatch, let the user know their logic is causing some kind of // recursive condition. - print('StateMachineController.apply exceeded max iterations.'); - + var runtime = core is RuntimeArtboard ? core : null; + var transition = '${_dumpState(_currentState)} |> ${_dumpState(_stateFrom)}'; + if (_tooManyIterationsCollected.add(transition)) { + Telemetry() + .collect('TOO MANY ITERATIONS > $i max=$_maxIterations | ${core.runtimeType} ${runtime?.artboard.name} | $transition') + .error(StackTrace.current, 'Too many iterations', fatal: false); + } return false; } } + if (i > _maxIterations) { + _maxIterations = i; + } + // give the current state the oportunity to clear spilled time, so that we // do not carry this over into another iteration. _currentState?.clearSpilledTime(); @@ -242,7 +266,7 @@ class LayerController { int index = 0; while (index < transitions.length) { final transitionWeight = - transitions.elementAt(index).evaluatedRandomWeight; + transitions[index].evaluatedRandomWeight; if (currentWeight + transitionWeight > random) { break; } @@ -250,7 +274,7 @@ class LayerController { index += 1; } assert(index < transitions.length); - final transition = transitions.elementAt(index); + final transition = transitions[index]; return transition; } return null; @@ -264,7 +288,11 @@ class LayerController { stateFrom, ignoreTriggers, viewModelInstance); } final transitions = stateFrom.state.transitions; - for (final transition in transitions) { + + final t = transitions.length; + for (var i = 0; i < t; i++) { + // for (final transition in transitions) { + var transition = transitions[i]; var allowed = transition.allowed(stateFrom, controller._inputValues, ignoreTriggers, viewModelInstance); if (allowed == AllowTransition.yes && @@ -362,9 +390,9 @@ class StateMachineController extends RiveAnimationController final _inputValues = HashMap(); final layerControllers = []; final _reportedEvents = []; - // Keep a seperate list of nested events because we also need to store + // Keep a separate list of nested events because we also need to store // the source of the nested event in order to compare to listener target - final Map> _reportedNestedEvents = {}; + final Map> _reportedNestedEvents = HashMap>();//{}; /// Optional callback for state changes final OnStateChange? onStateChange; @@ -512,7 +540,9 @@ class StateMachineController extends RiveAnimationController }); } } - hitShapeLookup.values.toList().forEach(hitComponents.add); + + // hitShapeLookup.values.toList().forEach(hitComponents.add); + hitShapeLookup.values.forEach(hitComponents.add); _artboard = core as RuntimeArtboard; @@ -563,11 +593,11 @@ class StateMachineController extends RiveAnimationController firstDrawable = firstDrawable.prev; } - int hitComponentsCount = hitComponents.length; + final hitComponentsCount = hitComponents.length; int currentSortedIndex = 0; while (firstDrawable != null) { for (var i = currentSortedIndex; i < hitComponentsCount; i++) { - if (hitComponents.elementAt(i).component == firstDrawable) { + if (hitComponents[i].component == firstDrawable) { if (currentSortedIndex != i) { hitComponents.swap(i, currentSortedIndex); } @@ -609,31 +639,48 @@ class StateMachineController extends RiveAnimationController _reportedEvents.clear(); _reportedNestedEvents.clear(); - var listeners = stateMachine.listeners.whereType(); - listeners.forEach((listener) { + // var listeners = stateMachine.listeners.whereType(); + // stateMachine.listeners.whereType().forEach((listener) { + for (final listener in stateMachine.listeners.whereType()) { var listenerTarget = artboard?.context.resolve(listener.targetId); if (listener.listenerType == ListenerType.event) { // Handle events from this artboard if it is the target if (listenerTarget == artboard) { - events.forEach((event) { - if (listener.eventId == event.id) { + // events.forEach((event) { + + var t = events.length; + for (var i = 0; i < t; i++) { + if (listener.eventId == events[i].id) { listener.performChanges(this, Vec2D(), Vec2D()); } - }); + } + // for (final event in events) { + // if (listener.eventId == event.id) { + // listener.performChanges(this, Vec2D(), Vec2D()); + // } + // } + } else { // Handle events from nested artboards nestedEvents.forEach((targetId, eventList) { if (listener.targetId == targetId) { - eventList.forEach((nestedEvent) { - if (listener.eventId == nestedEvent.id) { + + final t = eventList.length; + for (var i = 0; i < t; i++) { + if (listener.eventId == eventList[i].id) { listener.performChanges(this, Vec2D(), Vec2D()); } - }); + } + // for (final nestedEvent in eventList) { + // if (listener.eventId == nestedEvent.id) { + // listener.performChanges(this, Vec2D(), Vec2D()); + // } + // } } }); } } - }); + }//); var riveEvents = []; @@ -643,9 +690,10 @@ class StateMachineController extends RiveAnimationController } riveEvents.add(RiveEvent.fromCoreEvent(event)); } - _eventListeners.toList().forEach((listener) { + // _eventListeners.toList().forEach((listener) { + for (final listener in _eventListeners) { riveEvents.forEach(listener); - }); + }//); } } @@ -757,9 +805,9 @@ class StateMachineController extends RiveAnimationController int objectId, int propertyKey, double elapsedSeconds) { var coreObject = core.resolve(objectId); if (coreObject != null) { - RiveCoreContext.setCallback( + PropertyBeans.get(propertyKey).setCallback( coreObject, - propertyKey, + // propertyKey, CallbackData(this, delay: elapsedSeconds), ); } diff --git a/lib/src/rive_core/text/text.dart b/lib/src/rive_core/text/text.dart index a5f1771b..ea95ed85 100644 --- a/lib/src/rive_core/text/text.dart +++ b/lib/src/rive_core/text/text.dart @@ -1,4 +1,4 @@ -import 'dart:math'; +import 'dart:math' hide log; import 'dart:ui'; import 'package:rive/src/generated/text/text_base.dart'; @@ -76,7 +76,9 @@ class Text extends TextBase with TextStyleContainer implements Sizable { // Shapes that should be cleaned before next shaping call. final List _cleanupShapes = []; BreakLinesResult? _lines; - // TextShapeResult? get shape => _shape; + + /// STOKANAL-FORK-EDIT: exposing + TextShapeResult? get shape => _shape; BreakLinesResult? get lines => _lines; // Used by text effectors. @@ -263,8 +265,13 @@ class Text extends TextBase with TextStyleContainer implements Sizable { } final List _renderStyles = []; + + /// STOKANAL-FORK-EDIT: exposing + List get renderStyles => _renderStyles; + Size _measuredSizeMax = Size.zero; Size _measuredSize = Size.zero; + Size _measure(Size maxSize) { if (_measuredSizeMax == maxSize) { return _measuredSize; @@ -364,6 +371,9 @@ class Text extends TextBase with TextStyleContainer implements Sizable { min(maxSize.height, bounds.height.ceilToDouble())); } + /// STOKANAL-FORK-EDIT: expose method + void buildRenderStyles() => _buildRenderStyles(); + void _buildRenderStyles() { var lines = _lines; var shape = _shape; @@ -669,6 +679,13 @@ class Text extends TextBase with TextStyleContainer implements Sizable { return; } + /// STOKANAL-FORK-EDIT: logging + // if (text == 'F' && Random().nextDouble() < 0.01) { + // log('TEXT DRAW F > ${hashCode} lines=${_lines?.length} shape=${_shape!=null} styles=${_renderStyles.length} runs=${runs.map((r) => '${r.name}=${r.text}').join(",")}'); + // } else if (text == 'C' && Random().nextDouble() < 0.01) { + // log('TEXT DRAW C > ${hashCode} lines=${_lines?.length} shape=${_shape!=null} styles=${_renderStyles.length} runs=${runs.map((r) => '${r.name}=${r.text}').join(",")}'); + // } + if (!clip(canvas)) { canvas.save(); } diff --git a/lib/src/rive_core/text/text_modifier_range.dart b/lib/src/rive_core/text/text_modifier_range.dart index d1a1136b..fc17cb1e 100644 --- a/lib/src/rive_core/text/text_modifier_range.dart +++ b/lib/src/rive_core/text/text_modifier_range.dart @@ -1,4 +1,5 @@ import 'dart:math'; +import 'dart:typed_data'; import 'package:collection/collection.dart'; import 'package:rive/src/core/core.dart'; diff --git a/lib/src/rive_core/text/text_style.dart b/lib/src/rive_core/text/text_style.dart index d47d64da..48e97705 100644 --- a/lib/src/rive_core/text/text_style.dart +++ b/lib/src/rive_core/text/text_style.dart @@ -44,6 +44,16 @@ class TextVariationHelper extends Component { _font = null; } + // @override + // bool dispose() { + // if (!super.dispose()) { + // return false; + // } + // _font?.dispose(); + // _font = null; + // return true; + // } + @override void buildDependencies() { var text = style.text; @@ -56,10 +66,10 @@ class TextVariationHelper extends Component { class TextStyle extends TextStyleBase with ShapePaintContainer, FileAssetReferencer { - final Set _referencers = {}; + final _referencers = {}; Text? get text => parent as Text?; - final Set _variations = {}; - final Set _features = {}; + final _variations = {}; + final _features = {}; Iterable get variations => _variations; Iterable get features => _features; @@ -133,7 +143,13 @@ class TextStyle extends TextStyleBase _variationHelper?.buildDependencies(); } - void removeVariations() => _variations.toSet().forEach(context.removeObject); + // void removeVariations() => _variations.toSet().forEach(context.removeObject); + // void removeVariations() => _variations.forEach(context.removeObject); + void removeVariations() { + for (final v in _variations) { + context.removeObject(v); + } + } @override set asset(FontAsset? value) { diff --git a/lib/src/rive_core/text/text_style_container.dart b/lib/src/rive_core/text/text_style_container.dart index b60336ab..48610951 100644 --- a/lib/src/rive_core/text/text_style_container.dart +++ b/lib/src/rive_core/text/text_style_container.dart @@ -10,7 +10,7 @@ import 'package:rive_common/utilities.dart'; /// file-wide styles by making them owned by an [Artboard] or [Backboard]. abstract class TextStyleContainer { int _nextShaperId = 0; - final Set styles = {}; + final Set styles = {}; // preserve order final HashMap _styleLookup = HashMap(); // TextStyle? styleFromShaperId(int id) => _styleLookup[id]; @@ -42,7 +42,11 @@ abstract class TextStyleContainer { if (!iterableEquals(nextStyles, styles)) { styles.clear(); styles.addAll(nextStyles); - styles.forEach(_registerStyle); + + // styles.forEach(_registerStyle); + for (final s in styles) { + _registerStyle(s); + } } } diff --git a/lib/src/rive_core/transform_component.dart b/lib/src/rive_core/transform_component.dart index a4873389..f4f703d4 100644 --- a/lib/src/rive_core/transform_component.dart +++ b/lib/src/rive_core/transform_component.dart @@ -91,7 +91,7 @@ abstract class TransformComponent extends TransformComponentBase { Mat2D.copy(worldTransform, transform); } - if (_constraints.isNotEmpty) { + if (_constraints.length > 0) { for (final constraint in _constraints) { constraint.constrain(this); } @@ -225,11 +225,23 @@ abstract class TransformComponent extends TransformComponentBase { } // In the runtime, we have to iterate the dependents - dependents.forEach((element) { + + // Unique List + var list = dependentsList; + var t = list.length; + for (var i = 0; i < t; i++) { + var element = list[i]; if (element is TransformComponent) { element.markDirtyIfConstrained(); } - }); + } + + // Set + // for (final element in dependents) { + // if (element is TransformComponent) { + // element.markDirtyIfConstrained(); + // } + // } return true; } diff --git a/lib/src/rive_file.dart b/lib/src/rive_file.dart index fbd879dc..eb501a09 100644 --- a/lib/src/rive_file.dart +++ b/lib/src/rive_file.dart @@ -1,4 +1,5 @@ import 'dart:collection'; +import 'dart:developer'; import 'package:collection/collection.dart'; import 'package:flutter/services.dart'; @@ -14,6 +15,7 @@ import 'package:rive/src/generated/animation/entry_state_base.dart'; import 'package:rive/src/generated/animation/exit_state_base.dart'; import 'package:rive/src/generated/assets/font_asset_base.dart'; import 'package:rive/src/generated/nested_artboard_base.dart'; +import 'package:rive/src/generated/rive_core_beans.dart'; import 'package:rive/src/generated/text/text_base.dart'; import 'package:rive/src/local_file_io.dart' if (dart.library.js_interop) 'package:rive/src/local_file_web.dart'; @@ -41,6 +43,7 @@ import 'package:rive/src/rive_core/viewmodel/viewmodel_instance.dart'; import 'package:rive/src/runtime_nested_artboard.dart'; import 'package:rive_common/rive_text.dart'; import 'package:rive_common/utilities.dart'; +import 'package:stokanal/core.dart' hide log; typedef Core? ObjectGenerator(int coreTypeKey); @@ -67,12 +70,15 @@ Core? _readRuntimeObject(BinaryReader reader, break; } - var fieldType = RiveCoreContext.coreType(propertyKey); + // var fieldType = RiveCoreContext.coreType(propertyKey); + var fieldType = PropertyBeans.get(propertyKey).coreType; + if (fieldType == null || object == null) { _skipProperty(reader, propertyKey, propertyToField); } else { - RiveCoreContext.setObjectProperty( - object, propertyKey, fieldType.deserialize(reader)); + PropertyBeans.get(propertyKey).setObjectProperty(object, fieldType.deserialize(reader)); + // RiveCoreContext.setObjectProperty( + // object, propertyKey, fieldType.deserialize(reader)); } } return object; @@ -97,7 +103,7 @@ int _peekRuntimeObjectType( void _skipProperty(BinaryReader reader, int propertyKey, HashMap propertyToField) { var field = - RiveCoreContext.coreType(propertyKey) ?? propertyToField[propertyKey]; + PropertyBeans.get(propertyKey).coreType ?? propertyToField[propertyKey]; if (field == null) { throw UnsupportedError('Unsupported property key $propertyKey. ' 'A new runtime is likely necessary to play this file.'); @@ -162,12 +168,23 @@ class RiveFile { return false; } + // final String? path; + // late final bool skipInterpolation; + RiveFile._( BinaryReader reader, this.header, ObjectGenerator? generator, - this._assetLoader, - ) { + this._assetLoader, { + String? path, + }) { + + var skipInterpolation = path != null && skipInterpolationRiveFiles.any(path.contains); + if (skipInterpolation) { + log('RIVE-FILE >> $path${skipInterpolation ? ' > SKIP_INTERPOLATION' : ''}'); + } + // debugPrintStack(); + /// Property fields table of contents final propertyToField = _propertyToFieldLookup(header); @@ -314,17 +331,39 @@ class RiveFile { throw const RiveFormatErrorException('Rive file is missing a backboard.'); } + // var objects = 0; + // var keyedProperties = 0; + for (final artboard in _artboards) { var runtimeArtboard = artboard as RuntimeArtboard; - for (final object in runtimeArtboard.objects.whereNotNull()) { - if (object.validate()) { - InternalCoreHelper.markValid(object); + final t = runtimeArtboard.objects.length; + // for (final object in runtimeArtboard.objects.whereNotNull()) { + for (var i = 0; i < t; i++) { + var object = runtimeArtboard.objects[i]; + if (object == null) { + continue; + } + // objects++; + // if (object is KeyedProperty) { + // keyedProperties++; + // } + if (skipInterpolation && object is KeyedProperty) { + object.skipInterpolationTolerance(); + } + + if (kDebugMode && true) { + if (object.validate()) { + InternalCoreHelper.markValid(object); + } else { + throw RiveFormatErrorException('Rive file is corrupt. Invalid $object.'); + } } else { - throw RiveFormatErrorException( - 'Rive file is corrupt. Invalid $object.'); + InternalCoreHelper.markValid(object); } } } + + // log('RIVE-FILE >> $path >> objects=$objects keyedProperties=$keyedProperties'); } /// Imports a Rive file from an array of bytes. @@ -351,17 +390,17 @@ class RiveFile { FileAssetLoader? assetLoader, ObjectGenerator? objectGenerator, bool loadCdnAssets = true, + String? path, }) { - // TODO: in the next major version add an assert here to make this a - // requirement + // TODO: in the next major version add an assert here to make this a requirement if (!_initializedText) { - debugPrint('''Rive: RiveFile.import called before RiveFile.initialize() - -Consider calling `await RiveFile.initialize()` before using `RiveFile.import`'''); + /// STOKANAL-FORK-EDIT + // debugPrint('''Rive: RiveFile.import called before RiveFile.initialize(). Consider calling `await RiveFile.initialize()` before using `RiveFile.import`'''); } var reader = BinaryReader(bytes); return RiveFile._( + path: path, reader, RuntimeHeader.read(reader), objectGenerator, @@ -408,6 +447,7 @@ Consider calling `await RiveFile.initialize()` before using `RiveFile.import`''' FileAssetLoader? assetLoader, bool loadCdnAssets = true, ObjectGenerator? objectGenerator, + String? path, }) async { /// If the file looks like it needs the text runtime, let's load it. if (!_initializedText) { @@ -418,6 +458,7 @@ Consider calling `await RiveFile.initialize()` before using `RiveFile.import`''' assetLoader: assetLoader, loadCdnAssets: loadCdnAssets, objectGenerator: objectGenerator, + path: path, ); } @@ -446,6 +487,7 @@ Consider calling `await RiveFile.initialize()` before using `RiveFile.import`''' assetLoader: assetLoader, loadCdnAssets: loadCdnAssets, objectGenerator: objectGenerator, + path: bundleKey, ); } @@ -492,6 +534,7 @@ Consider calling `await RiveFile.initialize()` before using `RiveFile.import`''' assetLoader: assetLoader, loadCdnAssets: loadCdnAssets, objectGenerator: objectGenerator, + path: path, ); } diff --git a/lib/src/runtime_artboard.dart b/lib/src/runtime_artboard.dart index ca9594a3..dfcf67fd 100644 --- a/lib/src/runtime_artboard.dart +++ b/lib/src/runtime_artboard.dart @@ -1,8 +1,12 @@ +import 'dart:developer'; + +import 'package:collection/collection.dart'; import 'package:flutter/scheduler.dart'; import 'package:rive/rive.dart'; import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/notifier.dart'; +// import 'package:stokanal/core.dart'; /// Adds getters for linear animations and state machines extension RuntimeArtboardGetters on RuntimeArtboard { @@ -91,31 +95,32 @@ extension ArtboardRuntimeExtensions on Artboard { /// directly referenced. Use the Artboard type for any direct interactions with /// an artboard, and use extension methods to add functionality to Artboard. class RuntimeArtboard extends Artboard implements CoreContext { - final _redraw = Notifier(); - ChangeNotifier get redraw => _redraw; + @nonVirtual + final redraw = Notifier(); + // ChangeNotifier get redraw => _redraw; /// Note that objects must be nullable as some may not resolve during load due /// to format differences. - final List _objects = []; + @nonVirtual + final objects = []; + // Iterable get objects => _objects; - Iterable get objects => _objects; - final Set _needDependenciesBuilt = {}; + final _needDependenciesBuilt = {}; - // Indicates if this artboard is playing or paused + /// Indicates if this artboard is playing or paused bool _isPlaying = true; @override T? addObject(T? object) { object?.context = this; - object?.id = _objects.length; - - _objects.add(object); + object?.id = objects.length; + objects.add(object); return object; } @override void removeObject(T object) { - _objects.remove(object); + objects.remove(object); } @override @@ -156,10 +161,10 @@ class RuntimeArtboard extends Artboard implements CoreContext { @override T? resolve(int id) { - if (id >= _objects.length || id < 0) { + if (id < 0 || id >= objects.length) { return null; } - var object = _objects[id]; + var object = objects[id]; if (object is T) { return object as T; } @@ -168,10 +173,10 @@ class RuntimeArtboard extends Artboard implements CoreContext { @override T resolveWithDefault(int id, T defaultValue) { - if (id < 0 || id >= _objects.length) { + if (id < 0 || id >= objects.length) { return defaultValue; } - var object = _objects[id]; + var object = objects[id]; if (object is T) { return object as T; } @@ -189,7 +194,7 @@ class RuntimeArtboard extends Artboard implements CoreContext { @override void markNeedsAdvance() { - _redraw.notify(); + redraw.notify(); } @override @@ -198,24 +203,40 @@ class RuntimeArtboard extends Artboard implements CoreContext { artboard.context = artboard; artboard.frameOrigin = frameOrigin; artboard.copy(this); - artboard._objects.add(artboard); + artboard.objects.add(artboard); // First copy the objects ensuring onAddedDirty can later find them in the // _objects list. - for (final object in _objects.skip(1)) { - Core? clone = object?.clone(); - artboard.addObject(clone); + + var t = objects.length; + // for (final object in _objects.skip(1)) { + for (var i = 1; i < t; i++) { + // Core? clone = object?.clone(); + // artboard.addObject(clone); + artboard.addObject(objects[i]?.clone()); } // Then run the onAddedDirty loop. - for (final object in artboard.objects.skip(1)) { + t = artboard.objects.length; + // for (final object in artboard.objects.skip(1)) { + for (var i = 1; i < t; i++) { + var object = artboard.objects[i]; if (object is Component && object.parentId == ComponentBase.parentIdInitialValue) { object.parent = artboard; } object?.onAddedDirty(); } - animations.forEach(artboard.animations.add); - for (final object in artboard.objects.toList(growable: false)) { + + t = animations.length; + // for (final a in animations) { + for (var i = 0; i < t; i++) { + artboard.animations.add(animations[i]); + } + + t = artboard.objects.length; + // for (final object in artboard.objects) { + for (var i = 0; i < t; i++) { + var object = artboard.objects[i]; if (object == null) { continue; } @@ -223,10 +244,31 @@ class RuntimeArtboard extends Artboard implements CoreContext { InternalCoreHelper.markValid(object); } artboard.clean(); + return artboard; } + /// STOKANAL-FORK-EDIT: Reuse this object for every animation + void dump() { + log(toString()); + log(objects + .map((o) => o.runtimeType) + .groupListsBy((o) => o) + .entries + .sorted((e1, e2) => e2.value.length - e1.value.length) + .map((e) => '${e.key}: ${e.value.length}') + .join('\n')); + } + + /// STOKANAL-FORK-EDIT: Reuse this object for every animation + @override + String toString() { + // LinearAnimation.dump(); // uncomment to dump animations + return 'RuntimeArtboard[$name ${objects.length}]'; + } + void addNestedEventListener(StateMachineController controller) { + activeNestedArtboards.forEach((artboard) { if (artboard.mountedArtboard is RuntimeMountedArtboard) { (artboard.mountedArtboard as RuntimeMountedArtboard).eventCallback = @@ -257,4 +299,9 @@ class RuntimeArtboard extends Artboard implements CoreContext { @override bool get isPlaying => _isPlaying; + + // @override + void dispose() { + // log('DISPOSING > $runtimeType ${artboard.name}'); + } } diff --git a/lib/src/runtime_event.dart b/lib/src/runtime_event.dart index 113c6322..ab9593ad 100644 --- a/lib/src/runtime_event.dart +++ b/lib/src/runtime_event.dart @@ -1,3 +1,5 @@ +import 'dart:collection'; + import 'package:flutter/widgets.dart'; import 'package:rive/src/rive_core/custom_property_boolean.dart'; import 'package:rive/src/rive_core/custom_property_number.dart'; @@ -28,7 +30,7 @@ class RiveEvent { }); factory RiveEvent.fromCoreEvent(Event event) { - final Map properties = {}; + final Map properties = HashMap();//{}; for (final property in event.customProperties) { dynamic value; switch (property.coreType) { diff --git a/lib/src/runtime_mounted_artboard.dart b/lib/src/runtime_mounted_artboard.dart index 7553fdf5..eb02c4b7 100644 --- a/lib/src/runtime_mounted_artboard.dart +++ b/lib/src/runtime_mounted_artboard.dart @@ -19,7 +19,7 @@ abstract class RuntimeEventReporter { class RuntimeMountedArtboard extends MountedArtboard { NestedArtboard nestedArtboard; final RuntimeArtboard artboardInstance; - final Set _runtimeEventListeners = {}; + final _runtimeEventListeners = {}; Size originalArtboardInstanceSize = const Size(0, 0); Set get controllers => diff --git a/lib/src/state_transition_conditions.dart b/lib/src/state_transition_conditions.dart index b25d8588..a03689b8 100644 --- a/lib/src/state_transition_conditions.dart +++ b/lib/src/state_transition_conditions.dart @@ -1,20 +1,26 @@ import 'dart:collection'; +import 'package:flutter/foundation.dart'; import 'package:rive/src/rive_core/animation/transition_condition.dart'; class StateTransitionConditions extends ListBase { - final List _values = []; - List get values => _values.cast(); + + // final List _values = []; + // List get values => _values.cast(); + + @nonVirtual + // @override + final List values = []; // has to be nullable + // List get values => _values.cast(); @override - int get length => _values.length; + int get length => values.length; @override - set length(int value) => _values.length = value; + set length(int value) => values.length = value; @override - TransitionCondition operator [](int index) => _values[index]!; + TransitionCondition operator [](int index) => values[index]!; @override - void operator []=(int index, TransitionCondition value) => - _values[index] = value; + void operator []=(int index, TransitionCondition value) => values[index] = value; } diff --git a/lib/src/widgets/rive_animation.dart b/lib/src/widgets/rive_animation.dart index c8d61775..ea80526b 100644 --- a/lib/src/widgets/rive_animation.dart +++ b/lib/src/widgets/rive_animation.dart @@ -227,12 +227,32 @@ class RiveAnimationState extends State { } /// Loads [RiveFile] and calls [_init] - Future _configure() async { + // Future _configure() async { + void _configure() { if (!mounted) return; - _init(await _loadRiveFile()); + // log('RIVE-ANIMATION CONFIGURE $runtimeType:$hashCode > ${widget.artboard}:${widget.file}'); + // debugPrintStack(maxFrames: 10); + + _loadRiveFile().then(_init); + // _init(await _loadRiveFile()); } + /// STOKANAL-FORK-EDIT: start + /// This is a workaround to allow for embedded Rive animations. It hacks the Flutter State flow. + // @override + // RiveAnimation get widget => _widget??super.widget; + // RiveAnimation? _widget; + // @override + // bool get mounted => (_widget != null) ? true : super.mounted; + // @override + // void setState(VoidCallback fn) => (_widget != null) ? fn() : super.setState(fn); + // Future init(RiveAnimation widget) async { + // _widget = widget; + // initState(); + // } + /// STOKANAL-FORK-EDIT: end + /// Loads the correct Rive file depending on [widget.src] Future _loadRiveFile() { switch (widget.src) { @@ -266,10 +286,10 @@ class RiveAnimationState extends State { if (widget.name != oldWidget.name || widget.file != oldWidget.file || widget.src != oldWidget.src) { - _configure(); // Rife file has changed + _configure(); // Rive file has changed } else if (_requiresInit(oldWidget)) { if (_riveFile == null) { - _configure(); // Rife file not yet loaded + _configure(); // Rive file not yet loaded } else { _init(_riveFile!); } @@ -296,9 +316,11 @@ class RiveAnimationState extends State { } // Clear current local controllers. - _controllers.forEach((c) { + // _controllers.forEach((c) { + for (final c in _controllers) { c.dispose(); - }); + } + _controllers.clear(); final artboard = (widget.artboard != null @@ -341,7 +363,7 @@ class RiveAnimationState extends State { setState(() => _artboard = artboard); // Call the onInit callback if provided - widget.onInit?.call(_artboard!); + widget.onInit?.call(artboard); } @override diff --git a/pubspec.yaml b/pubspec.yaml index df07780c..23891e56 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,17 +3,23 @@ version: 0.13.20 homepage: https://rive.app description: Rive Flutter Runtime. This package provides runtime functionality for playing back and interacting with animations built with the Rive editor available at https://rive.app. repository: https://github.com/rive-app/rive-flutter -topics: - - animation - - ui - - effects - - widgets - - widget + +publish_to: none # STOKANAL-FORK-EDIT: added to include stokanal path dependency + +# topics: + # - animation + # - ui + # - effects + # - widgets + # - widget +# - environment: sdk: ">=2.17.0 <4.0.0" flutter: ">=2.5.0" + dependencies: collection: ^1.15.0 +# ffi: ^2.1.4 flutter: sdk: flutter flutter_web_plugins: @@ -22,8 +28,18 @@ dependencies: meta: ^1.3.0 plugin_platform_interface: ^2.0.2 rive_common: 0.4.15 + + # STOKANAL-FORK-EDIT: added stokanal + stokanal: + path: ../stokanal-flutter/ +# git: +# url: https://github.com/kaypora-games/stokanal-flutter.git +# ref: develop + dev_dependencies: flutter_test: sdk: flutter mocktail: - path: ^1.8.3 \ No newline at end of file + path: ^1.8.3 + +# see STOKANAL-FORK-EDIT for edits against the fork \ No newline at end of file diff --git a/test/rive_animation_test.dart b/test/rive_animation_test.dart index 7d523995..ef05bebd 100644 --- a/test/rive_animation_test.dart +++ b/test/rive_animation_test.dart @@ -269,7 +269,7 @@ void main() { riveFile.mainArtboard, 'State Machine 1'); expect(controller, isNotNull); - Set receivedEvents = {}; + var receivedEvents = {}; controller!.addEventListener((event) { receivedEvents.add(event.name); }); @@ -316,7 +316,7 @@ void main() { riveFile.mainArtboard, 'State Machine 1'); expect(controller, isNotNull); - Set receivedEvents = {}; + var receivedEvents = {}; controller!.addEventListener((event) { receivedEvents.add(event.name); });