mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-06-23 23:46:42 +08:00
Updating for latest rive editor changes (events & nested animation sync).
This commit is contained in:
@ -22,6 +22,7 @@ export 'package:rive/src/core/importers/state_machine_importer.dart';
|
|||||||
export 'package:rive/src/core/importers/state_machine_layer_importer.dart';
|
export 'package:rive/src/core/importers/state_machine_layer_importer.dart';
|
||||||
export 'package:rive/src/core/importers/state_machine_listener_importer.dart';
|
export 'package:rive/src/core/importers/state_machine_listener_importer.dart';
|
||||||
export 'package:rive/src/core/importers/state_transition_importer.dart';
|
export 'package:rive/src/core/importers/state_transition_importer.dart';
|
||||||
|
export 'package:rive/src/event_list.dart';
|
||||||
export 'package:rive/src/generated/rive_core_context.dart';
|
export 'package:rive/src/generated/rive_core_context.dart';
|
||||||
export 'package:rive/src/listener_actions.dart';
|
export 'package:rive/src/listener_actions.dart';
|
||||||
export 'package:rive/src/runtime_artboard.dart';
|
export 'package:rive/src/runtime_artboard.dart';
|
||||||
|
20
lib/src/event_list.dart
Normal file
20
lib/src/event_list.dart
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import 'dart:collection';
|
||||||
|
import 'package:rive/src/rive_core/event.dart';
|
||||||
|
|
||||||
|
class EventList extends ListBase<Event> {
|
||||||
|
// Lame way to do this due to how ListBase needs to expand a nullable list.
|
||||||
|
final List<Event?> _values = [];
|
||||||
|
List<Event> get values => _values.cast<Event>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get length => _values.length;
|
||||||
|
|
||||||
|
@override
|
||||||
|
set length(int value) => _values.length = value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Event operator [](int index) => _values[index]!;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void operator []=(int index, Event value) => _values[index] = value;
|
||||||
|
}
|
43
lib/src/generated/custom_property_boolean_base.dart
Normal file
43
lib/src/generated/custom_property_boolean_base.dart
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/// Core automatically generated
|
||||||
|
/// lib/src/generated/custom_property_boolean_base.dart.
|
||||||
|
/// Do not modify manually.
|
||||||
|
|
||||||
|
import 'package:rive/src/rive_core/component.dart';
|
||||||
|
|
||||||
|
abstract class CustomPropertyBooleanBase extends Component {
|
||||||
|
static const int typeKey = 129;
|
||||||
|
@override
|
||||||
|
int get coreType => CustomPropertyBooleanBase.typeKey;
|
||||||
|
@override
|
||||||
|
Set<int> get coreTypes =>
|
||||||
|
{CustomPropertyBooleanBase.typeKey, ComponentBase.typeKey};
|
||||||
|
|
||||||
|
/// --------------------------------------------------------------------------
|
||||||
|
/// PropertyValue field with key 245.
|
||||||
|
static const bool propertyValueInitialValue = false;
|
||||||
|
bool _propertyValue = propertyValueInitialValue;
|
||||||
|
static const int propertyValuePropertyKey = 245;
|
||||||
|
bool get propertyValue => _propertyValue;
|
||||||
|
|
||||||
|
/// Change the [_propertyValue] field value.
|
||||||
|
/// [propertyValueChanged] will be invoked only if the field's value has
|
||||||
|
/// changed.
|
||||||
|
set propertyValue(bool value) {
|
||||||
|
if (_propertyValue == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool from = _propertyValue;
|
||||||
|
_propertyValue = value;
|
||||||
|
if (hasValidated) {
|
||||||
|
propertyValueChanged(from, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void propertyValueChanged(bool from, bool to);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void copy(covariant CustomPropertyBooleanBase source) {
|
||||||
|
super.copy(source);
|
||||||
|
_propertyValue = source._propertyValue;
|
||||||
|
}
|
||||||
|
}
|
43
lib/src/generated/custom_property_number_base.dart
Normal file
43
lib/src/generated/custom_property_number_base.dart
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/// Core automatically generated
|
||||||
|
/// lib/src/generated/custom_property_number_base.dart.
|
||||||
|
/// Do not modify manually.
|
||||||
|
|
||||||
|
import 'package:rive/src/rive_core/component.dart';
|
||||||
|
|
||||||
|
abstract class CustomPropertyNumberBase extends Component {
|
||||||
|
static const int typeKey = 127;
|
||||||
|
@override
|
||||||
|
int get coreType => CustomPropertyNumberBase.typeKey;
|
||||||
|
@override
|
||||||
|
Set<int> get coreTypes =>
|
||||||
|
{CustomPropertyNumberBase.typeKey, ComponentBase.typeKey};
|
||||||
|
|
||||||
|
/// --------------------------------------------------------------------------
|
||||||
|
/// PropertyValue field with key 243.
|
||||||
|
static const double propertyValueInitialValue = 0;
|
||||||
|
double _propertyValue = propertyValueInitialValue;
|
||||||
|
static const int propertyValuePropertyKey = 243;
|
||||||
|
double get propertyValue => _propertyValue;
|
||||||
|
|
||||||
|
/// Change the [_propertyValue] field value.
|
||||||
|
/// [propertyValueChanged] will be invoked only if the field's value has
|
||||||
|
/// changed.
|
||||||
|
set propertyValue(double value) {
|
||||||
|
if (_propertyValue == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double from = _propertyValue;
|
||||||
|
_propertyValue = value;
|
||||||
|
if (hasValidated) {
|
||||||
|
propertyValueChanged(from, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void propertyValueChanged(double from, double to);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void copy(covariant CustomPropertyNumberBase source) {
|
||||||
|
super.copy(source);
|
||||||
|
_propertyValue = source._propertyValue;
|
||||||
|
}
|
||||||
|
}
|
43
lib/src/generated/custom_property_string_base.dart
Normal file
43
lib/src/generated/custom_property_string_base.dart
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/// Core automatically generated
|
||||||
|
/// lib/src/generated/custom_property_string_base.dart.
|
||||||
|
/// Do not modify manually.
|
||||||
|
|
||||||
|
import 'package:rive/src/rive_core/component.dart';
|
||||||
|
|
||||||
|
abstract class CustomPropertyStringBase extends Component {
|
||||||
|
static const int typeKey = 130;
|
||||||
|
@override
|
||||||
|
int get coreType => CustomPropertyStringBase.typeKey;
|
||||||
|
@override
|
||||||
|
Set<int> get coreTypes =>
|
||||||
|
{CustomPropertyStringBase.typeKey, ComponentBase.typeKey};
|
||||||
|
|
||||||
|
/// --------------------------------------------------------------------------
|
||||||
|
/// PropertyValue field with key 246.
|
||||||
|
static const String propertyValueInitialValue = '';
|
||||||
|
String _propertyValue = propertyValueInitialValue;
|
||||||
|
static const int propertyValuePropertyKey = 246;
|
||||||
|
String get propertyValue => _propertyValue;
|
||||||
|
|
||||||
|
/// Change the [_propertyValue] field value.
|
||||||
|
/// [propertyValueChanged] will be invoked only if the field's value has
|
||||||
|
/// changed.
|
||||||
|
set propertyValue(String value) {
|
||||||
|
if (_propertyValue == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String from = _propertyValue;
|
||||||
|
_propertyValue = value;
|
||||||
|
if (hasValidated) {
|
||||||
|
propertyValueChanged(from, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void propertyValueChanged(String from, String to);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void copy(covariant CustomPropertyStringBase source) {
|
||||||
|
super.copy(source);
|
||||||
|
_propertyValue = source._propertyValue;
|
||||||
|
}
|
||||||
|
}
|
48
lib/src/generated/event_base.dart
Normal file
48
lib/src/generated/event_base.dart
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/// Core automatically generated lib/src/generated/event_base.dart.
|
||||||
|
/// Do not modify manually.
|
||||||
|
|
||||||
|
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';
|
||||||
|
|
||||||
|
abstract class EventBase extends ContainerComponent {
|
||||||
|
static const int typeKey = 128;
|
||||||
|
@override
|
||||||
|
int get coreType => EventBase.typeKey;
|
||||||
|
@override
|
||||||
|
Set<int> get coreTypes => {
|
||||||
|
EventBase.typeKey,
|
||||||
|
ContainerComponentBase.typeKey,
|
||||||
|
ComponentBase.typeKey
|
||||||
|
};
|
||||||
|
|
||||||
|
/// --------------------------------------------------------------------------
|
||||||
|
/// Type field with key 244.
|
||||||
|
static const String typeInitialValue = '';
|
||||||
|
String _type = typeInitialValue;
|
||||||
|
static const int typePropertyKey = 244;
|
||||||
|
|
||||||
|
/// Intent of the event.
|
||||||
|
String get type => _type;
|
||||||
|
|
||||||
|
/// Change the [_type] field value.
|
||||||
|
/// [typeChanged] will be invoked only if the field's value has changed.
|
||||||
|
set type(String value) {
|
||||||
|
if (_type == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String from = _type;
|
||||||
|
_type = value;
|
||||||
|
if (hasValidated) {
|
||||||
|
typeChanged(from, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void typeChanged(String from, String to);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void copy(covariant EventBase source) {
|
||||||
|
super.copy(source);
|
||||||
|
_type = source._type;
|
||||||
|
}
|
||||||
|
}
|
@ -87,8 +87,12 @@ import 'package:rive/src/rive_core/constraints/rotation_constraint.dart';
|
|||||||
import 'package:rive/src/rive_core/constraints/scale_constraint.dart';
|
import 'package:rive/src/rive_core/constraints/scale_constraint.dart';
|
||||||
import 'package:rive/src/rive_core/constraints/transform_constraint.dart';
|
import 'package:rive/src/rive_core/constraints/transform_constraint.dart';
|
||||||
import 'package:rive/src/rive_core/constraints/translation_constraint.dart';
|
import 'package:rive/src/rive_core/constraints/translation_constraint.dart';
|
||||||
|
import 'package:rive/src/rive_core/custom_property_boolean.dart';
|
||||||
|
import 'package:rive/src/rive_core/custom_property_number.dart';
|
||||||
|
import 'package:rive/src/rive_core/custom_property_string.dart';
|
||||||
import 'package:rive/src/rive_core/draw_rules.dart';
|
import 'package:rive/src/rive_core/draw_rules.dart';
|
||||||
import 'package:rive/src/rive_core/draw_target.dart';
|
import 'package:rive/src/rive_core/draw_target.dart';
|
||||||
|
import 'package:rive/src/rive_core/event.dart';
|
||||||
import 'package:rive/src/rive_core/nested_artboard.dart';
|
import 'package:rive/src/rive_core/nested_artboard.dart';
|
||||||
import 'package:rive/src/rive_core/node.dart';
|
import 'package:rive/src/rive_core/node.dart';
|
||||||
import 'package:rive/src/rive_core/shapes/clipping_shape.dart';
|
import 'package:rive/src/rive_core/shapes/clipping_shape.dart';
|
||||||
@ -121,6 +125,8 @@ class RiveCoreContext {
|
|||||||
switch (typeKey) {
|
switch (typeKey) {
|
||||||
case DrawTargetBase.typeKey:
|
case DrawTargetBase.typeKey:
|
||||||
return DrawTarget();
|
return DrawTarget();
|
||||||
|
case CustomPropertyNumberBase.typeKey:
|
||||||
|
return CustomPropertyNumber();
|
||||||
case DistanceConstraintBase.typeKey:
|
case DistanceConstraintBase.typeKey:
|
||||||
return DistanceConstraint();
|
return DistanceConstraint();
|
||||||
case IKConstraintBase.typeKey:
|
case IKConstraintBase.typeKey:
|
||||||
@ -263,8 +269,12 @@ class RiveCoreContext {
|
|||||||
return Image();
|
return Image();
|
||||||
case CubicDetachedVertexBase.typeKey:
|
case CubicDetachedVertexBase.typeKey:
|
||||||
return CubicDetachedVertex();
|
return CubicDetachedVertex();
|
||||||
|
case EventBase.typeKey:
|
||||||
|
return Event();
|
||||||
case DrawRulesBase.typeKey:
|
case DrawRulesBase.typeKey:
|
||||||
return DrawRules();
|
return DrawRules();
|
||||||
|
case CustomPropertyBooleanBase.typeKey:
|
||||||
|
return CustomPropertyBoolean();
|
||||||
case ArtboardBase.typeKey:
|
case ArtboardBase.typeKey:
|
||||||
return Artboard();
|
return Artboard();
|
||||||
case BackboardBase.typeKey:
|
case BackboardBase.typeKey:
|
||||||
@ -277,6 +287,8 @@ class RiveCoreContext {
|
|||||||
return Skin();
|
return Skin();
|
||||||
case TendonBase.typeKey:
|
case TendonBase.typeKey:
|
||||||
return Tendon();
|
return Tendon();
|
||||||
|
case CustomPropertyStringBase.typeKey:
|
||||||
|
return CustomPropertyString();
|
||||||
case FolderBase.typeKey:
|
case FolderBase.typeKey:
|
||||||
return Folder();
|
return Folder();
|
||||||
case ImageAssetBase.typeKey:
|
case ImageAssetBase.typeKey:
|
||||||
@ -310,6 +322,11 @@ class RiveCoreContext {
|
|||||||
object.placementValue = value;
|
object.placementValue = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CustomPropertyNumberBase.propertyValuePropertyKey:
|
||||||
|
if (object is CustomPropertyNumberBase && value is double) {
|
||||||
|
object.propertyValue = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ConstraintBase.strengthPropertyKey:
|
case ConstraintBase.strengthPropertyKey:
|
||||||
if (object is ConstraintBase && value is double) {
|
if (object is ConstraintBase && value is double) {
|
||||||
object.strength = value;
|
object.strength = value;
|
||||||
@ -1005,11 +1022,21 @@ class RiveCoreContext {
|
|||||||
object.outDistance = value;
|
object.outDistance = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case EventBase.typePropertyKey:
|
||||||
|
if (object is EventBase && value is String) {
|
||||||
|
object.type = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DrawRulesBase.drawTargetIdPropertyKey:
|
case DrawRulesBase.drawTargetIdPropertyKey:
|
||||||
if (object is DrawRulesBase && value is int) {
|
if (object is DrawRulesBase && value is int) {
|
||||||
object.drawTargetId = value;
|
object.drawTargetId = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CustomPropertyBooleanBase.propertyValuePropertyKey:
|
||||||
|
if (object is CustomPropertyBooleanBase && value is bool) {
|
||||||
|
object.propertyValue = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ArtboardBase.clipPropertyKey:
|
case ArtboardBase.clipPropertyKey:
|
||||||
if (object is ArtboardBase && value is bool) {
|
if (object is ArtboardBase && value is bool) {
|
||||||
object.clip = value;
|
object.clip = value;
|
||||||
@ -1130,6 +1157,11 @@ class RiveCoreContext {
|
|||||||
object.ty = value;
|
object.ty = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CustomPropertyStringBase.propertyValuePropertyKey:
|
||||||
|
if (object is CustomPropertyStringBase && value is String) {
|
||||||
|
object.propertyValue = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case AssetBase.namePropertyKey:
|
case AssetBase.namePropertyKey:
|
||||||
if (object is AssetBase && value is String) {
|
if (object is AssetBase && value is String) {
|
||||||
object.name = value;
|
object.name = value;
|
||||||
@ -1169,6 +1201,8 @@ class RiveCoreContext {
|
|||||||
case ComponentBase.namePropertyKey:
|
case ComponentBase.namePropertyKey:
|
||||||
case AnimationBase.namePropertyKey:
|
case AnimationBase.namePropertyKey:
|
||||||
case StateMachineComponentBase.namePropertyKey:
|
case StateMachineComponentBase.namePropertyKey:
|
||||||
|
case EventBase.typePropertyKey:
|
||||||
|
case CustomPropertyStringBase.propertyValuePropertyKey:
|
||||||
case AssetBase.namePropertyKey:
|
case AssetBase.namePropertyKey:
|
||||||
return stringType;
|
return stringType;
|
||||||
case ComponentBase.parentIdPropertyKey:
|
case ComponentBase.parentIdPropertyKey:
|
||||||
@ -1232,6 +1266,7 @@ class RiveCoreContext {
|
|||||||
case TendonBase.boneIdPropertyKey:
|
case TendonBase.boneIdPropertyKey:
|
||||||
case FileAssetBase.assetIdPropertyKey:
|
case FileAssetBase.assetIdPropertyKey:
|
||||||
return uintType;
|
return uintType;
|
||||||
|
case CustomPropertyNumberBase.propertyValuePropertyKey:
|
||||||
case ConstraintBase.strengthPropertyKey:
|
case ConstraintBase.strengthPropertyKey:
|
||||||
case DistanceConstraintBase.distancePropertyKey:
|
case DistanceConstraintBase.distancePropertyKey:
|
||||||
case TransformComponentConstraintBase.copyFactorPropertyKey:
|
case TransformComponentConstraintBase.copyFactorPropertyKey:
|
||||||
@ -1336,6 +1371,7 @@ class RiveCoreContext {
|
|||||||
case PointsPathBase.isClosedPropertyKey:
|
case PointsPathBase.isClosedPropertyKey:
|
||||||
case RectangleBase.linkCornerRadiusPropertyKey:
|
case RectangleBase.linkCornerRadiusPropertyKey:
|
||||||
case ClippingShapeBase.isVisiblePropertyKey:
|
case ClippingShapeBase.isVisiblePropertyKey:
|
||||||
|
case CustomPropertyBooleanBase.propertyValuePropertyKey:
|
||||||
case ArtboardBase.clipPropertyKey:
|
case ArtboardBase.clipPropertyKey:
|
||||||
return boolType;
|
return boolType;
|
||||||
case KeyFrameColorBase.valuePropertyKey:
|
case KeyFrameColorBase.valuePropertyKey:
|
||||||
@ -1358,6 +1394,10 @@ class RiveCoreContext {
|
|||||||
return (object as AnimationBase).name;
|
return (object as AnimationBase).name;
|
||||||
case StateMachineComponentBase.namePropertyKey:
|
case StateMachineComponentBase.namePropertyKey:
|
||||||
return (object as StateMachineComponentBase).name;
|
return (object as StateMachineComponentBase).name;
|
||||||
|
case EventBase.typePropertyKey:
|
||||||
|
return (object as EventBase).type;
|
||||||
|
case CustomPropertyStringBase.propertyValuePropertyKey:
|
||||||
|
return (object as CustomPropertyStringBase).propertyValue;
|
||||||
case AssetBase.namePropertyKey:
|
case AssetBase.namePropertyKey:
|
||||||
return (object as AssetBase).name;
|
return (object as AssetBase).name;
|
||||||
}
|
}
|
||||||
@ -1492,6 +1532,8 @@ class RiveCoreContext {
|
|||||||
|
|
||||||
static double getDouble(Core object, int propertyKey) {
|
static double getDouble(Core object, int propertyKey) {
|
||||||
switch (propertyKey) {
|
switch (propertyKey) {
|
||||||
|
case CustomPropertyNumberBase.propertyValuePropertyKey:
|
||||||
|
return (object as CustomPropertyNumberBase).propertyValue;
|
||||||
case ConstraintBase.strengthPropertyKey:
|
case ConstraintBase.strengthPropertyKey:
|
||||||
return (object as ConstraintBase).strength;
|
return (object as ConstraintBase).strength;
|
||||||
case DistanceConstraintBase.distancePropertyKey:
|
case DistanceConstraintBase.distancePropertyKey:
|
||||||
@ -1704,6 +1746,8 @@ class RiveCoreContext {
|
|||||||
return (object as RectangleBase).linkCornerRadius;
|
return (object as RectangleBase).linkCornerRadius;
|
||||||
case ClippingShapeBase.isVisiblePropertyKey:
|
case ClippingShapeBase.isVisiblePropertyKey:
|
||||||
return (object as ClippingShapeBase).isVisible;
|
return (object as ClippingShapeBase).isVisible;
|
||||||
|
case CustomPropertyBooleanBase.propertyValuePropertyKey:
|
||||||
|
return (object as CustomPropertyBooleanBase).propertyValue;
|
||||||
case ArtboardBase.clipPropertyKey:
|
case ArtboardBase.clipPropertyKey:
|
||||||
return (object as ArtboardBase).clip;
|
return (object as ArtboardBase).clip;
|
||||||
}
|
}
|
||||||
@ -1749,6 +1793,16 @@ class RiveCoreContext {
|
|||||||
object.name = value;
|
object.name = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case EventBase.typePropertyKey:
|
||||||
|
if (object is EventBase) {
|
||||||
|
object.type = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CustomPropertyStringBase.propertyValuePropertyKey:
|
||||||
|
if (object is CustomPropertyStringBase) {
|
||||||
|
object.propertyValue = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case AssetBase.namePropertyKey:
|
case AssetBase.namePropertyKey:
|
||||||
if (object is AssetBase) {
|
if (object is AssetBase) {
|
||||||
object.name = value;
|
object.name = value;
|
||||||
@ -2064,6 +2118,11 @@ class RiveCoreContext {
|
|||||||
|
|
||||||
static void setDouble(Core object, int propertyKey, double value) {
|
static void setDouble(Core object, int propertyKey, double value) {
|
||||||
switch (propertyKey) {
|
switch (propertyKey) {
|
||||||
|
case CustomPropertyNumberBase.propertyValuePropertyKey:
|
||||||
|
if (object is CustomPropertyNumberBase) {
|
||||||
|
object.propertyValue = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ConstraintBase.strengthPropertyKey:
|
case ConstraintBase.strengthPropertyKey:
|
||||||
if (object is ConstraintBase) {
|
if (object is ConstraintBase) {
|
||||||
object.strength = value;
|
object.strength = value;
|
||||||
@ -2584,6 +2643,11 @@ class RiveCoreContext {
|
|||||||
object.isVisible = value;
|
object.isVisible = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CustomPropertyBooleanBase.propertyValuePropertyKey:
|
||||||
|
if (object is CustomPropertyBooleanBase) {
|
||||||
|
object.propertyValue = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ArtboardBase.clipPropertyKey:
|
case ArtboardBase.clipPropertyKey:
|
||||||
if (object is ArtboardBase) {
|
if (object is ArtboardBase) {
|
||||||
object.clip = value;
|
object.clip = value;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
abstract class Interpolator {
|
abstract class Interpolator {
|
||||||
int get id;
|
int get id;
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ export 'package:rive/src/generated/animation/nested_linear_animation_base.dart';
|
|||||||
/// Need this abstraction to not depend on package:rive in rive_core.
|
/// Need this abstraction to not depend on package:rive in rive_core.
|
||||||
// ignore: one_member_abstracts
|
// ignore: one_member_abstracts
|
||||||
abstract class NestedLinearAnimationInstance {
|
abstract class NestedLinearAnimationInstance {
|
||||||
bool needsApply = true;
|
|
||||||
void goto(double value);
|
void goto(double value);
|
||||||
double get durationSeconds;
|
double get durationSeconds;
|
||||||
|
|
||||||
@ -37,15 +36,12 @@ abstract class NestedLinearAnimation extends NestedLinearAnimationBase {
|
|||||||
bool get isEnabled => true;
|
bool get isEnabled => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void mixChanged(double from, double to) {
|
void mixChanged(double from, double to) {}
|
||||||
linearAnimationInstance?.needsApply = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool advance(double elapsedSeconds, MountedArtboard mountedArtboard) {
|
bool advance(double elapsedSeconds, MountedArtboard mountedArtboard) {
|
||||||
if (linearAnimationInstance?.needsApply ?? false) {
|
if (linearAnimationInstance != null) {
|
||||||
linearAnimationInstance!.apply(mountedArtboard, mix);
|
linearAnimationInstance!.apply(mountedArtboard, mix);
|
||||||
linearAnimationInstance!.needsApply = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -11,6 +11,7 @@ import 'package:rive/src/rive_core/component_dirt.dart';
|
|||||||
import 'package:rive/src/rive_core/draw_rules.dart';
|
import 'package:rive/src/rive_core/draw_rules.dart';
|
||||||
import 'package:rive/src/rive_core/draw_target.dart';
|
import 'package:rive/src/rive_core/draw_target.dart';
|
||||||
import 'package:rive/src/rive_core/drawable.dart';
|
import 'package:rive/src/rive_core/drawable.dart';
|
||||||
|
import 'package:rive/src/rive_core/event.dart';
|
||||||
import 'package:rive/src/rive_core/math/vec2d.dart';
|
import 'package:rive/src/rive_core/math/vec2d.dart';
|
||||||
import 'package:rive/src/rive_core/nested_artboard.dart';
|
import 'package:rive/src/rive_core/nested_artboard.dart';
|
||||||
import 'package:rive/src/rive_core/rive_animation_controller.dart';
|
import 'package:rive/src/rive_core/rive_animation_controller.dart';
|
||||||
@ -76,10 +77,14 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
|||||||
List<Drawable> get drawables => _drawables;
|
List<Drawable> get drawables => _drawables;
|
||||||
|
|
||||||
final AnimationList _animations = AnimationList();
|
final AnimationList _animations = AnimationList();
|
||||||
|
final EventList _events = EventList();
|
||||||
|
|
||||||
/// List of animations and state machines in the artboard.
|
/// 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;
|
||||||
|
|
||||||
/// List of linear animations in the artboard.
|
/// List of linear animations in the artboard.
|
||||||
Iterable<LinearAnimation> get linearAnimations =>
|
Iterable<LinearAnimation> get linearAnimations =>
|
||||||
_animations.whereType<LinearAnimation>();
|
_animations.whereType<LinearAnimation>();
|
||||||
@ -359,6 +364,25 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_events.add(event);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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);
|
||||||
|
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
/// The animation controllers that are called back whenever the artboard
|
/// The animation controllers that are called back whenever the artboard
|
||||||
/// advances.
|
/// advances.
|
||||||
final Set<RiveAnimationController> _animationControllers = {};
|
final Set<RiveAnimationController> _animationControllers = {};
|
||||||
|
@ -3,14 +3,9 @@ import 'package:rive/src/generated/assets/drawable_asset_base.dart';
|
|||||||
export 'package:rive/src/generated/assets/drawable_asset_base.dart';
|
export 'package:rive/src/generated/assets/drawable_asset_base.dart';
|
||||||
|
|
||||||
abstract class DrawableAsset extends DrawableAssetBase {
|
abstract class DrawableAsset extends DrawableAssetBase {
|
||||||
DrawableAsset();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void heightChanged(double from, double to) {}
|
void heightChanged(double from, double to) {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void widthChanged(double from, double to) {}
|
void widthChanged(double from, double to) {}
|
||||||
|
|
||||||
@override
|
|
||||||
void assetIdChanged(int from, int to) {}
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ class ImageAsset extends ImageAssetBase {
|
|||||||
if (_image == image) {
|
if (_image == image) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_image = image;
|
_image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,8 +38,10 @@ class ImageAsset extends ImageAssetBase {
|
|||||||
..asset = this
|
..asset = this
|
||||||
..name = name;
|
..name = name;
|
||||||
|
|
||||||
/// The editor works with images as PNGs, even if their sources may have come
|
static final imageExtensions = ['png', 'webp', 'jpeg'];
|
||||||
/// from other formats.
|
|
||||||
@override
|
@override
|
||||||
String get fileExtension => 'png';
|
String get fileExtension => imageExtensions[format];
|
||||||
|
|
||||||
|
int get format => 0;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,9 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
|||||||
|
|
||||||
// Note that this isn't a setter as we don't want anything externally changing
|
// Note that this isn't a setter as we don't want anything externally changing
|
||||||
// the artboard.
|
// the artboard.
|
||||||
void _changeArtboard(Artboard? value) {
|
@protected
|
||||||
|
@mustCallSuper
|
||||||
|
void changeArtboard(Artboard? value) {
|
||||||
if (_artboard == value) {
|
if (_artboard == value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,11 +81,11 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
|||||||
curr = curr.parent, sanity--) {
|
curr = curr.parent, sanity--) {
|
||||||
visitAncestor(curr);
|
visitAncestor(curr);
|
||||||
if (curr is Artboard) {
|
if (curr is Artboard) {
|
||||||
_changeArtboard(curr);
|
changeArtboard(curr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_changeArtboard(null);
|
changeArtboard(null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +224,7 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
|||||||
|
|
||||||
if (artboard != null) {
|
if (artboard != null) {
|
||||||
context.markDependencyOrderDirty();
|
context.markDependencyOrderDirty();
|
||||||
_changeArtboard(null);
|
changeArtboard(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
lib/src/rive_core/custom_property_boolean.dart
Normal file
11
lib/src/rive_core/custom_property_boolean.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import 'package:rive/src/generated/custom_property_boolean_base.dart';
|
||||||
|
export 'package:rive/src/generated/custom_property_boolean_base.dart';
|
||||||
|
|
||||||
|
/// A custom property value stored in the hierarchy with a boolean value.
|
||||||
|
class CustomPropertyBoolean extends CustomPropertyBooleanBase {
|
||||||
|
@override
|
||||||
|
void update(int dirt) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void propertyValueChanged(bool from, bool to) {}
|
||||||
|
}
|
11
lib/src/rive_core/custom_property_number.dart
Normal file
11
lib/src/rive_core/custom_property_number.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import 'package:rive/src/generated/custom_property_number_base.dart';
|
||||||
|
export 'package:rive/src/generated/custom_property_number_base.dart';
|
||||||
|
|
||||||
|
/// A custom property value stored in the hierarchy with a numeric value.
|
||||||
|
class CustomPropertyNumber extends CustomPropertyNumberBase {
|
||||||
|
@override
|
||||||
|
void update(int dirt) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void propertyValueChanged(double from, double to) {}
|
||||||
|
}
|
11
lib/src/rive_core/custom_property_string.dart
Normal file
11
lib/src/rive_core/custom_property_string.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import 'package:rive/src/generated/custom_property_string_base.dart';
|
||||||
|
export 'package:rive/src/generated/custom_property_string_base.dart';
|
||||||
|
|
||||||
|
/// A custom property value stored in the hierarchy with a string value.
|
||||||
|
class CustomPropertyString extends CustomPropertyStringBase {
|
||||||
|
@override
|
||||||
|
void update(int dirt) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void propertyValueChanged(String from, String to) {}
|
||||||
|
}
|
@ -1,7 +1,19 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:rive/src/generated/event_base.dart';
|
||||||
|
import 'package:rive/src/rive_core/artboard.dart';
|
||||||
|
|
||||||
// Just a way to get around the protected notifyListeners so we can use trigger
|
export 'package:rive/src/generated/event_base.dart';
|
||||||
// multiple events from a single object.
|
|
||||||
class Event extends ChangeNotifier {
|
class Event extends EventBase {
|
||||||
void notify() => notifyListeners();
|
@override
|
||||||
|
void typeChanged(String from, String to) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void update(int dirt) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void changeArtboard(Artboard? value) {
|
||||||
|
artboard?.internalRemoveEvent(this);
|
||||||
|
super.changeArtboard(value);
|
||||||
|
artboard?.internalAddEvent(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
7
lib/src/rive_core/notifier.dart
Normal file
7
lib/src/rive_core/notifier.dart
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
// Just a way to get around the protected notifyListeners so we can use trigger
|
||||||
|
// multiple events from a single object.
|
||||||
|
class Notifier extends ChangeNotifier {
|
||||||
|
void notify() => notifyListeners();
|
||||||
|
}
|
@ -43,7 +43,9 @@ class Image extends ImageBase
|
|||||||
}
|
}
|
||||||
bool clipped = clip(canvas);
|
bool clipped = clip(canvas);
|
||||||
|
|
||||||
final paint = ui.Paint()..color = ui.Color.fromRGBO(0, 0, 0, renderOpacity);
|
final paint = ui.Paint()
|
||||||
|
..color = ui.Color.fromRGBO(0, 0, 0, renderOpacity)
|
||||||
|
..filterQuality = ui.FilterQuality.high;
|
||||||
|
|
||||||
final width = asset!.width;
|
final width = asset!.width;
|
||||||
final height = asset!.height;
|
final height = asset!.height;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:rive/rive.dart';
|
import 'package:rive/rive.dart';
|
||||||
import 'package:rive/src/core/core.dart';
|
import 'package:rive/src/core/core.dart';
|
||||||
import 'package:rive/src/rive_core/component.dart';
|
import 'package:rive/src/rive_core/component.dart';
|
||||||
import 'package:rive/src/rive_core/event.dart';
|
import 'package:rive/src/rive_core/notifier.dart';
|
||||||
|
|
||||||
/// Adds getters for linear animations and state machines
|
/// Adds getters for linear animations and state machines
|
||||||
extension RuntimeArtboardGetters on RuntimeArtboard {
|
extension RuntimeArtboardGetters on RuntimeArtboard {
|
||||||
@ -18,7 +18,7 @@ extension RuntimeArtboardGetters on RuntimeArtboard {
|
|||||||
/// directly referenced. Use the Artboard type for any direct interactions with
|
/// directly referenced. Use the Artboard type for any direct interactions with
|
||||||
/// an artboard, and use extension methods to add functionality to Artboard.
|
/// an artboard, and use extension methods to add functionality to Artboard.
|
||||||
class RuntimeArtboard extends Artboard implements CoreContext {
|
class RuntimeArtboard extends Artboard implements CoreContext {
|
||||||
final _redraw = Event();
|
final _redraw = Notifier();
|
||||||
ChangeNotifier get redraw => _redraw;
|
ChangeNotifier get redraw => _redraw;
|
||||||
|
|
||||||
/// Note that objects must be nullable as some may not resolve during load due
|
/// Note that objects must be nullable as some may not resolve during load due
|
||||||
|
@ -72,7 +72,6 @@ class RuntimeNestedLinearAnimationInstance
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool advance(double elapsedSeconds) {
|
bool advance(double elapsedSeconds) {
|
||||||
needsApply = true;
|
|
||||||
linearAnimation.advance(elapsedSeconds * speed);
|
linearAnimation.advance(elapsedSeconds * speed);
|
||||||
return linearAnimation.keepGoing;
|
return linearAnimation.keepGoing;
|
||||||
}
|
}
|
||||||
@ -86,7 +85,6 @@ class RuntimeNestedLinearAnimationInstance
|
|||||||
if (localTime == linearAnimation.time) {
|
if (localTime == linearAnimation.time) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
needsApply = true;
|
|
||||||
linearAnimation.time = localTime;
|
linearAnimation.time = localTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user