From 53ea9b583931f31cb2702083c868546d6c3786d9 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Mon, 26 Jul 2021 13:57:57 -0700 Subject: [PATCH] Adding distance constraint. --- .../constraints/distance_constraint_base.dart | 77 +++++++++++++++++++ lib/src/generated/rive_core_context.dart | 30 ++++++++ lib/src/rive_core/animation/animation.dart | 2 +- .../rive_core/animation/animation_state.dart | 3 +- lib/src/rive_core/animation/any_state.dart | 3 +- .../rive_core/animation/blend_animation.dart | 5 +- .../animation/blend_animation_direct.dart | 3 +- lib/src/rive_core/animation/blend_state.dart | 3 +- .../rive_core/animation/blend_state_1d.dart | 3 +- .../animation/blend_state_direct.dart | 2 +- .../animation/blend_state_instance.dart | 2 +- .../animation/blend_state_transition.dart | 3 +- .../animation/cubic_interpolator.dart | 2 +- lib/src/rive_core/animation/entry_state.dart | 3 +- lib/src/rive_core/animation/exit_state.dart | 3 +- lib/src/rive_core/animation/keyed_object.dart | 3 +- .../rive_core/animation/keyed_property.dart | 2 +- lib/src/rive_core/animation/keyframe.dart | 3 +- lib/src/rive_core/animation/layer_state.dart | 3 +- .../rive_core/animation/linear_animation.dart | 3 +- .../rive_core/animation/state_machine.dart | 3 +- .../animation/state_machine_component.dart | 2 +- .../animation/state_machine_input.dart | 3 +- .../animation/state_machine_layer.dart | 5 +- .../rive_core/animation/state_transition.dart | 3 +- .../animation/transition_bool_condition.dart | 4 +- .../animation/transition_condition.dart | 2 +- .../transition_number_condition.dart | 2 +- .../transition_trigger_condition.dart | 3 +- .../animation/transition_value_condition.dart | 3 +- lib/src/rive_core/artboard.dart | 7 +- lib/src/rive_core/bones/bone.dart | 3 +- lib/src/rive_core/bones/cubic_weight.dart | 3 +- lib/src/rive_core/bones/skin.dart | 2 +- lib/src/rive_core/bones/tendon.dart | 3 +- lib/src/rive_core/bones/weight.dart | 3 +- lib/src/rive_core/component.dart | 6 +- lib/src/rive_core/constraints/constraint.dart | 16 ++-- .../constraints/distance_constraint.dart | 63 +++++++++++++++ .../rive_core/constraints/ik_constraint.dart | 8 +- .../constraints/targeted_constraint.dart | 5 +- lib/src/rive_core/container_component.dart | 4 +- lib/src/rive_core/draw_rules.dart | 3 +- lib/src/rive_core/draw_target.dart | 2 +- lib/src/rive_core/drawable.dart | 3 +- lib/src/rive_core/node.dart | 3 +- lib/src/rive_core/shapes/clipping_shape.dart | 3 +- .../shapes/cubic_asymmetric_vertex.dart | 3 +- .../shapes/cubic_detached_vertex.dart | 3 +- .../shapes/cubic_mirrored_vertex.dart | 3 +- lib/src/rive_core/shapes/cubic_vertex.dart | 3 +- lib/src/rive_core/shapes/ellipse.dart | 2 +- lib/src/rive_core/shapes/paint/fill.dart | 3 +- .../rive_core/shapes/paint/gradient_stop.dart | 2 +- .../shapes/paint/linear_gradient.dart | 3 +- .../rive_core/shapes/paint/shape_paint.dart | 3 +- .../rive_core/shapes/paint/solid_color.dart | 3 +- lib/src/rive_core/shapes/paint/stroke.dart | 3 +- lib/src/rive_core/shapes/paint/trim_path.dart | 2 +- lib/src/rive_core/shapes/parametric_path.dart | 3 +- lib/src/rive_core/shapes/path.dart | 3 +- lib/src/rive_core/shapes/path_vertex.dart | 3 +- lib/src/rive_core/shapes/points_path.dart | 2 +- lib/src/rive_core/shapes/polygon.dart | 2 +- lib/src/rive_core/shapes/rectangle.dart | 3 +- lib/src/rive_core/shapes/shape.dart | 2 +- lib/src/rive_core/shapes/star.dart | 3 +- lib/src/rive_core/shapes/straight_vertex.dart | 3 +- lib/src/rive_core/shapes/triangle.dart | 2 +- .../rive_core/state_machine_controller.dart | 2 +- lib/src/rive_core/transform_component.dart | 7 +- 71 files changed, 267 insertions(+), 126 deletions(-) create mode 100644 lib/src/generated/constraints/distance_constraint_base.dart create mode 100644 lib/src/rive_core/constraints/distance_constraint.dart diff --git a/lib/src/generated/constraints/distance_constraint_base.dart b/lib/src/generated/constraints/distance_constraint_base.dart new file mode 100644 index 0000000..8aba167 --- /dev/null +++ b/lib/src/generated/constraints/distance_constraint_base.dart @@ -0,0 +1,77 @@ +/// Core automatically generated +/// lib/src/generated/constraints/distance_constraint_base.dart. +/// Do not modify manually. + +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/rive_core/constraints/targeted_constraint.dart'; + +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 + }; + + /// -------------------------------------------------------------------------- + /// Distance field with key 177. + static const double distanceInitialValue = 100.0; + double _distance = distanceInitialValue; + static const int distancePropertyKey = 177; + + /// The unit distance the constraint will move the constrained object relative + /// to the target. + double get distance => _distance; + + /// Change the [_distance] field value. + /// [distanceChanged] will be invoked only if the field's value has changed. + set distance(double value) { + if (_distance == value) { + return; + } + double from = _distance; + _distance = value; + if (hasValidated) { + distanceChanged(from, value); + } + } + + void distanceChanged(double from, double to); + + /// -------------------------------------------------------------------------- + /// ModeValue field with key 178. + static const int modeValueInitialValue = 0; + int _modeValue = modeValueInitialValue; + static const int modeValuePropertyKey = 178; + + /// Backing value for the mode enum. + int get modeValue => _modeValue; + + /// Change the [_modeValue] field value. + /// [modeValueChanged] will be invoked only if the field's value has changed. + set modeValue(int value) { + if (_modeValue == value) { + return; + } + int from = _modeValue; + _modeValue = value; + if (hasValidated) { + modeValueChanged(from, value); + } + } + + void modeValueChanged(int from, int to); + + @override + void copy(DistanceConstraintBase source) { + super.copy(source); + _distance = source._distance; + _modeValue = source._modeValue; + } +} diff --git a/lib/src/generated/rive_core_context.dart b/lib/src/generated/rive_core_context.dart index 201fa46..9147962 100644 --- a/lib/src/generated/rive_core_context.dart +++ b/lib/src/generated/rive_core_context.dart @@ -46,6 +46,7 @@ import 'package:rive/src/generated/bones/tendon_base.dart'; import 'package:rive/src/generated/bones/weight_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/distance_constraint_base.dart'; import 'package:rive/src/generated/constraints/ik_constraint_base.dart'; import 'package:rive/src/generated/constraints/targeted_constraint_base.dart'; import 'package:rive/src/generated/draw_rules_base.dart'; @@ -110,6 +111,7 @@ import 'package:rive/src/rive_core/bones/root_bone.dart'; import 'package:rive/src/rive_core/bones/skin.dart'; import 'package:rive/src/rive_core/bones/tendon.dart'; import 'package:rive/src/rive_core/bones/weight.dart'; +import 'package:rive/src/rive_core/constraints/distance_constraint.dart'; import 'package:rive/src/rive_core/constraints/ik_constraint.dart'; import 'package:rive/src/rive_core/draw_rules.dart'; import 'package:rive/src/rive_core/draw_target.dart'; @@ -140,6 +142,8 @@ class RiveCoreContext { switch (typeKey) { case DrawTargetBase.typeKey: return DrawTarget(); + case DistanceConstraintBase.typeKey: + return DistanceConstraint(); case IKConstraintBase.typeKey: return IKConstraint(); case AnimationStateBase.typeKey: @@ -289,6 +293,16 @@ 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; + } + break; case IKConstraintBase.invertDirectionPropertyKey: if (object is IKConstraintBase && value is bool) { object.invertDirection = value; @@ -917,6 +931,7 @@ class RiveCoreContext { case DrawTargetBase.drawableIdPropertyKey: case DrawTargetBase.placementValuePropertyKey: case TargetedConstraintBase.targetIdPropertyKey: + case DistanceConstraintBase.modeValuePropertyKey: case IKConstraintBase.parentBoneCountPropertyKey: case AnimationStateBase.animationIdPropertyKey: case KeyedObjectBase.objectIdPropertyKey: @@ -960,6 +975,7 @@ class RiveCoreContext { case TendonBase.boneIdPropertyKey: return uintType; case ConstraintBase.strengthPropertyKey: + case DistanceConstraintBase.distancePropertyKey: case StateMachineNumberBase.valuePropertyKey: case TransitionNumberConditionBase.valuePropertyKey: case CubicInterpolatorBase.x1PropertyKey: @@ -1069,6 +1085,8 @@ class RiveCoreContext { return (object as DrawTargetBase).placementValue; case TargetedConstraintBase.targetIdPropertyKey: return (object as TargetedConstraintBase).targetId; + case DistanceConstraintBase.modeValuePropertyKey: + return (object as DistanceConstraintBase).modeValue; case IKConstraintBase.parentBoneCountPropertyKey: return (object as IKConstraintBase).parentBoneCount; case AnimationStateBase.animationIdPropertyKey: @@ -1159,6 +1177,8 @@ class RiveCoreContext { switch (propertyKey) { case ConstraintBase.strengthPropertyKey: return (object as ConstraintBase).strength; + case DistanceConstraintBase.distancePropertyKey: + return (object as DistanceConstraintBase).distance; case StateMachineNumberBase.valuePropertyKey: return (object as StateMachineNumberBase).value; case TransitionNumberConditionBase.valuePropertyKey: @@ -1375,6 +1395,11 @@ class RiveCoreContext { object.targetId = value; } break; + case DistanceConstraintBase.modeValuePropertyKey: + if (object is DistanceConstraintBase) { + object.modeValue = value; + } + break; case IKConstraintBase.parentBoneCountPropertyKey: if (object is IKConstraintBase) { object.parentBoneCount = value; @@ -1590,6 +1615,11 @@ class RiveCoreContext { object.strength = value; } break; + case DistanceConstraintBase.distancePropertyKey: + if (object is DistanceConstraintBase) { + object.distance = value; + } + break; case StateMachineNumberBase.valuePropertyKey: if (object is StateMachineNumberBase) { object.value = value; diff --git a/lib/src/rive_core/animation/animation.dart b/lib/src/rive_core/animation/animation.dart index a56dbcb..0fabb31 100644 --- a/lib/src/rive_core/animation/animation.dart +++ b/lib/src/rive_core/animation/animation.dart @@ -1,7 +1,7 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/animation_base.dart'; import 'package:rive/src/rive_core/artboard.dart'; +import 'package:rive/src/generated/animation/animation_base.dart'; export 'package:rive/src/generated/animation/animation_base.dart'; class Animation extends AnimationBase { diff --git a/lib/src/rive_core/animation/animation_state.dart b/lib/src/rive_core/animation/animation_state.dart index e6d6303..f0805fa 100644 --- a/lib/src/rive_core/animation/animation_state.dart +++ b/lib/src/rive_core/animation/animation_state.dart @@ -1,10 +1,9 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/animation_state_base.dart'; import 'package:rive/src/rive_core/animation/animation_state_instance.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; import 'package:rive/src/rive_core/artboard.dart'; - +import 'package:rive/src/generated/animation/animation_state_base.dart'; export 'package:rive/src/generated/animation/animation_state_base.dart'; class AnimationState extends AnimationStateBase { diff --git a/lib/src/rive_core/animation/any_state.dart b/lib/src/rive_core/animation/any_state.dart index 19fb579..d1d2376 100644 --- a/lib/src/rive_core/animation/any_state.dart +++ b/lib/src/rive_core/animation/any_state.dart @@ -1,6 +1,5 @@ -import 'package:rive/src/generated/animation/any_state_base.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; - +import 'package:rive/src/generated/animation/any_state_base.dart'; export 'package:rive/src/generated/animation/any_state_base.dart'; class AnyState extends AnyStateBase { diff --git a/lib/src/rive_core/animation/blend_animation.dart b/lib/src/rive_core/animation/blend_animation.dart index 786cf3b..3b0fee1 100644 --- a/lib/src/rive_core/animation/blend_animation.dart +++ b/lib/src/rive_core/animation/blend_animation.dart @@ -1,10 +1,9 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/blend_animation_base.dart'; -import 'package:rive/src/generated/artboard_base.dart'; import 'package:rive/src/rive_core/animation/layer_state.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/artboard.dart'; - +import 'package:rive/src/generated/animation/blend_animation_base.dart'; +import 'package:rive/src/generated/artboard_base.dart'; export 'package:rive/src/generated/animation/blend_animation_base.dart'; abstract class BlendAnimation extends BlendAnimationBase { diff --git a/lib/src/rive_core/animation/blend_animation_direct.dart b/lib/src/rive_core/animation/blend_animation_direct.dart index 6771a85..8fe9e8e 100644 --- a/lib/src/rive_core/animation/blend_animation_direct.dart +++ b/lib/src/rive_core/animation/blend_animation_direct.dart @@ -1,8 +1,7 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/blend_animation_direct_base.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart'; import 'package:rive/src/rive_core/animation/state_machine_number.dart'; - +import 'package:rive/src/generated/animation/blend_animation_direct_base.dart'; export 'package:rive/src/generated/animation/blend_animation_direct_base.dart'; class BlendAnimationDirect extends BlendAnimationDirectBase { diff --git a/lib/src/rive_core/animation/blend_state.dart b/lib/src/rive_core/animation/blend_state.dart index 91d74cb..2fe958c 100644 --- a/lib/src/rive_core/animation/blend_state.dart +++ b/lib/src/rive_core/animation/blend_state.dart @@ -1,7 +1,6 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/blend_state_base.dart'; import 'package:rive/src/rive_core/animation/blend_animation.dart'; - +import 'package:rive/src/generated/animation/blend_state_base.dart'; export 'package:rive/src/generated/animation/blend_state_base.dart'; // diff --git a/lib/src/rive_core/animation/blend_state_1d.dart b/lib/src/rive_core/animation/blend_state_1d.dart index dce4a42..4ec0589 100644 --- a/lib/src/rive_core/animation/blend_state_1d.dart +++ b/lib/src/rive_core/animation/blend_state_1d.dart @@ -1,10 +1,9 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/blend_state_1d_base.dart'; import 'package:rive/src/rive_core/animation/blend_state_1d_instance.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart'; import 'package:rive/src/rive_core/animation/state_machine_number.dart'; - +import 'package:rive/src/generated/animation/blend_state_1d_base.dart'; export 'package:rive/src/generated/animation/blend_state_1d_base.dart'; class BlendState1D extends BlendState1DBase { diff --git a/lib/src/rive_core/animation/blend_state_direct.dart b/lib/src/rive_core/animation/blend_state_direct.dart index 4abc4cf..07c2bdf 100644 --- a/lib/src/rive_core/animation/blend_state_direct.dart +++ b/lib/src/rive_core/animation/blend_state_direct.dart @@ -1,6 +1,6 @@ -import 'package:rive/src/generated/animation/blend_state_direct_base.dart'; import 'package:rive/src/rive_core/animation/blend_state_direct_instance.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; +import 'package:rive/src/generated/animation/blend_state_direct_base.dart'; export 'package:rive/src/generated/animation/blend_state_direct_base.dart'; diff --git a/lib/src/rive_core/animation/blend_state_instance.dart b/lib/src/rive_core/animation/blend_state_instance.dart index d25e594..6076f16 100644 --- a/lib/src/rive_core/animation/blend_state_instance.dart +++ b/lib/src/rive_core/animation/blend_state_instance.dart @@ -1,7 +1,7 @@ import 'dart:collection'; -import 'package:flutter/foundation.dart'; import 'package:rive/src/core/core.dart'; +import 'package:flutter/foundation.dart'; import 'package:rive/src/rive_core/animation/blend_animation.dart'; import 'package:rive/src/rive_core/animation/blend_state.dart'; import 'package:rive/src/rive_core/animation/linear_animation_instance.dart'; diff --git a/lib/src/rive_core/animation/blend_state_transition.dart b/lib/src/rive_core/animation/blend_state_transition.dart index d76c7d0..6b76d5c 100644 --- a/lib/src/rive_core/animation/blend_state_transition.dart +++ b/lib/src/rive_core/animation/blend_state_transition.dart @@ -1,11 +1,10 @@ -import 'package:rive/src/generated/animation/blend_state_transition_base.dart'; import 'package:rive/src/rive_core/animation/blend_animation.dart'; import 'package:rive/src/rive_core/animation/blend_state_instance.dart'; import 'package:rive/src/rive_core/animation/layer_state.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/linear_animation_instance.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; - +import 'package:rive/src/generated/animation/blend_state_transition_base.dart'; export 'package:rive/src/generated/animation/blend_state_transition_base.dart'; class BlendStateTransition extends BlendStateTransitionBase { diff --git a/lib/src/rive_core/animation/cubic_interpolator.dart b/lib/src/rive_core/animation/cubic_interpolator.dart index 0e69d9c..8216745 100644 --- a/lib/src/rive_core/animation/cubic_interpolator.dart +++ b/lib/src/rive_core/animation/cubic_interpolator.dart @@ -1,9 +1,9 @@ import 'dart:typed_data'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/cubic_interpolator_base.dart'; import 'package:rive/src/rive_core/animation/interpolator.dart'; import 'package:rive/src/rive_core/artboard.dart'; +import 'package:rive/src/generated/animation/cubic_interpolator_base.dart'; const int newtonIterations = 4; diff --git a/lib/src/rive_core/animation/entry_state.dart b/lib/src/rive_core/animation/entry_state.dart index ed64e4f..d868ef3 100644 --- a/lib/src/rive_core/animation/entry_state.dart +++ b/lib/src/rive_core/animation/entry_state.dart @@ -1,6 +1,5 @@ -import 'package:rive/src/generated/animation/entry_state_base.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; - +import 'package:rive/src/generated/animation/entry_state_base.dart'; export 'package:rive/src/generated/animation/entry_state_base.dart'; class EntryState extends EntryStateBase { diff --git a/lib/src/rive_core/animation/exit_state.dart b/lib/src/rive_core/animation/exit_state.dart index 5e65ef7..fabdec2 100644 --- a/lib/src/rive_core/animation/exit_state.dart +++ b/lib/src/rive_core/animation/exit_state.dart @@ -1,6 +1,5 @@ -import 'package:rive/src/generated/animation/exit_state_base.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; - +import 'package:rive/src/generated/animation/exit_state_base.dart'; export 'package:rive/src/generated/animation/exit_state_base.dart'; class ExitState extends ExitStateBase { diff --git a/lib/src/rive_core/animation/keyed_object.dart b/lib/src/rive_core/animation/keyed_object.dart index 05cd148..5778cf7 100644 --- a/lib/src/rive_core/animation/keyed_object.dart +++ b/lib/src/rive_core/animation/keyed_object.dart @@ -1,12 +1,11 @@ import 'dart:collection'; 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'; import 'package:rive/src/rive_core/component.dart'; +import 'package:rive/src/generated/animation/keyed_object_base.dart'; import 'linear_animation.dart'; - export 'package:rive/src/generated/animation/keyed_object_base.dart'; class KeyedObject extends KeyedObjectBase { diff --git a/lib/src/rive_core/animation/keyed_property.dart b/lib/src/rive_core/animation/keyed_property.dart index ddc315c..13e3f07 100644 --- a/lib/src/rive_core/animation/keyed_property.dart +++ b/lib/src/rive_core/animation/keyed_property.dart @@ -1,8 +1,8 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/keyed_property_base.dart'; import 'package:rive/src/rive_core/animation/keyed_object.dart'; import 'package:rive/src/rive_core/animation/keyframe.dart'; +import 'package:rive/src/generated/animation/keyed_property_base.dart'; export 'package:rive/src/generated/animation/keyed_property_base.dart'; abstract class KeyFrameInterface { diff --git a/lib/src/rive_core/animation/keyframe.dart b/lib/src/rive_core/animation/keyframe.dart index f777eb4..9d82a62 100644 --- a/lib/src/rive_core/animation/keyframe.dart +++ b/lib/src/rive_core/animation/keyframe.dart @@ -1,10 +1,11 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/keyframe_base.dart'; import 'package:rive/src/rive_core/animation/interpolator.dart'; import 'package:rive/src/rive_core/animation/keyed_property.dart'; import 'package:rive/src/rive_core/animation/keyframe_interpolation.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart'; +import 'package:rive/src/generated/animation/keyframe_base.dart'; + export 'package:rive/src/generated/animation/keyframe_base.dart'; abstract class KeyFrame extends KeyFrameBase diff --git a/lib/src/rive_core/animation/layer_state.dart b/lib/src/rive_core/animation/layer_state.dart index af59609..7f3a1fb 100644 --- a/lib/src/rive_core/animation/layer_state.dart +++ b/lib/src/rive_core/animation/layer_state.dart @@ -1,9 +1,8 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/layer_state_base.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; import 'package:rive/src/rive_core/animation/state_machine_layer.dart'; import 'package:rive/src/rive_core/animation/state_transition.dart'; - +import 'package:rive/src/generated/animation/layer_state_base.dart'; export 'package:rive/src/generated/animation/layer_state_base.dart'; abstract class LayerState extends LayerStateBase { diff --git a/lib/src/rive_core/animation/linear_animation.dart b/lib/src/rive_core/animation/linear_animation.dart index 4593a24..b774e5e 100644 --- a/lib/src/rive_core/animation/linear_animation.dart +++ b/lib/src/rive_core/animation/linear_animation.dart @@ -1,11 +1,10 @@ import 'dart:collection'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/linear_animation_base.dart'; import 'package:rive/src/rive_core/animation/keyed_object.dart'; import 'package:rive/src/rive_core/animation/loop.dart'; import 'package:rive/src/rive_core/artboard.dart'; - +import 'package:rive/src/generated/animation/linear_animation_base.dart'; export 'package:rive/src/generated/animation/linear_animation_base.dart'; class LinearAnimation extends LinearAnimationBase { diff --git a/lib/src/rive_core/animation/state_machine.dart b/lib/src/rive_core/animation/state_machine.dart index 208050b..9fa71e4 100644 --- a/lib/src/rive_core/animation/state_machine.dart +++ b/lib/src/rive_core/animation/state_machine.dart @@ -1,9 +1,8 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/state_machine_base.dart'; import 'package:rive/src/rive_core/animation/state_machine_input.dart'; import 'package:rive/src/rive_core/animation/state_machine_layer.dart'; import 'package:rive/src/rive_core/artboard.dart'; - +import 'package:rive/src/generated/animation/state_machine_base.dart'; export 'package:rive/src/generated/animation/state_machine_base.dart'; class StateMachine extends StateMachineBase { diff --git a/lib/src/rive_core/animation/state_machine_component.dart b/lib/src/rive_core/animation/state_machine_component.dart index b8a909e..7805db8 100644 --- a/lib/src/rive_core/animation/state_machine_component.dart +++ b/lib/src/rive_core/animation/state_machine_component.dart @@ -1,8 +1,8 @@ import 'dart:collection'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/state_machine_component_base.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart'; +import 'package:rive/src/generated/animation/state_machine_component_base.dart'; export 'package:rive/src/generated/animation/state_machine_component_base.dart'; diff --git a/lib/src/rive_core/animation/state_machine_input.dart b/lib/src/rive_core/animation/state_machine_input.dart index e25a051..ef801d8 100644 --- a/lib/src/rive_core/animation/state_machine_input.dart +++ b/lib/src/rive_core/animation/state_machine_input.dart @@ -1,9 +1,8 @@ import 'dart:collection'; -import 'package:rive/src/generated/animation/state_machine_input_base.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart'; import 'package:rive/src/rive_core/animation/state_machine_component.dart'; - +import 'package:rive/src/generated/animation/state_machine_input_base.dart'; export 'package:rive/src/generated/animation/state_machine_input_base.dart'; abstract class StateMachineInput extends StateMachineInputBase { diff --git a/lib/src/rive_core/animation/state_machine_layer.dart b/lib/src/rive_core/animation/state_machine_layer.dart index a4e0548..c9f93b5 100644 --- a/lib/src/rive_core/animation/state_machine_layer.dart +++ b/lib/src/rive_core/animation/state_machine_layer.dart @@ -1,14 +1,13 @@ import 'dart:collection'; -import 'package:rive/src/generated/animation/any_state_base.dart'; -import 'package:rive/src/generated/animation/state_machine_layer_base.dart'; import 'package:rive/src/rive_core/animation/any_state.dart'; import 'package:rive/src/rive_core/animation/entry_state.dart'; import 'package:rive/src/rive_core/animation/exit_state.dart'; import 'package:rive/src/rive_core/animation/layer_state.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart'; import 'package:rive/src/rive_core/animation/state_machine_component.dart'; - +import 'package:rive/src/generated/animation/any_state_base.dart'; +import 'package:rive/src/generated/animation/state_machine_layer_base.dart'; export 'package:rive/src/generated/animation/state_machine_layer_base.dart'; class StateMachineLayer extends StateMachineLayerBase { diff --git a/lib/src/rive_core/animation/state_transition.dart b/lib/src/rive_core/animation/state_transition.dart index 13bfdff..84775a7 100644 --- a/lib/src/rive_core/animation/state_transition.dart +++ b/lib/src/rive_core/animation/state_transition.dart @@ -1,7 +1,6 @@ import 'dart:collection'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/state_transition_base.dart'; import 'package:rive/src/rive_core/animation/animation_state.dart'; import 'package:rive/src/rive_core/animation/animation_state_instance.dart'; import 'package:rive/src/rive_core/animation/layer_state.dart'; @@ -11,8 +10,8 @@ import 'package:rive/src/rive_core/animation/loop.dart'; import 'package:rive/src/rive_core/animation/state_instance.dart'; import 'package:rive/src/rive_core/animation/transition_condition.dart'; import 'package:rive/src/rive_core/animation/transition_trigger_condition.dart'; +import 'package:rive/src/generated/animation/state_transition_base.dart'; import 'package:rive/src/rive_core/state_transition_flags.dart'; - export 'package:rive/src/generated/animation/state_transition_base.dart'; enum AllowTransition { no, waitingForExit, yes } diff --git a/lib/src/rive_core/animation/transition_bool_condition.dart b/lib/src/rive_core/animation/transition_bool_condition.dart index eeef836..5e58c47 100644 --- a/lib/src/rive_core/animation/transition_bool_condition.dart +++ b/lib/src/rive_core/animation/transition_bool_condition.dart @@ -1,9 +1,7 @@ import 'dart:collection'; - -import 'package:rive/src/generated/animation/transition_bool_condition_base.dart'; import 'package:rive/src/rive_core/animation/state_machine_bool.dart'; import 'package:rive/src/rive_core/animation/transition_condition.dart'; - +import 'package:rive/src/generated/animation/transition_bool_condition_base.dart'; export 'package:rive/src/generated/animation/transition_bool_condition_base.dart'; class TransitionBoolCondition extends TransitionBoolConditionBase { diff --git a/lib/src/rive_core/animation/transition_condition.dart b/lib/src/rive_core/animation/transition_condition.dart index 4902a2a..99bb49b 100644 --- a/lib/src/rive_core/animation/transition_condition.dart +++ b/lib/src/rive_core/animation/transition_condition.dart @@ -1,9 +1,9 @@ import 'dart:collection'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/animation/transition_condition_base.dart'; import 'package:rive/src/rive_core/animation/state_machine_input.dart'; import 'package:rive/src/rive_core/animation/state_transition.dart'; +import 'package:rive/src/generated/animation/transition_condition_base.dart'; export 'package:rive/src/generated/animation/transition_condition_base.dart'; diff --git a/lib/src/rive_core/animation/transition_number_condition.dart b/lib/src/rive_core/animation/transition_number_condition.dart index 49a0a1c..c4cfa57 100644 --- a/lib/src/rive_core/animation/transition_number_condition.dart +++ b/lib/src/rive_core/animation/transition_number_condition.dart @@ -1,8 +1,8 @@ import 'dart:collection'; -import 'package:rive/src/generated/animation/transition_number_condition_base.dart'; import 'package:rive/src/rive_core/animation/state_machine_number.dart'; import 'package:rive/src/rive_core/animation/transition_condition.dart'; +import 'package:rive/src/generated/animation/transition_number_condition_base.dart'; export 'package:rive/src/generated/animation/transition_number_condition_base.dart'; diff --git a/lib/src/rive_core/animation/transition_trigger_condition.dart b/lib/src/rive_core/animation/transition_trigger_condition.dart index 2a96349..124a2e2 100644 --- a/lib/src/rive_core/animation/transition_trigger_condition.dart +++ b/lib/src/rive_core/animation/transition_trigger_condition.dart @@ -1,8 +1,7 @@ import 'dart:collection'; -import 'package:rive/src/generated/animation/transition_trigger_condition_base.dart'; import 'package:rive/src/rive_core/animation/state_machine_trigger.dart'; - +import 'package:rive/src/generated/animation/transition_trigger_condition_base.dart'; export 'package:rive/src/generated/animation/transition_trigger_condition_base.dart'; class TransitionTriggerCondition extends TransitionTriggerConditionBase { diff --git a/lib/src/rive_core/animation/transition_value_condition.dart b/lib/src/rive_core/animation/transition_value_condition.dart index 62ef412..2a68b87 100644 --- a/lib/src/rive_core/animation/transition_value_condition.dart +++ b/lib/src/rive_core/animation/transition_value_condition.dart @@ -1,6 +1,5 @@ -import 'package:rive/src/generated/animation/transition_value_condition_base.dart'; import 'package:rive/src/rive_core/animation/transition_condition.dart'; - +import 'package:rive/src/generated/animation/transition_value_condition_base.dart'; export 'package:rive/src/generated/animation/transition_value_condition_base.dart'; abstract class TransitionValueCondition extends TransitionValueConditionBase { diff --git a/lib/src/rive_core/artboard.dart b/lib/src/rive_core/artboard.dart index e27fc9b..7cbc173 100644 --- a/lib/src/rive_core/artboard.dart +++ b/lib/src/rive_core/artboard.dart @@ -1,7 +1,6 @@ import 'dart:ui'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/artboard_base.dart'; import 'package:rive/src/rive_core/animation/animation.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart'; @@ -15,6 +14,7 @@ import 'package:rive/src/rive_core/math/vec2d.dart'; import 'package:rive/src/rive_core/rive_animation_controller.dart'; import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart'; import 'package:rive/src/rive_core/shapes/shape_paint_container.dart'; +import 'package:rive/src/generated/artboard_base.dart'; import 'package:rive/src/utilities/dependency_sorter.dart'; export 'package:rive/src/generated/artboard_base.dart'; @@ -129,7 +129,10 @@ class Artboard extends ArtboardBase with ShapePaintContainer { didUpdate = true; } } - return updateComponents() || didUpdate; + if (updateComponents() || didUpdate) { + return true; + } + return false; } @override diff --git a/lib/src/rive_core/bones/bone.dart b/lib/src/rive_core/bones/bone.dart index bd9a0bc..9d0a604 100644 --- a/lib/src/rive_core/bones/bone.dart +++ b/lib/src/rive_core/bones/bone.dart @@ -1,7 +1,6 @@ -import 'package:rive/src/generated/bones/bone_base.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/bones/bone_base.dart'; export 'package:rive/src/generated/bones/bone_base.dart'; typedef bool BoneCallback(Bone bone); diff --git a/lib/src/rive_core/bones/cubic_weight.dart b/lib/src/rive_core/bones/cubic_weight.dart index 7cf795c..45a0ee0 100644 --- a/lib/src/rive_core/bones/cubic_weight.dart +++ b/lib/src/rive_core/bones/cubic_weight.dart @@ -1,6 +1,5 @@ -import 'package:rive/src/generated/bones/cubic_weight_base.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/bones/cubic_weight_base.dart'; export 'package:rive/src/generated/bones/cubic_weight_base.dart'; class CubicWeight extends CubicWeightBase { diff --git a/lib/src/rive_core/bones/skin.dart b/lib/src/rive_core/bones/skin.dart index 24b3062..4512467 100644 --- a/lib/src/rive_core/bones/skin.dart +++ b/lib/src/rive_core/bones/skin.dart @@ -1,11 +1,11 @@ import 'dart:typed_data'; -import 'package:rive/src/generated/bones/skin_base.dart'; import 'package:rive/src/rive_core/bones/skinnable.dart'; import 'package:rive/src/rive_core/bones/tendon.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; +import 'package:rive/src/generated/bones/skin_base.dart'; export 'package:rive/src/generated/bones/skin_base.dart'; diff --git a/lib/src/rive_core/bones/tendon.dart b/lib/src/rive_core/bones/tendon.dart index 71cd818..84a3d14 100644 --- a/lib/src/rive_core/bones/tendon.dart +++ b/lib/src/rive_core/bones/tendon.dart @@ -1,7 +1,6 @@ -import 'package:rive/src/generated/bones/tendon_base.dart'; import 'package:rive/src/rive_core/bones/skeletal_component.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; - +import 'package:rive/src/generated/bones/tendon_base.dart'; export 'package:rive/src/generated/bones/tendon_base.dart'; class Tendon extends TendonBase { diff --git a/lib/src/rive_core/bones/weight.dart b/lib/src/rive_core/bones/weight.dart index 8151184..af4cb82 100644 --- a/lib/src/rive_core/bones/weight.dart +++ b/lib/src/rive_core/bones/weight.dart @@ -1,9 +1,8 @@ import 'dart:typed_data'; -import 'package:rive/src/generated/bones/weight_base.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/bones/weight_base.dart'; export 'package:rive/src/generated/bones/weight_base.dart'; class Weight extends WeightBase { diff --git a/lib/src/rive_core/component.dart b/lib/src/rive_core/component.dart index 2c131af..b5c388a 100644 --- a/lib/src/rive_core/component.dart +++ b/lib/src/rive_core/component.dart @@ -1,11 +1,11 @@ -import 'package:flutter/foundation.dart'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/component_base.dart'; +import 'package:flutter/foundation.dart'; import 'package:rive/src/rive_core/artboard.dart'; import 'package:rive/src/rive_core/container_component.dart'; + +import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/utilities/dependency_sorter.dart'; import 'package:rive/src/utilities/tops.dart'; - export 'package:rive/src/generated/component_base.dart'; abstract class Component extends ComponentBase diff --git a/lib/src/rive_core/constraints/constraint.dart b/lib/src/rive_core/constraints/constraint.dart index 723c18a..5e2d8e6 100644 --- a/lib/src/rive_core/constraints/constraint.dart +++ b/lib/src/rive_core/constraints/constraint.dart @@ -6,21 +6,27 @@ export 'package:rive/src/generated/constraints/constraint_base.dart'; /// providing rules for how to constrain its transform space. abstract class Constraint extends ConstraintBase { /// Returns the [TransformComponent] which this [Constraint] is applied to. - // TransformComponent? get constrainedComponent => - // parent is TransformComponent ? parent as TransformComponent : null; - TransformComponent get constrainedComponent => parent as TransformComponent; + TransformComponent? get constrainedComponent => + parent is TransformComponent ? parent as TransformComponent : null; @override void strengthChanged(double from, double to) => - constrainedComponent.markTransformDirty(); + constrainedComponent?.markTransformDirty(); @override bool validate() => super.validate() && parent is TransformComponent; void constrain(TransformComponent component); + @override + void buildDependencies() { + super.buildDependencies(); + + parent!.addDependent(this); + } + @override void update(int dirt) {} - void markConstraintDirty() => constrainedComponent.markTransformDirty(); + void markConstraintDirty() => constrainedComponent?.markTransformDirty(); } diff --git a/lib/src/rive_core/constraints/distance_constraint.dart b/lib/src/rive_core/constraints/distance_constraint.dart new file mode 100644 index 0000000..319f3ee --- /dev/null +++ b/lib/src/rive_core/constraints/distance_constraint.dart @@ -0,0 +1,63 @@ +import 'package:rive/src/rive_core/math/vec2d.dart'; +import 'package:rive/src/generated/constraints/distance_constraint_base.dart'; +import 'package:rive/src/rive_core/transform_component.dart'; +export 'package:rive/src/generated/constraints/distance_constraint_base.dart'; + +enum DistanceConstraintMode { closer, further, exact } + +const _distanceEpsilon = 0.001; + +/// A constraint which transaltes its constrained component in world space to a +/// certain distance from the [target] based on [mode]. +class DistanceConstraint extends DistanceConstraintBase { + @override + void constrain(TransformComponent component) { + if (target == null) { + return; + } + var targetTranslation = target!.worldTranslation; + var ourTranslation = component.worldTranslation; + + var toTarget = Vec2D.subtract(Vec2D(), ourTranslation, targetTranslation); + var currentDistance = Vec2D.length(toTarget); + switch (mode) { + case DistanceConstraintMode.closer: + if (currentDistance < distance) { + return; + } + break; + case DistanceConstraintMode.further: + if (currentDistance > distance) { + return; + } + break; + case DistanceConstraintMode.exact: + break; + } + if (currentDistance < _distanceEpsilon) { + return; + } + + Vec2D.scale(toTarget, toTarget, 1.0 / currentDistance); + Vec2D.scale(toTarget, toTarget, distance); + + var world = component.worldTransform; + + var position = Vec2D.add(Vec2D(), targetTranslation, toTarget); + Vec2D.lerp(position, ourTranslation, position, strength); + world[4] = position[0]; + world[5] = position[1]; + } + + @override + void distanceChanged(double from, double to) => markConstraintDirty(); + + @override + void modeValueChanged(int from, int to) => markConstraintDirty(); + + DistanceConstraintMode get mode => DistanceConstraintMode.values[modeValue]; + set mode(DistanceConstraintMode value) => modeValue = value.index; + + @override + bool validate() => super.validate() && parent is TransformComponent; +} diff --git a/lib/src/rive_core/constraints/ik_constraint.dart b/lib/src/rive_core/constraints/ik_constraint.dart index 44c3159..faabdd1 100644 --- a/lib/src/rive_core/constraints/ik_constraint.dart +++ b/lib/src/rive_core/constraints/ik_constraint.dart @@ -1,13 +1,11 @@ import 'dart:math'; - -import 'package:rive/src/generated/constraints/ik_constraint_base.dart'; import 'package:rive/src/rive_core/artboard.dart'; import 'package:rive/src/rive_core/bones/bone.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/transform_components.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; +import 'package:rive/src/generated/constraints/ik_constraint_base.dart'; import 'package:rive/src/rive_core/transform_component.dart'; - export 'package:rive/src/generated/constraints/ik_constraint_base.dart'; /// A constraint which rotates its constrained bone and the parentBoneCount @@ -34,12 +32,12 @@ class IKConstraint extends IKConstraintBase { /// The list of bones in FK order. final List<_BoneChainLink> _fkChain = []; + Iterable<_BoneChainLink> get fkChain => _fkChain; + @override void buildDependencies() { super.buildDependencies(); - parent!.addDependent(this); - // Rebuild the FK chain when we update dependencies. _fkChain.clear(); var boneCount = parentBoneCount; diff --git a/lib/src/rive_core/constraints/targeted_constraint.dart b/lib/src/rive_core/constraints/targeted_constraint.dart index 95d9bc3..6498197 100644 --- a/lib/src/rive_core/constraints/targeted_constraint.dart +++ b/lib/src/rive_core/constraints/targeted_constraint.dart @@ -25,7 +25,9 @@ abstract class TargetedConstraint extends TargetedConstraintBase { super.buildDependencies(); // Targeted constraints must have their constrainedComponent update after // the target. - _target?.addDependent(constrainedComponent, via: this); + if (constrainedComponent != null) { + _target?.addDependent(constrainedComponent!, via: this); + } } @override @@ -33,4 +35,5 @@ abstract class TargetedConstraint extends TargetedConstraintBase { super.onAddedDirty(); target = context.resolve(targetId); } + } diff --git a/lib/src/rive_core/container_component.dart b/lib/src/rive_core/container_component.dart index c3d2250..1892e76 100644 --- a/lib/src/rive_core/container_component.dart +++ b/lib/src/rive_core/container_component.dart @@ -1,9 +1,9 @@ -import 'package:flutter/material.dart'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/container_component_base.dart'; +import 'package:flutter/material.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/draw_rules.dart'; import 'package:rive/src/rive_core/drawable.dart'; +import 'package:rive/src/generated/container_component_base.dart'; typedef bool DescentCallback(Component component); diff --git a/lib/src/rive_core/draw_rules.dart b/lib/src/rive_core/draw_rules.dart index 407262d..58ef46d 100644 --- a/lib/src/rive_core/draw_rules.dart +++ b/lib/src/rive_core/draw_rules.dart @@ -1,8 +1,7 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/draw_rules_base.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/draw_target.dart'; - +import 'package:rive/src/generated/draw_rules_base.dart'; export 'package:rive/src/generated/draw_rules_base.dart'; class DrawRules extends DrawRulesBase { diff --git a/lib/src/rive_core/draw_target.dart b/lib/src/rive_core/draw_target.dart index 945e5df..5e20c1b 100644 --- a/lib/src/rive_core/draw_target.dart +++ b/lib/src/rive_core/draw_target.dart @@ -1,6 +1,6 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/draw_target_base.dart'; import 'package:rive/src/rive_core/drawable.dart'; +import 'package:rive/src/generated/draw_target_base.dart'; export 'package:rive/src/generated/draw_target_base.dart'; diff --git a/lib/src/rive_core/drawable.dart b/lib/src/rive_core/drawable.dart index d28c050..2f15f9f 100644 --- a/lib/src/rive_core/drawable.dart +++ b/lib/src/rive_core/drawable.dart @@ -1,13 +1,12 @@ import 'dart:ui'; -import 'package:rive/src/generated/drawable_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/component_flags.dart'; import 'package:rive/src/rive_core/container_component.dart'; import 'package:rive/src/rive_core/draw_rules.dart'; import 'package:rive/src/rive_core/shapes/clipping_shape.dart'; +import 'package:rive/src/generated/drawable_base.dart'; import 'package:rive/src/rive_core/transform_component.dart'; - export 'package:rive/src/generated/drawable_base.dart'; abstract class Drawable extends DrawableBase { diff --git a/lib/src/rive_core/node.dart b/lib/src/rive_core/node.dart index e16f95b..222e777 100644 --- a/lib/src/rive_core/node.dart +++ b/lib/src/rive_core/node.dart @@ -1,7 +1,6 @@ -import 'package:rive/src/generated/node_base.dart'; import 'package:rive/src/rive_core/math/aabb.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/node_base.dart'; export 'package:rive/src/generated/node_base.dart'; class _UnknownNode extends Node {} diff --git a/lib/src/rive_core/shapes/clipping_shape.dart b/lib/src/rive_core/shapes/clipping_shape.dart index 1b24fb2..ef0da44 100644 --- a/lib/src/rive_core/shapes/clipping_shape.dart +++ b/lib/src/rive_core/shapes/clipping_shape.dart @@ -1,10 +1,9 @@ import 'dart:ui'; -import 'package:rive/src/generated/shapes/clipping_shape_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/node.dart'; import 'package:rive/src/rive_core/shapes/shape.dart'; - +import 'package:rive/src/generated/shapes/clipping_shape_base.dart'; export 'package:rive/src/generated/shapes/clipping_shape_base.dart'; class ClippingShape extends ClippingShapeBase { diff --git a/lib/src/rive_core/shapes/cubic_asymmetric_vertex.dart b/lib/src/rive_core/shapes/cubic_asymmetric_vertex.dart index a20ecea..d90304a 100644 --- a/lib/src/rive_core/shapes/cubic_asymmetric_vertex.dart +++ b/lib/src/rive_core/shapes/cubic_asymmetric_vertex.dart @@ -1,10 +1,9 @@ import 'dart:math'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/shapes/cubic_asymmetric_vertex_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/shapes/cubic_asymmetric_vertex_base.dart'; export 'package:rive/src/generated/shapes/cubic_asymmetric_vertex_base.dart'; class CubicAsymmetricVertex extends CubicAsymmetricVertexBase { diff --git a/lib/src/rive_core/shapes/cubic_detached_vertex.dart b/lib/src/rive_core/shapes/cubic_detached_vertex.dart index 48394a1..8e8d4c0 100644 --- a/lib/src/rive_core/shapes/cubic_detached_vertex.dart +++ b/lib/src/rive_core/shapes/cubic_detached_vertex.dart @@ -1,10 +1,9 @@ import 'dart:math'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/shapes/cubic_detached_vertex_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/shapes/cubic_detached_vertex_base.dart'; export 'package:rive/src/generated/shapes/cubic_detached_vertex_base.dart'; class CubicDetachedVertex extends CubicDetachedVertexBase { diff --git a/lib/src/rive_core/shapes/cubic_mirrored_vertex.dart b/lib/src/rive_core/shapes/cubic_mirrored_vertex.dart index fb964ce..31f5514 100644 --- a/lib/src/rive_core/shapes/cubic_mirrored_vertex.dart +++ b/lib/src/rive_core/shapes/cubic_mirrored_vertex.dart @@ -1,10 +1,9 @@ import 'dart:math'; import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/shapes/cubic_mirrored_vertex_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/shapes/cubic_mirrored_vertex_base.dart'; export 'package:rive/src/generated/shapes/cubic_mirrored_vertex_base.dart'; class CubicMirroredVertex extends CubicMirroredVertexBase { diff --git a/lib/src/rive_core/shapes/cubic_vertex.dart b/lib/src/rive_core/shapes/cubic_vertex.dart index e00a74f..25d1bb8 100644 --- a/lib/src/rive_core/shapes/cubic_vertex.dart +++ b/lib/src/rive_core/shapes/cubic_vertex.dart @@ -1,10 +1,9 @@ import 'dart:typed_data'; -import 'package:rive/src/generated/shapes/cubic_vertex_base.dart'; import 'package:rive/src/rive_core/bones/weight.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/shapes/cubic_vertex_base.dart'; export 'package:rive/src/generated/shapes/cubic_vertex_base.dart'; abstract class CubicVertex extends CubicVertexBase { diff --git a/lib/src/rive_core/shapes/ellipse.dart b/lib/src/rive_core/shapes/ellipse.dart index 5febbb0..3afdfc7 100644 --- a/lib/src/rive_core/shapes/ellipse.dart +++ b/lib/src/rive_core/shapes/ellipse.dart @@ -1,7 +1,7 @@ -import 'package:rive/src/generated/shapes/ellipse_base.dart'; import 'package:rive/src/rive_core/math/circle_constant.dart'; import 'package:rive/src/rive_core/shapes/cubic_detached_vertex.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; +import 'package:rive/src/generated/shapes/ellipse_base.dart'; export 'package:rive/src/generated/shapes/ellipse_base.dart'; diff --git a/lib/src/rive_core/shapes/paint/fill.dart b/lib/src/rive_core/shapes/paint/fill.dart index 00f3058..c65f581 100644 --- a/lib/src/rive_core/shapes/paint/fill.dart +++ b/lib/src/rive_core/shapes/paint/fill.dart @@ -1,9 +1,8 @@ import 'dart:ui'; -import 'package:rive/src/generated/shapes/paint/fill_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/shapes/shape_paint_container.dart'; - +import 'package:rive/src/generated/shapes/paint/fill_base.dart'; export 'package:rive/src/generated/shapes/paint/fill_base.dart'; /// A fill Shape painter. diff --git a/lib/src/rive_core/shapes/paint/gradient_stop.dart b/lib/src/rive_core/shapes/paint/gradient_stop.dart index 1e6b1d5..cec815c 100644 --- a/lib/src/rive_core/shapes/paint/gradient_stop.dart +++ b/lib/src/rive_core/shapes/paint/gradient_stop.dart @@ -1,8 +1,8 @@ import 'dart:ui' as ui; -import 'package:rive/src/generated/shapes/paint/gradient_stop_base.dart'; import 'package:rive/src/rive_core/container_component.dart'; import 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart'; +import 'package:rive/src/generated/shapes/paint/gradient_stop_base.dart'; export 'package:rive/src/generated/shapes/paint/gradient_stop_base.dart'; diff --git a/lib/src/rive_core/shapes/paint/linear_gradient.dart b/lib/src/rive_core/shapes/paint/linear_gradient.dart index 488409d..6dea1f0 100644 --- a/lib/src/rive_core/shapes/paint/linear_gradient.dart +++ b/lib/src/rive_core/shapes/paint/linear_gradient.dart @@ -1,14 +1,13 @@ import 'dart:ui' as ui; import 'package:meta/meta.dart'; -import 'package:rive/src/generated/shapes/paint/linear_gradient_base.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; import 'package:rive/src/rive_core/shapes/paint/gradient_stop.dart'; import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart'; import 'package:rive/src/rive_core/shapes/shape.dart'; - +import 'package:rive/src/generated/shapes/paint/linear_gradient_base.dart'; export 'package:rive/src/generated/shapes/paint/linear_gradient_base.dart'; /// A core linear gradient. Can be added as a child to a [Shape]'s [Fill] or diff --git a/lib/src/rive_core/shapes/paint/shape_paint.dart b/lib/src/rive_core/shapes/paint/shape_paint.dart index b97a0b9..4c89b7a 100644 --- a/lib/src/rive_core/shapes/paint/shape_paint.dart +++ b/lib/src/rive_core/shapes/paint/shape_paint.dart @@ -1,14 +1,13 @@ import 'dart:ui'; import 'package:meta/meta.dart'; -import 'package:rive/src/generated/shapes/paint/shape_paint_base.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/container_component.dart'; import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart'; import 'package:rive/src/rive_core/shapes/shape.dart'; import 'package:rive/src/rive_core/shapes/shape_paint_container.dart'; - +import 'package:rive/src/generated/shapes/paint/shape_paint_base.dart'; export 'package:rive/src/generated/shapes/paint/shape_paint_base.dart'; /// Generic ShapePaint that abstracts Stroke and Fill. Automatically hooks up diff --git a/lib/src/rive_core/shapes/paint/solid_color.dart b/lib/src/rive_core/shapes/paint/solid_color.dart index 0bcd170..eb33afa 100644 --- a/lib/src/rive_core/shapes/paint/solid_color.dart +++ b/lib/src/rive_core/shapes/paint/solid_color.dart @@ -1,10 +1,9 @@ import 'dart:ui'; -import 'package:rive/src/generated/shapes/paint/solid_color_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/shapes/paint/shape_paint.dart'; import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart'; - +import 'package:rive/src/generated/shapes/paint/solid_color_base.dart'; export 'package:rive/src/generated/shapes/paint/solid_color_base.dart'; /// A solid color painter for a shape. Works for both Fill and Stroke. diff --git a/lib/src/rive_core/shapes/paint/stroke.dart b/lib/src/rive_core/shapes/paint/stroke.dart index 7e75869..01b11a8 100644 --- a/lib/src/rive_core/shapes/paint/stroke.dart +++ b/lib/src/rive_core/shapes/paint/stroke.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:rive/src/generated/shapes/paint/stroke_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/shapes/paint/stroke_effect.dart'; import 'package:rive/src/rive_core/shapes/shape.dart'; import 'package:rive/src/rive_core/shapes/shape_paint_container.dart'; - +import 'package:rive/src/generated/shapes/paint/stroke_base.dart'; export 'package:rive/src/generated/shapes/paint/stroke_base.dart'; /// A stroke Shape painter. diff --git a/lib/src/rive_core/shapes/paint/trim_path.dart b/lib/src/rive_core/shapes/paint/trim_path.dart index 6a032ec..a97115e 100644 --- a/lib/src/rive_core/shapes/paint/trim_path.dart +++ b/lib/src/rive_core/shapes/paint/trim_path.dart @@ -1,11 +1,11 @@ import 'dart:ui'; -import 'package:rive/src/generated/shapes/paint/trim_path_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/shapes/paint/stroke.dart'; import 'package:rive/src/rive_core/shapes/paint/stroke_effect.dart'; import 'package:rive/src/rive_core/shapes/paint/trim_path_drawing.dart'; +import 'package:rive/src/generated/shapes/paint/trim_path_base.dart'; export 'package:rive/src/generated/shapes/paint/trim_path_base.dart'; enum TrimPathMode { diff --git a/lib/src/rive_core/shapes/parametric_path.dart b/lib/src/rive_core/shapes/parametric_path.dart index 4cb0243..266e548 100644 --- a/lib/src/rive_core/shapes/parametric_path.dart +++ b/lib/src/rive_core/shapes/parametric_path.dart @@ -1,6 +1,5 @@ -import 'package:rive/src/generated/shapes/parametric_path_base.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; - +import 'package:rive/src/generated/shapes/parametric_path_base.dart'; export 'package:rive/src/generated/shapes/parametric_path_base.dart'; abstract class ParametricPath extends ParametricPathBase { diff --git a/lib/src/rive_core/shapes/path.dart b/lib/src/rive_core/shapes/path.dart index 92e3f03..26bfe2f 100644 --- a/lib/src/rive_core/shapes/path.dart +++ b/lib/src/rive_core/shapes/path.dart @@ -1,7 +1,6 @@ import 'dart:math'; import 'dart:ui' as ui; -import 'package:rive/src/generated/shapes/path_base.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/component_flags.dart'; @@ -12,7 +11,7 @@ import 'package:rive/src/rive_core/shapes/cubic_vertex.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; import 'package:rive/src/rive_core/shapes/shape.dart'; import 'package:rive/src/rive_core/shapes/straight_vertex.dart'; - +import 'package:rive/src/generated/shapes/path_base.dart'; export 'package:rive/src/generated/shapes/path_base.dart'; /// An abstract low level path that gets implemented by parametric and point diff --git a/lib/src/rive_core/shapes/path_vertex.dart b/lib/src/rive_core/shapes/path_vertex.dart index 02de297..d2e9508 100644 --- a/lib/src/rive_core/shapes/path_vertex.dart +++ b/lib/src/rive_core/shapes/path_vertex.dart @@ -1,12 +1,11 @@ import 'dart:typed_data'; -import 'package:rive/src/generated/shapes/path_vertex_base.dart'; import 'package:rive/src/rive_core/bones/weight.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; import 'package:rive/src/rive_core/shapes/path.dart'; - +import 'package:rive/src/generated/shapes/path_vertex_base.dart'; export 'package:rive/src/generated/shapes/path_vertex_base.dart'; abstract class PathVertex extends PathVertexBase { diff --git a/lib/src/rive_core/shapes/points_path.dart b/lib/src/rive_core/shapes/points_path.dart index f8cf887..be58fde 100644 --- a/lib/src/rive_core/shapes/points_path.dart +++ b/lib/src/rive_core/shapes/points_path.dart @@ -1,9 +1,9 @@ -import 'package:rive/src/generated/shapes/points_path_base.dart'; import 'package:rive/src/rive_core/bones/skinnable.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; +import 'package:rive/src/generated/shapes/points_path_base.dart'; export 'package:rive/src/generated/shapes/points_path_base.dart'; diff --git a/lib/src/rive_core/shapes/polygon.dart b/lib/src/rive_core/shapes/polygon.dart index 9c44226..de17e4f 100644 --- a/lib/src/rive_core/shapes/polygon.dart +++ b/lib/src/rive_core/shapes/polygon.dart @@ -1,9 +1,9 @@ import 'dart:math'; -import 'package:rive/src/generated/shapes/polygon_base.dart'; import 'package:rive/src/rive_core/bones/weight.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; import 'package:rive/src/rive_core/shapes/straight_vertex.dart'; +import 'package:rive/src/generated/shapes/polygon_base.dart'; export 'package:rive/src/generated/shapes/polygon_base.dart'; diff --git a/lib/src/rive_core/shapes/rectangle.dart b/lib/src/rive_core/shapes/rectangle.dart index a827042..b72149c 100644 --- a/lib/src/rive_core/shapes/rectangle.dart +++ b/lib/src/rive_core/shapes/rectangle.dart @@ -1,7 +1,6 @@ -import 'package:rive/src/generated/shapes/rectangle_base.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; import 'package:rive/src/rive_core/shapes/straight_vertex.dart'; - +import 'package:rive/src/generated/shapes/rectangle_base.dart'; export 'package:rive/src/generated/shapes/rectangle_base.dart'; class Rectangle extends RectangleBase { diff --git a/lib/src/rive_core/shapes/shape.dart b/lib/src/rive_core/shapes/shape.dart index 8c4df11..ec3d9b0 100644 --- a/lib/src/rive_core/shapes/shape.dart +++ b/lib/src/rive_core/shapes/shape.dart @@ -1,7 +1,6 @@ import 'dart:ui' as ui; import 'package:collection/collection.dart'; -import 'package:rive/src/generated/shapes/shape_base.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart' as core; import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart'; @@ -9,6 +8,7 @@ import 'package:rive/src/rive_core/shapes/paint/stroke.dart'; import 'package:rive/src/rive_core/shapes/path.dart'; import 'package:rive/src/rive_core/shapes/path_composer.dart'; import 'package:rive/src/rive_core/shapes/shape_paint_container.dart'; +import 'package:rive/src/generated/shapes/shape_base.dart'; export 'package:rive/src/generated/shapes/shape_base.dart'; diff --git a/lib/src/rive_core/shapes/star.dart b/lib/src/rive_core/shapes/star.dart index accf691..7c69c1d 100644 --- a/lib/src/rive_core/shapes/star.dart +++ b/lib/src/rive_core/shapes/star.dart @@ -1,10 +1,9 @@ import 'dart:math'; -import 'package:rive/src/generated/shapes/star_base.dart'; import 'package:rive/src/rive_core/bones/weight.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; import 'package:rive/src/rive_core/shapes/straight_vertex.dart'; - +import 'package:rive/src/generated/shapes/star_base.dart'; export 'package:rive/src/generated/shapes/star_base.dart'; class Star extends StarBase { diff --git a/lib/src/rive_core/shapes/straight_vertex.dart b/lib/src/rive_core/shapes/straight_vertex.dart index c41d40e..55a130f 100644 --- a/lib/src/rive_core/shapes/straight_vertex.dart +++ b/lib/src/rive_core/shapes/straight_vertex.dart @@ -1,9 +1,8 @@ import 'package:rive/src/core/core.dart'; -import 'package:rive/src/generated/shapes/straight_vertex_base.dart'; import 'package:rive/src/rive_core/bones/weight.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; - +import 'package:rive/src/generated/shapes/straight_vertex_base.dart'; export 'package:rive/src/generated/shapes/straight_vertex_base.dart'; class StraightVertex extends StraightVertexBase { diff --git a/lib/src/rive_core/shapes/triangle.dart b/lib/src/rive_core/shapes/triangle.dart index 7b21422..b218f63 100644 --- a/lib/src/rive_core/shapes/triangle.dart +++ b/lib/src/rive_core/shapes/triangle.dart @@ -1,6 +1,6 @@ -import 'package:rive/src/generated/shapes/triangle_base.dart'; import 'package:rive/src/rive_core/shapes/path_vertex.dart'; import 'package:rive/src/rive_core/shapes/straight_vertex.dart'; +import 'package:rive/src/generated/shapes/triangle_base.dart'; /// Export the Base class for external use (e.g. rive.dart) export 'package:rive/src/generated/shapes/triangle_base.dart'; diff --git a/lib/src/rive_core/state_machine_controller.dart b/lib/src/rive_core/state_machine_controller.dart index 5488bf6..e5ed34a 100644 --- a/lib/src/rive_core/state_machine_controller.dart +++ b/lib/src/rive_core/state_machine_controller.dart @@ -1,8 +1,8 @@ import 'dart:collection'; +import 'package:rive/src/core/core.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/scheduler.dart'; -import 'package:rive/src/core/core.dart'; import 'package:rive/src/rive_core/animation/animation_state.dart'; import 'package:rive/src/rive_core/animation/animation_state_instance.dart'; import 'package:rive/src/rive_core/animation/any_state.dart'; diff --git a/lib/src/rive_core/transform_component.dart b/lib/src/rive_core/transform_component.dart index fe3c490..651e819 100644 --- a/lib/src/rive_core/transform_component.dart +++ b/lib/src/rive_core/transform_component.dart @@ -1,6 +1,4 @@ import 'package:flutter/foundation.dart'; -import 'package:rive/src/generated/shapes/clipping_shape_base.dart'; -import 'package:rive/src/generated/transform_component_base.dart'; import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart'; @@ -11,7 +9,10 @@ import 'package:rive/src/rive_core/drawable.dart'; import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/vec2d.dart'; import 'package:rive/src/rive_core/shapes/clipping_shape.dart'; +import 'package:rive/src/generated/shapes/clipping_shape_base.dart'; +import 'package:rive/src/generated/transform_component_base.dart'; +import 'constraints/distance_constraint.dart'; export 'package:rive/src/generated/transform_component_base.dart'; abstract class TransformComponent extends TransformComponentBase { @@ -165,6 +166,7 @@ abstract class TransformComponent extends TransformComponentBase { break; case IKConstraintBase.typeKey: + case DistanceConstraintBase.typeKey: _constraints.add(child as Constraint); break; } @@ -186,6 +188,7 @@ abstract class TransformComponent extends TransformComponentBase { } break; case IKConstraintBase.typeKey: + case DistanceConstraintBase.typeKey: _constraints.remove(child as Constraint); break;