Getting nested animations working.

This commit is contained in:
Luigi Rosso
2021-09-26 15:41:36 -07:00
committed by Luigi Rosso
parent 9bc89d1031
commit 3a84f6ae89
92 changed files with 1001 additions and 247 deletions

View File

@ -57,6 +57,7 @@ abstract class Core<T extends CoreContext> {
} }
} }
// ignore: avoid_classes_with_only_static_members
class InternalCoreHelper { class InternalCoreHelper {
static void markValid(Core object) { static void markValid(Core object) {
object._hasValidated = true; object._hasValidated = true;

View File

@ -0,0 +1,72 @@
/// Core automatically generated
/// lib/src/generated/animation/keyframe_play_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/keyframe_base.dart';
import 'package:rive/src/rive_core/animation/keyframe.dart';
abstract class KeyFramePlayBase extends KeyFrame {
static const int typeKey = 99;
@override
int get coreType => KeyFramePlayBase.typeKey;
@override
Set<int> get coreTypes => {KeyFramePlayBase.typeKey, KeyFrameBase.typeKey};
/// --------------------------------------------------------------------------
/// NestedPlaybackValue field with key 203.
static const int nestedPlaybackValueInitialValue = 0;
int _nestedPlaybackValue = nestedPlaybackValueInitialValue;
static const int nestedPlaybackValuePropertyKey = 203;
/// Backing value for NestedPlayback enum.
int get nestedPlaybackValue => _nestedPlaybackValue;
/// Change the [_nestedPlaybackValue] field value.
/// [nestedPlaybackValueChanged] will be invoked only if the field's value has
/// changed.
set nestedPlaybackValue(int value) {
if (_nestedPlaybackValue == value) {
return;
}
int from = _nestedPlaybackValue;
_nestedPlaybackValue = value;
if (hasValidated) {
nestedPlaybackValueChanged(from, value);
}
}
void nestedPlaybackValueChanged(int from, int to);
/// --------------------------------------------------------------------------
/// ReferenceTime field with key 204.
static const int referenceTimeInitialValue = 0;
int _referenceTime = referenceTimeInitialValue;
static const int referenceTimePropertyKey = 204;
/// Represents time value to play/stop at, note that depending on
/// playbackValue this could also be a percentage.
int get referenceTime => _referenceTime;
/// Change the [_referenceTime] field value.
/// [referenceTimeChanged] will be invoked only if the field's value has
/// changed.
set referenceTime(int value) {
if (_referenceTime == value) {
return;
}
int from = _referenceTime;
_referenceTime = value;
if (hasValidated) {
referenceTimeChanged(from, value);
}
}
void referenceTimeChanged(int from, int to);
@override
void copy(covariant KeyFramePlayBase source) {
super.copy(source);
_nestedPlaybackValue = source._nestedPlaybackValue;
_referenceTime = source._referenceTime;
}
}

View File

@ -0,0 +1,51 @@
/// Core automatically generated
/// lib/src/generated/animation/nested_linear_animation_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/nested_animation_base.dart';
import 'package:rive/src/rive_core/animation/linear_animation.dart';
import 'package:rive/src/rive_core/nested_animation.dart';
abstract class NestedLinearAnimationBase
extends NestedAnimation<LinearAnimation> {
static const int typeKey = 97;
@override
int get coreType => NestedLinearAnimationBase.typeKey;
@override
Set<int> get coreTypes => {
NestedLinearAnimationBase.typeKey,
NestedAnimationBase.typeKey,
ComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// Mix field with key 200.
static const double mixInitialValue = 1;
double _mix = mixInitialValue;
static const int mixPropertyKey = 200;
/// Value to mix the animation in.
double get mix => _mix;
/// Change the [_mix] field value.
/// [mixChanged] will be invoked only if the field's value has changed.
set mix(double value) {
if (_mix == value) {
return;
}
double from = _mix;
_mix = value;
if (hasValidated) {
mixChanged(from, value);
}
}
void mixChanged(double from, double to);
@override
void copy(covariant NestedLinearAnimationBase source) {
super.copy(source);
_mix = source._mix;
}
}

View File

@ -0,0 +1,51 @@
/// Core automatically generated
/// lib/src/generated/animation/nested_remap_animation_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/nested_linear_animation_base.dart';
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/nested_animation_base.dart';
import 'package:rive/src/rive_core/animation/nested_linear_animation.dart';
abstract class NestedRemapAnimationBase extends NestedLinearAnimation {
static const int typeKey = 98;
@override
int get coreType => NestedRemapAnimationBase.typeKey;
@override
Set<int> get coreTypes => {
NestedRemapAnimationBase.typeKey,
NestedLinearAnimationBase.typeKey,
NestedAnimationBase.typeKey,
ComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// Time field with key 202.
static const double timeInitialValue = 0.0;
double _time = timeInitialValue;
static const int timePropertyKey = 202;
/// Time value in seconds for the nested linear animation.
double get time => _time;
/// Change the [_time] field value.
/// [timeChanged] will be invoked only if the field's value has changed.
set time(double value) {
if (_time == value) {
return;
}
double from = _time;
_time = value;
if (hasValidated) {
timeChanged(from, value);
}
}
void timeChanged(double from, double to);
@override
void copy(covariant NestedRemapAnimationBase source) {
super.copy(source);
_time = source._time;
}
}

View File

@ -0,0 +1,76 @@
/// Core automatically generated
/// lib/src/generated/animation/nested_simple_animation_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/nested_linear_animation_base.dart';
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/nested_animation_base.dart';
import 'package:rive/src/rive_core/animation/nested_linear_animation.dart';
abstract class NestedSimpleAnimationBase extends NestedLinearAnimation {
static const int typeKey = 96;
@override
int get coreType => NestedSimpleAnimationBase.typeKey;
@override
Set<int> get coreTypes => {
NestedSimpleAnimationBase.typeKey,
NestedLinearAnimationBase.typeKey,
NestedAnimationBase.typeKey,
ComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// Speed field with key 199.
static const double speedInitialValue = 1;
double _speed = speedInitialValue;
static const int speedPropertyKey = 199;
/// Speed to play the nested animation at.
double get speed => _speed;
/// Change the [_speed] field value.
/// [speedChanged] will be invoked only if the field's value has changed.
set speed(double value) {
if (_speed == value) {
return;
}
double from = _speed;
_speed = value;
if (hasValidated) {
speedChanged(from, value);
}
}
void speedChanged(double from, double to);
/// --------------------------------------------------------------------------
/// IsPlaying field with key 201.
static const bool isPlayingInitialValue = false;
bool _isPlaying = isPlayingInitialValue;
static const int isPlayingPropertyKey = 201;
/// Enumerated backing value for playback state.
bool get isPlaying => _isPlaying;
/// Change the [_isPlaying] field value.
/// [isPlayingChanged] will be invoked only if the field's value has changed.
set isPlaying(bool value) {
if (_isPlaying == value) {
return;
}
bool from = _isPlaying;
_isPlaying = value;
if (hasValidated) {
isPlayingChanged(from, value);
}
}
void isPlayingChanged(bool from, bool to);
@override
void copy(covariant NestedSimpleAnimationBase source) {
super.copy(source);
_speed = source._speed;
_isPlaying = source._isPlaying;
}
}

View File

@ -0,0 +1,20 @@
/// Core automatically generated
/// lib/src/generated/animation/nested_state_machine_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/nested_animation_base.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart';
import 'package:rive/src/rive_core/nested_animation.dart';
abstract class NestedStateMachineBase extends NestedAnimation<StateMachine> {
static const int typeKey = 95;
@override
int get coreType => NestedStateMachineBase.typeKey;
@override
Set<int> get coreTypes => {
NestedStateMachineBase.typeKey,
NestedAnimationBase.typeKey,
ComponentBase.typeKey
};
}

View File

@ -0,0 +1,45 @@
/// Core automatically generated lib/src/generated/nested_animation_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/rive_core/component.dart';
abstract class NestedAnimationBase extends Component {
static const int typeKey = 93;
@override
int get coreType => NestedAnimationBase.typeKey;
@override
Set<int> get coreTypes =>
{NestedAnimationBase.typeKey, ComponentBase.typeKey};
/// --------------------------------------------------------------------------
/// AnimationId field with key 198.
static const int animationIdInitialValue = -1;
int _animationId = animationIdInitialValue;
static const int animationIdPropertyKey = 198;
/// Identifier used to track the animation in the nested artboard.
int get animationId => _animationId;
/// Change the [_animationId] field value.
/// [animationIdChanged] will be invoked only if the field's value has
/// changed.
set animationId(int value) {
if (_animationId == value) {
return;
}
int from = _animationId;
_animationId = value;
if (hasValidated) {
animationIdChanged(from, value);
}
}
void animationIdChanged(int from, int to);
@override
void copy(covariant NestedAnimationBase source) {
super.copy(source);
_animationId = source._animationId;
}
}

View File

@ -25,6 +25,10 @@ import 'package:rive/src/generated/animation/keyframe_color_base.dart';
import 'package:rive/src/generated/animation/keyframe_double_base.dart'; import 'package:rive/src/generated/animation/keyframe_double_base.dart';
import 'package:rive/src/generated/animation/keyframe_id_base.dart'; import 'package:rive/src/generated/animation/keyframe_id_base.dart';
import 'package:rive/src/generated/animation/linear_animation_base.dart'; import 'package:rive/src/generated/animation/linear_animation_base.dart';
import 'package:rive/src/generated/animation/nested_linear_animation_base.dart';
import 'package:rive/src/generated/animation/nested_remap_animation_base.dart';
import 'package:rive/src/generated/animation/nested_simple_animation_base.dart';
import 'package:rive/src/generated/animation/nested_state_machine_base.dart';
import 'package:rive/src/generated/animation/state_machine_base.dart'; import 'package:rive/src/generated/animation/state_machine_base.dart';
import 'package:rive/src/generated/animation/state_machine_bool_base.dart'; import 'package:rive/src/generated/animation/state_machine_bool_base.dart';
import 'package:rive/src/generated/animation/state_machine_component_base.dart'; import 'package:rive/src/generated/animation/state_machine_component_base.dart';
@ -60,6 +64,7 @@ import 'package:rive/src/generated/constraints/translation_constraint_base.dart'
import 'package:rive/src/generated/draw_rules_base.dart'; import 'package:rive/src/generated/draw_rules_base.dart';
import 'package:rive/src/generated/draw_target_base.dart'; import 'package:rive/src/generated/draw_target_base.dart';
import 'package:rive/src/generated/drawable_base.dart'; import 'package:rive/src/generated/drawable_base.dart';
import 'package:rive/src/generated/nested_animation_base.dart';
import 'package:rive/src/generated/nested_artboard_base.dart'; import 'package:rive/src/generated/nested_artboard_base.dart';
import 'package:rive/src/generated/node_base.dart'; import 'package:rive/src/generated/node_base.dart';
import 'package:rive/src/generated/shapes/clipping_shape_base.dart'; import 'package:rive/src/generated/shapes/clipping_shape_base.dart';
@ -105,6 +110,9 @@ import 'package:rive/src/rive_core/animation/keyframe_color.dart';
import 'package:rive/src/rive_core/animation/keyframe_double.dart'; import 'package:rive/src/rive_core/animation/keyframe_double.dart';
import 'package:rive/src/rive_core/animation/keyframe_id.dart'; import 'package:rive/src/rive_core/animation/keyframe_id.dart';
import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart';
import 'package:rive/src/rive_core/animation/nested_remap_animation.dart';
import 'package:rive/src/rive_core/animation/nested_simple_animation.dart';
import 'package:rive/src/rive_core/animation/nested_state_machine.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart';
import 'package:rive/src/rive_core/animation/state_machine_bool.dart'; import 'package:rive/src/rive_core/animation/state_machine_bool.dart';
import 'package:rive/src/rive_core/animation/state_machine_layer.dart'; import 'package:rive/src/rive_core/animation/state_machine_layer.dart';
@ -174,6 +182,12 @@ class RiveCoreContext {
return Node(); return Node();
case NestedArtboardBase.typeKey: case NestedArtboardBase.typeKey:
return NestedArtboard(); return NestedArtboard();
case AnimationBase.typeKey:
return Animation();
case LinearAnimationBase.typeKey:
return LinearAnimation();
case NestedSimpleAnimationBase.typeKey:
return NestedSimpleAnimation();
case AnimationStateBase.typeKey: case AnimationStateBase.typeKey:
return AnimationState(); return AnimationState();
case KeyedObjectBase.typeKey: case KeyedObjectBase.typeKey:
@ -196,8 +210,6 @@ class RiveCoreContext {
return AnyState(); return AnyState();
case StateMachineLayerBase.typeKey: case StateMachineLayerBase.typeKey:
return StateMachineLayer(); return StateMachineLayer();
case AnimationBase.typeKey:
return Animation();
case CubicInterpolatorBase.typeKey: case CubicInterpolatorBase.typeKey:
return CubicInterpolator(); return CubicInterpolator();
case StateTransitionBase.typeKey: case StateTransitionBase.typeKey:
@ -210,18 +222,20 @@ class RiveCoreContext {
return StateMachine(); return StateMachine();
case EntryStateBase.typeKey: case EntryStateBase.typeKey:
return EntryState(); return EntryState();
case LinearAnimationBase.typeKey:
return LinearAnimation();
case StateMachineTriggerBase.typeKey: case StateMachineTriggerBase.typeKey:
return StateMachineTrigger(); return StateMachineTrigger();
case BlendStateDirectBase.typeKey: case BlendStateDirectBase.typeKey:
return BlendStateDirect(); return BlendStateDirect();
case NestedStateMachineBase.typeKey:
return NestedStateMachine();
case ExitStateBase.typeKey: case ExitStateBase.typeKey:
return ExitState(); return ExitState();
case BlendAnimation1DBase.typeKey: case BlendAnimation1DBase.typeKey:
return BlendAnimation1D(); return BlendAnimation1D();
case BlendState1DBase.typeKey: case BlendState1DBase.typeKey:
return BlendState1D(); return BlendState1D();
case NestedRemapAnimationBase.typeKey:
return NestedRemapAnimation();
case TransitionBoolConditionBase.typeKey: case TransitionBoolConditionBase.typeKey:
return TransitionBoolCondition(); return TransitionBoolCondition();
case BlendStateTransitionBase.typeKey: case BlendStateTransitionBase.typeKey:
@ -466,6 +480,66 @@ class RiveCoreContext {
object.artboardId = value; object.artboardId = value;
} }
break; break;
case NestedAnimationBase.animationIdPropertyKey:
if (object is NestedAnimationBase && value is int) {
object.animationId = value;
}
break;
case AnimationBase.namePropertyKey:
if (object is AnimationBase && value is String) {
object.name = value;
}
break;
case LinearAnimationBase.fpsPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.fps = value;
}
break;
case LinearAnimationBase.durationPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.duration = value;
}
break;
case LinearAnimationBase.speedPropertyKey:
if (object is LinearAnimationBase && value is double) {
object.speed = value;
}
break;
case LinearAnimationBase.loopValuePropertyKey:
if (object is LinearAnimationBase && value is int) {
object.loopValue = value;
}
break;
case LinearAnimationBase.workStartPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.workStart = value;
}
break;
case LinearAnimationBase.workEndPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.workEnd = value;
}
break;
case LinearAnimationBase.enableWorkAreaPropertyKey:
if (object is LinearAnimationBase && value is bool) {
object.enableWorkArea = value;
}
break;
case NestedLinearAnimationBase.mixPropertyKey:
if (object is NestedLinearAnimationBase && value is double) {
object.mix = value;
}
break;
case NestedSimpleAnimationBase.speedPropertyKey:
if (object is NestedSimpleAnimationBase && value is double) {
object.speed = value;
}
break;
case NestedSimpleAnimationBase.isPlayingPropertyKey:
if (object is NestedSimpleAnimationBase && value is bool) {
object.isPlaying = value;
}
break;
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
if (object is AnimationStateBase && value is int) { if (object is AnimationStateBase && value is int) {
object.animationId = value; object.animationId = value;
@ -541,11 +615,6 @@ class RiveCoreContext {
object.value = value; object.value = value;
} }
break; break;
case AnimationBase.namePropertyKey:
if (object is AnimationBase && value is String) {
object.name = value;
}
break;
case CubicInterpolatorBase.x1PropertyKey: case CubicInterpolatorBase.x1PropertyKey:
if (object is CubicInterpolatorBase && value is double) { if (object is CubicInterpolatorBase && value is double) {
object.x1 = value; object.x1 = value;
@ -596,41 +665,6 @@ class RiveCoreContext {
object.value = value; object.value = value;
} }
break; break;
case LinearAnimationBase.fpsPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.fps = value;
}
break;
case LinearAnimationBase.durationPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.duration = value;
}
break;
case LinearAnimationBase.speedPropertyKey:
if (object is LinearAnimationBase && value is double) {
object.speed = value;
}
break;
case LinearAnimationBase.loopValuePropertyKey:
if (object is LinearAnimationBase && value is int) {
object.loopValue = value;
}
break;
case LinearAnimationBase.workStartPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.workStart = value;
}
break;
case LinearAnimationBase.workEndPropertyKey:
if (object is LinearAnimationBase && value is int) {
object.workEnd = value;
}
break;
case LinearAnimationBase.enableWorkAreaPropertyKey:
if (object is LinearAnimationBase && value is bool) {
object.enableWorkArea = value;
}
break;
case BlendAnimation1DBase.valuePropertyKey: case BlendAnimation1DBase.valuePropertyKey:
if (object is BlendAnimation1DBase && value is double) { if (object is BlendAnimation1DBase && value is double) {
object.value = value; object.value = value;
@ -641,6 +675,11 @@ class RiveCoreContext {
object.inputId = value; object.inputId = value;
} }
break; break;
case NestedRemapAnimationBase.timePropertyKey:
if (object is NestedRemapAnimationBase && value is double) {
object.time = value;
}
break;
case BlendStateTransitionBase.exitBlendAnimationIdPropertyKey: case BlendStateTransitionBase.exitBlendAnimationIdPropertyKey:
if (object is BlendStateTransitionBase && value is int) { if (object is BlendStateTransitionBase && value is int) {
object.exitBlendAnimationId = value; object.exitBlendAnimationId = value;
@ -1047,8 +1086,8 @@ class RiveCoreContext {
static CoreFieldType? coreType(int propertyKey) { static CoreFieldType? coreType(int propertyKey) {
switch (propertyKey) { switch (propertyKey) {
case ComponentBase.namePropertyKey: case ComponentBase.namePropertyKey:
case StateMachineComponentBase.namePropertyKey:
case AnimationBase.namePropertyKey: case AnimationBase.namePropertyKey:
case StateMachineComponentBase.namePropertyKey:
return stringType; return stringType;
case ComponentBase.parentIdPropertyKey: case ComponentBase.parentIdPropertyKey:
case DrawTargetBase.drawableIdPropertyKey: case DrawTargetBase.drawableIdPropertyKey:
@ -1062,6 +1101,12 @@ class RiveCoreContext {
case DrawableBase.blendModeValuePropertyKey: case DrawableBase.blendModeValuePropertyKey:
case DrawableBase.drawableFlagsPropertyKey: case DrawableBase.drawableFlagsPropertyKey:
case NestedArtboardBase.artboardIdPropertyKey: case NestedArtboardBase.artboardIdPropertyKey:
case NestedAnimationBase.animationIdPropertyKey:
case LinearAnimationBase.fpsPropertyKey:
case LinearAnimationBase.durationPropertyKey:
case LinearAnimationBase.loopValuePropertyKey:
case LinearAnimationBase.workStartPropertyKey:
case LinearAnimationBase.workEndPropertyKey:
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
case KeyedObjectBase.objectIdPropertyKey: case KeyedObjectBase.objectIdPropertyKey:
case BlendAnimationBase.animationIdPropertyKey: case BlendAnimationBase.animationIdPropertyKey:
@ -1077,11 +1122,6 @@ class RiveCoreContext {
case StateTransitionBase.flagsPropertyKey: case StateTransitionBase.flagsPropertyKey:
case StateTransitionBase.durationPropertyKey: case StateTransitionBase.durationPropertyKey:
case StateTransitionBase.exitTimePropertyKey: case StateTransitionBase.exitTimePropertyKey:
case LinearAnimationBase.fpsPropertyKey:
case LinearAnimationBase.durationPropertyKey:
case LinearAnimationBase.loopValuePropertyKey:
case LinearAnimationBase.workStartPropertyKey:
case LinearAnimationBase.workEndPropertyKey:
case BlendState1DBase.inputIdPropertyKey: case BlendState1DBase.inputIdPropertyKey:
case BlendStateTransitionBase.exitBlendAnimationIdPropertyKey: case BlendStateTransitionBase.exitBlendAnimationIdPropertyKey:
case StrokeBase.capPropertyKey: case StrokeBase.capPropertyKey:
@ -1115,6 +1155,9 @@ class RiveCoreContext {
case TransformComponentBase.scaleYPropertyKey: case TransformComponentBase.scaleYPropertyKey:
case NodeBase.xPropertyKey: case NodeBase.xPropertyKey:
case NodeBase.yPropertyKey: case NodeBase.yPropertyKey:
case LinearAnimationBase.speedPropertyKey:
case NestedLinearAnimationBase.mixPropertyKey:
case NestedSimpleAnimationBase.speedPropertyKey:
case StateMachineNumberBase.valuePropertyKey: case StateMachineNumberBase.valuePropertyKey:
case TransitionNumberConditionBase.valuePropertyKey: case TransitionNumberConditionBase.valuePropertyKey:
case CubicInterpolatorBase.x1PropertyKey: case CubicInterpolatorBase.x1PropertyKey:
@ -1122,8 +1165,8 @@ class RiveCoreContext {
case CubicInterpolatorBase.x2PropertyKey: case CubicInterpolatorBase.x2PropertyKey:
case CubicInterpolatorBase.y2PropertyKey: case CubicInterpolatorBase.y2PropertyKey:
case KeyFrameDoubleBase.valuePropertyKey: case KeyFrameDoubleBase.valuePropertyKey:
case LinearAnimationBase.speedPropertyKey:
case BlendAnimation1DBase.valuePropertyKey: case BlendAnimation1DBase.valuePropertyKey:
case NestedRemapAnimationBase.timePropertyKey:
case LinearGradientBase.startXPropertyKey: case LinearGradientBase.startXPropertyKey:
case LinearGradientBase.startYPropertyKey: case LinearGradientBase.startYPropertyKey:
case LinearGradientBase.endXPropertyKey: case LinearGradientBase.endXPropertyKey:
@ -1186,8 +1229,9 @@ class RiveCoreContext {
case TransformComponentConstraintYBase.minYPropertyKey: case TransformComponentConstraintYBase.minYPropertyKey:
case TransformComponentConstraintYBase.maxYPropertyKey: case TransformComponentConstraintYBase.maxYPropertyKey:
case IKConstraintBase.invertDirectionPropertyKey: case IKConstraintBase.invertDirectionPropertyKey:
case KeyFrameBoolBase.valuePropertyKey:
case LinearAnimationBase.enableWorkAreaPropertyKey: case LinearAnimationBase.enableWorkAreaPropertyKey:
case NestedSimpleAnimationBase.isPlayingPropertyKey:
case KeyFrameBoolBase.valuePropertyKey:
case StateMachineBoolBase.valuePropertyKey: case StateMachineBoolBase.valuePropertyKey:
case ShapePaintBase.isVisiblePropertyKey: case ShapePaintBase.isVisiblePropertyKey:
case StrokeBase.transformAffectsStrokePropertyKey: case StrokeBase.transformAffectsStrokePropertyKey:
@ -1209,10 +1253,10 @@ class RiveCoreContext {
switch (propertyKey) { switch (propertyKey) {
case ComponentBase.namePropertyKey: case ComponentBase.namePropertyKey:
return (object as ComponentBase).name; return (object as ComponentBase).name;
case StateMachineComponentBase.namePropertyKey:
return (object as StateMachineComponentBase).name;
case AnimationBase.namePropertyKey: case AnimationBase.namePropertyKey:
return (object as AnimationBase).name; return (object as AnimationBase).name;
case StateMachineComponentBase.namePropertyKey:
return (object as StateMachineComponentBase).name;
} }
return ''; return '';
} }
@ -1243,6 +1287,18 @@ class RiveCoreContext {
return (object as DrawableBase).drawableFlags; return (object as DrawableBase).drawableFlags;
case NestedArtboardBase.artboardIdPropertyKey: case NestedArtboardBase.artboardIdPropertyKey:
return (object as NestedArtboardBase).artboardId; return (object as NestedArtboardBase).artboardId;
case NestedAnimationBase.animationIdPropertyKey:
return (object as NestedAnimationBase).animationId;
case LinearAnimationBase.fpsPropertyKey:
return (object as LinearAnimationBase).fps;
case LinearAnimationBase.durationPropertyKey:
return (object as LinearAnimationBase).duration;
case LinearAnimationBase.loopValuePropertyKey:
return (object as LinearAnimationBase).loopValue;
case LinearAnimationBase.workStartPropertyKey:
return (object as LinearAnimationBase).workStart;
case LinearAnimationBase.workEndPropertyKey:
return (object as LinearAnimationBase).workEnd;
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
return (object as AnimationStateBase).animationId; return (object as AnimationStateBase).animationId;
case KeyedObjectBase.objectIdPropertyKey: case KeyedObjectBase.objectIdPropertyKey:
@ -1273,16 +1329,6 @@ class RiveCoreContext {
return (object as StateTransitionBase).duration; return (object as StateTransitionBase).duration;
case StateTransitionBase.exitTimePropertyKey: case StateTransitionBase.exitTimePropertyKey:
return (object as StateTransitionBase).exitTime; return (object as StateTransitionBase).exitTime;
case LinearAnimationBase.fpsPropertyKey:
return (object as LinearAnimationBase).fps;
case LinearAnimationBase.durationPropertyKey:
return (object as LinearAnimationBase).duration;
case LinearAnimationBase.loopValuePropertyKey:
return (object as LinearAnimationBase).loopValue;
case LinearAnimationBase.workStartPropertyKey:
return (object as LinearAnimationBase).workStart;
case LinearAnimationBase.workEndPropertyKey:
return (object as LinearAnimationBase).workEnd;
case BlendState1DBase.inputIdPropertyKey: case BlendState1DBase.inputIdPropertyKey:
return (object as BlendState1DBase).inputId; return (object as BlendState1DBase).inputId;
case BlendStateTransitionBase.exitBlendAnimationIdPropertyKey: case BlendStateTransitionBase.exitBlendAnimationIdPropertyKey:
@ -1353,6 +1399,12 @@ class RiveCoreContext {
return (object as NodeBase).x; return (object as NodeBase).x;
case NodeBase.yPropertyKey: case NodeBase.yPropertyKey:
return (object as NodeBase).y; return (object as NodeBase).y;
case LinearAnimationBase.speedPropertyKey:
return (object as LinearAnimationBase).speed;
case NestedLinearAnimationBase.mixPropertyKey:
return (object as NestedLinearAnimationBase).mix;
case NestedSimpleAnimationBase.speedPropertyKey:
return (object as NestedSimpleAnimationBase).speed;
case StateMachineNumberBase.valuePropertyKey: case StateMachineNumberBase.valuePropertyKey:
return (object as StateMachineNumberBase).value; return (object as StateMachineNumberBase).value;
case TransitionNumberConditionBase.valuePropertyKey: case TransitionNumberConditionBase.valuePropertyKey:
@ -1367,10 +1419,10 @@ class RiveCoreContext {
return (object as CubicInterpolatorBase).y2; return (object as CubicInterpolatorBase).y2;
case KeyFrameDoubleBase.valuePropertyKey: case KeyFrameDoubleBase.valuePropertyKey:
return (object as KeyFrameDoubleBase).value; return (object as KeyFrameDoubleBase).value;
case LinearAnimationBase.speedPropertyKey:
return (object as LinearAnimationBase).speed;
case BlendAnimation1DBase.valuePropertyKey: case BlendAnimation1DBase.valuePropertyKey:
return (object as BlendAnimation1DBase).value; return (object as BlendAnimation1DBase).value;
case NestedRemapAnimationBase.timePropertyKey:
return (object as NestedRemapAnimationBase).time;
case LinearGradientBase.startXPropertyKey: case LinearGradientBase.startXPropertyKey:
return (object as LinearGradientBase).startX; return (object as LinearGradientBase).startX;
case LinearGradientBase.startYPropertyKey: case LinearGradientBase.startYPropertyKey:
@ -1499,10 +1551,12 @@ class RiveCoreContext {
return (object as TransformComponentConstraintYBase).maxY; return (object as TransformComponentConstraintYBase).maxY;
case IKConstraintBase.invertDirectionPropertyKey: case IKConstraintBase.invertDirectionPropertyKey:
return (object as IKConstraintBase).invertDirection; return (object as IKConstraintBase).invertDirection;
case KeyFrameBoolBase.valuePropertyKey:
return (object as KeyFrameBoolBase).value;
case LinearAnimationBase.enableWorkAreaPropertyKey: case LinearAnimationBase.enableWorkAreaPropertyKey:
return (object as LinearAnimationBase).enableWorkArea; return (object as LinearAnimationBase).enableWorkArea;
case NestedSimpleAnimationBase.isPlayingPropertyKey:
return (object as NestedSimpleAnimationBase).isPlaying;
case KeyFrameBoolBase.valuePropertyKey:
return (object as KeyFrameBoolBase).value;
case StateMachineBoolBase.valuePropertyKey: case StateMachineBoolBase.valuePropertyKey:
return (object as StateMachineBoolBase).value; return (object as StateMachineBoolBase).value;
case ShapePaintBase.isVisiblePropertyKey: case ShapePaintBase.isVisiblePropertyKey:
@ -1540,13 +1594,13 @@ class RiveCoreContext {
object.name = value; object.name = value;
} }
break; break;
case StateMachineComponentBase.namePropertyKey: case AnimationBase.namePropertyKey:
if (object is StateMachineComponentBase) { if (object is AnimationBase) {
object.name = value; object.name = value;
} }
break; break;
case AnimationBase.namePropertyKey: case StateMachineComponentBase.namePropertyKey:
if (object is AnimationBase) { if (object is StateMachineComponentBase) {
object.name = value; object.name = value;
} }
break; break;
@ -1615,6 +1669,36 @@ class RiveCoreContext {
object.artboardId = value; object.artboardId = value;
} }
break; break;
case NestedAnimationBase.animationIdPropertyKey:
if (object is NestedAnimationBase) {
object.animationId = value;
}
break;
case LinearAnimationBase.fpsPropertyKey:
if (object is LinearAnimationBase) {
object.fps = value;
}
break;
case LinearAnimationBase.durationPropertyKey:
if (object is LinearAnimationBase) {
object.duration = value;
}
break;
case LinearAnimationBase.loopValuePropertyKey:
if (object is LinearAnimationBase) {
object.loopValue = value;
}
break;
case LinearAnimationBase.workStartPropertyKey:
if (object is LinearAnimationBase) {
object.workStart = value;
}
break;
case LinearAnimationBase.workEndPropertyKey:
if (object is LinearAnimationBase) {
object.workEnd = value;
}
break;
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
if (object is AnimationStateBase) { if (object is AnimationStateBase) {
object.animationId = value; object.animationId = value;
@ -1690,31 +1774,6 @@ class RiveCoreContext {
object.exitTime = value; object.exitTime = value;
} }
break; break;
case LinearAnimationBase.fpsPropertyKey:
if (object is LinearAnimationBase) {
object.fps = value;
}
break;
case LinearAnimationBase.durationPropertyKey:
if (object is LinearAnimationBase) {
object.duration = value;
}
break;
case LinearAnimationBase.loopValuePropertyKey:
if (object is LinearAnimationBase) {
object.loopValue = value;
}
break;
case LinearAnimationBase.workStartPropertyKey:
if (object is LinearAnimationBase) {
object.workStart = value;
}
break;
case LinearAnimationBase.workEndPropertyKey:
if (object is LinearAnimationBase) {
object.workEnd = value;
}
break;
case BlendState1DBase.inputIdPropertyKey: case BlendState1DBase.inputIdPropertyKey:
if (object is BlendState1DBase) { if (object is BlendState1DBase) {
object.inputId = value; object.inputId = value;
@ -1880,6 +1939,21 @@ class RiveCoreContext {
object.y = value; object.y = value;
} }
break; break;
case LinearAnimationBase.speedPropertyKey:
if (object is LinearAnimationBase) {
object.speed = value;
}
break;
case NestedLinearAnimationBase.mixPropertyKey:
if (object is NestedLinearAnimationBase) {
object.mix = value;
}
break;
case NestedSimpleAnimationBase.speedPropertyKey:
if (object is NestedSimpleAnimationBase) {
object.speed = value;
}
break;
case StateMachineNumberBase.valuePropertyKey: case StateMachineNumberBase.valuePropertyKey:
if (object is StateMachineNumberBase) { if (object is StateMachineNumberBase) {
object.value = value; object.value = value;
@ -1915,16 +1989,16 @@ class RiveCoreContext {
object.value = value; object.value = value;
} }
break; break;
case LinearAnimationBase.speedPropertyKey:
if (object is LinearAnimationBase) {
object.speed = value;
}
break;
case BlendAnimation1DBase.valuePropertyKey: case BlendAnimation1DBase.valuePropertyKey:
if (object is BlendAnimation1DBase) { if (object is BlendAnimation1DBase) {
object.value = value; object.value = value;
} }
break; break;
case NestedRemapAnimationBase.timePropertyKey:
if (object is NestedRemapAnimationBase) {
object.time = value;
}
break;
case LinearGradientBase.startXPropertyKey: case LinearGradientBase.startXPropertyKey:
if (object is LinearGradientBase) { if (object is LinearGradientBase) {
object.startX = value; object.startX = value;
@ -2235,16 +2309,21 @@ class RiveCoreContext {
object.invertDirection = value; object.invertDirection = value;
} }
break; break;
case KeyFrameBoolBase.valuePropertyKey:
if (object is KeyFrameBoolBase) {
object.value = value;
}
break;
case LinearAnimationBase.enableWorkAreaPropertyKey: case LinearAnimationBase.enableWorkAreaPropertyKey:
if (object is LinearAnimationBase) { if (object is LinearAnimationBase) {
object.enableWorkArea = value; object.enableWorkArea = value;
} }
break; break;
case NestedSimpleAnimationBase.isPlayingPropertyKey:
if (object is NestedSimpleAnimationBase) {
object.isPlaying = value;
}
break;
case KeyFrameBoolBase.valuePropertyKey:
if (object is KeyFrameBoolBase) {
object.value = value;
}
break;
case StateMachineBoolBase.valuePropertyKey: case StateMachineBoolBase.valuePropertyKey:
if (object is StateMachineBoolBase) { if (object is StateMachineBoolBase) {
object.value = value; object.value = value;

View File

@ -68,11 +68,6 @@ class Rive extends LeafRenderObjectWidget {
..artboardSize = Size(artboard.width, artboard.height) ..artboardSize = Size(artboard.width, artboard.height)
..useArtboardSize = useArtboardSize; ..useArtboardSize = useArtboardSize;
} }
@override
void didUnmountRenderObject(covariant RiveRenderObject renderObject) {
renderObject.dispose();
}
} }
class RiveRenderObject extends RiveRenderBox { class RiveRenderObject extends RiveRenderBox {
@ -93,7 +88,9 @@ class RiveRenderObject extends RiveRenderBox {
markNeedsLayout(); markNeedsLayout();
} }
@override
void dispose() { void dispose() {
super.dispose();
_artboard.redraw.removeListener(scheduleRepaint); _artboard.redraw.removeListener(scheduleRepaint);
} }
@ -105,7 +102,8 @@ class RiveRenderObject extends RiveRenderBox {
} }
@override @override
bool advance(double elapsedSeconds) => _artboard.advance(elapsedSeconds); bool advance(double elapsedSeconds) =>
_artboard.advance(elapsedSeconds, nested: true);
@override @override
void beforeDraw(Canvas canvas, Offset offset) { void beforeDraw(Canvas canvas, Offset offset) {

View File

@ -1,7 +1,7 @@
import 'package:rive/src/core/core.dart'; 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/rive_core/artboard.dart';
import 'package:rive/src/generated/animation/animation_base.dart';
export 'package:rive/src/generated/animation/animation_base.dart'; export 'package:rive/src/generated/animation/animation_base.dart';
class Animation extends AnimationBase<RuntimeArtboard> { class Animation extends AnimationBase<RuntimeArtboard> {

View File

@ -1,9 +1,10 @@
import 'package:rive/src/core/core.dart'; 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/animation_state_instance.dart';
import 'package:rive/src/rive_core/animation/linear_animation.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/animation/state_instance.dart';
import 'package:rive/src/rive_core/artboard.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'; export 'package:rive/src/generated/animation/animation_state_base.dart';
class AnimationState extends AnimationStateBase { class AnimationState extends AnimationStateBase {

View File

@ -1,5 +1,6 @@
import 'package:rive/src/rive_core/animation/state_instance.dart';
import 'package:rive/src/generated/animation/any_state_base.dart'; import 'package:rive/src/generated/animation/any_state_base.dart';
import 'package:rive/src/rive_core/animation/state_instance.dart';
export 'package:rive/src/generated/animation/any_state_base.dart'; export 'package:rive/src/generated/animation/any_state_base.dart';
class AnyState extends AnyStateBase { class AnyState extends AnyStateBase {

View File

@ -1,9 +1,10 @@
import 'package:rive/src/core/core.dart'; 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/layer_state.dart';
import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart';
import 'package:rive/src/rive_core/artboard.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'; export 'package:rive/src/generated/animation/blend_animation_base.dart';
abstract class BlendAnimation extends BlendAnimationBase { abstract class BlendAnimation extends BlendAnimationBase {

View File

@ -1,7 +1,8 @@
import 'package:rive/src/core/core.dart'; 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.dart';
import 'package:rive/src/rive_core/animation/state_machine_number.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'; export 'package:rive/src/generated/animation/blend_animation_direct_base.dart';
class BlendAnimationDirect extends BlendAnimationDirectBase { class BlendAnimationDirect extends BlendAnimationDirectBase {

View File

@ -1,6 +1,7 @@
import 'package:rive/src/core/core.dart'; import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/blend_animation.dart';
import 'package:rive/src/generated/animation/blend_state_base.dart'; import 'package:rive/src/generated/animation/blend_state_base.dart';
import 'package:rive/src/rive_core/animation/blend_animation.dart';
export 'package:rive/src/generated/animation/blend_state_base.dart'; export 'package:rive/src/generated/animation/blend_state_base.dart';
// //

View File

@ -1,9 +1,10 @@
import 'package:rive/src/core/core.dart'; 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/blend_state_1d_instance.dart';
import 'package:rive/src/rive_core/animation/state_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.dart';
import 'package:rive/src/rive_core/animation/state_machine_number.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'; export 'package:rive/src/generated/animation/blend_state_1d_base.dart';
class BlendState1D extends BlendState1DBase { class BlendState1D extends BlendState1DBase {

View File

@ -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/blend_state_direct_instance.dart';
import 'package:rive/src/rive_core/animation/state_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'; export 'package:rive/src/generated/animation/blend_state_direct_base.dart';

View File

@ -1,7 +1,7 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/core/core.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/blend_animation.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/blend_state.dart';
import 'package:rive/src/rive_core/animation/linear_animation_instance.dart'; import 'package:rive/src/rive_core/animation/linear_animation_instance.dart';

View File

@ -1,10 +1,11 @@
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_animation.dart';
import 'package:rive/src/rive_core/animation/blend_state_instance.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/layer_state.dart';
import 'package:rive/src/rive_core/animation/linear_animation.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/linear_animation_instance.dart';
import 'package:rive/src/rive_core/animation/state_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'; export 'package:rive/src/generated/animation/blend_state_transition_base.dart';
class BlendStateTransition extends BlendStateTransitionBase { class BlendStateTransition extends BlendStateTransitionBase {

View File

@ -1,9 +1,9 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:rive/src/core/core.dart'; 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/animation/interpolator.dart';
import 'package:rive/src/rive_core/artboard.dart'; import 'package:rive/src/rive_core/artboard.dart';
import 'package:rive/src/generated/animation/cubic_interpolator_base.dart';
const int newtonIterations = 4; const int newtonIterations = 4;

View File

@ -1,5 +1,6 @@
import 'package:rive/src/rive_core/animation/state_instance.dart';
import 'package:rive/src/generated/animation/entry_state_base.dart'; import 'package:rive/src/generated/animation/entry_state_base.dart';
import 'package:rive/src/rive_core/animation/state_instance.dart';
export 'package:rive/src/generated/animation/entry_state_base.dart'; export 'package:rive/src/generated/animation/entry_state_base.dart';
class EntryState extends EntryStateBase { class EntryState extends EntryStateBase {

View File

@ -1,5 +1,6 @@
import 'package:rive/src/rive_core/animation/state_instance.dart';
import 'package:rive/src/generated/animation/exit_state_base.dart'; import 'package:rive/src/generated/animation/exit_state_base.dart';
import 'package:rive/src/rive_core/animation/state_instance.dart';
export 'package:rive/src/generated/animation/exit_state_base.dart'; export 'package:rive/src/generated/animation/exit_state_base.dart';
class ExitState extends ExitStateBase { class ExitState extends ExitStateBase {

View File

@ -1,11 +1,11 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/core/core.dart'; import 'package:rive/src/core/core.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 'package:rive/src/generated/animation/keyed_object_base.dart';
import 'package:rive/src/rive_core/animation/keyed_property.dart';
import 'linear_animation.dart'; import 'linear_animation.dart';
export 'package:rive/src/generated/animation/keyed_object_base.dart'; export 'package:rive/src/generated/animation/keyed_object_base.dart';
class KeyedObject extends KeyedObjectBase<RuntimeArtboard> { class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
@ -20,20 +20,6 @@ class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
@override @override
void onAdded() {} void onAdded() {}
@override
bool validate() {
if (!super.validate()) {
return false;
}
var component = context.resolve<Component>(objectId);
if (component == null) {
return false;
}
return true;
}
@override @override
void onRemoved() { void onRemoved() {
super.onRemoved(); super.onRemoved();
@ -61,6 +47,7 @@ class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
return false; return false;
} }
_keyedProperties[property.propertyKey] = property; _keyedProperties[property.propertyKey] = property;
return true; return true;
} }
@ -75,6 +62,7 @@ class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
} }
// assert(removed == null || removed == property, // assert(removed == null || removed == property,
// '$removed was not $property or null'); // '$removed was not $property or null');
return removed != null; return removed != null;
} }

View File

@ -1,8 +1,8 @@
import 'package:rive/src/core/core.dart'; 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/keyed_object.dart';
import 'package:rive/src/rive_core/animation/keyframe.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'; export 'package:rive/src/generated/animation/keyed_property_base.dart';
abstract class KeyFrameInterface { abstract class KeyFrameInterface {
@ -11,7 +11,7 @@ abstract class KeyFrameInterface {
class KeyFrameList<T extends KeyFrameInterface> { class KeyFrameList<T extends KeyFrameInterface> {
List<T> _keyframes = []; List<T> _keyframes = [];
Iterable<T> get keyframes => _keyframes; List<T> get keyframes => _keyframes;
set keyframes(Iterable<T> frames) => _keyframes = frames.toList(); set keyframes(Iterable<T> frames) => _keyframes = frames.toList();
/// Get the keyframe immediately following the provided one. /// Get the keyframe immediately following the provided one.

View File

@ -1,11 +1,10 @@
import 'package:rive/src/core/core.dart'; 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/interpolator.dart';
import 'package:rive/src/rive_core/animation/keyed_property.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/keyframe_interpolation.dart';
import 'package:rive/src/rive_core/animation/linear_animation.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'; export 'package:rive/src/generated/animation/keyframe_base.dart';
abstract class KeyFrame extends KeyFrameBase<RuntimeArtboard> abstract class KeyFrame extends KeyFrameBase<RuntimeArtboard>

View File

@ -1,8 +1,9 @@
import 'package:rive/src/core/core.dart'; 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_instance.dart';
import 'package:rive/src/rive_core/animation/state_machine_layer.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/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'; export 'package:rive/src/generated/animation/layer_state_base.dart';
abstract class LayerState extends LayerStateBase { abstract class LayerState extends LayerStateBase {

View File

@ -1,10 +1,11 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/core/core.dart'; 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/keyed_object.dart';
import 'package:rive/src/rive_core/animation/loop.dart'; import 'package:rive/src/rive_core/animation/loop.dart';
import 'package:rive/src/rive_core/artboard.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'; export 'package:rive/src/generated/animation/linear_animation_base.dart';
class LinearAnimation extends LinearAnimationBase { class LinearAnimation extends LinearAnimationBase {
@ -78,6 +79,27 @@ class LinearAnimation extends LinearAnimationBase {
@override @override
void workStartChanged(int from, int to) {} void workStartChanged(int from, int to) {}
/// Returns the end time of the animation in seconds
double get endTime => (enableWorkArea ? workEnd : duration).toDouble() / fps;
/// Returns the start time of the animation in seconds
double get startTime => (enableWorkArea ? workStart : 0).toDouble() / fps;
/// Convert a global clock to local seconds (takes into consideration work
/// area start/end, speed, looping).
double globalToLocalTime(double seconds) {
switch (loop) {
case Loop.oneShot:
return seconds + startTime;
case Loop.loop:
return seconds % (endTime - startTime) + startTime;
case Loop.pingPong:
var localTime = seconds % (endTime - startTime);
var direction = (seconds ~/ (endTime - startTime)) % 2;
return direction == 0 ? localTime + startTime : endTime - localTime;
}
}
@override @override
bool import(ImportStack stack) { bool import(ImportStack stack) {
var artboardImporter = stack.latest<ArtboardImporter>(ArtboardBase.typeKey); var artboardImporter = stack.latest<ArtboardImporter>(ArtboardBase.typeKey);

View File

@ -1,9 +1,12 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart';
import 'package:rive/src/rive_core/animation/loop.dart'; import 'package:rive/src/rive_core/animation/loop.dart';
class LinearAnimationInstance { class LinearAnimationInstance {
final LinearAnimation animation; final LinearAnimation animation;
double _time = 0; double _time = 0;
double _lastTime = 0;
double _totalTime = 0; double _totalTime = 0;
double _lastTotalTime = 0; double _lastTotalTime = 0;
int _direction = 1; int _direction = 1;
@ -18,7 +21,9 @@ class LinearAnimationInstance {
LinearAnimationInstance(this.animation) LinearAnimationInstance(this.animation)
: _time = : _time =
(animation.enableWorkArea ? animation.workStart : 0).toDouble() / (animation.enableWorkArea ? animation.workStart : 0).toDouble() /
animation.fps; animation.fps {
_lastTime = _time;
}
/// Note that when time is set, the direction will be changed to 1 /// Note that when time is set, the direction will be changed to 1
set time(double value) { set time(double value) {
@ -28,7 +33,7 @@ class LinearAnimationInstance {
// Make sure to keep last and total in relative lockstep so state machines // Make sure to keep last and total in relative lockstep so state machines
// can track change even when setting time. // can track change even when setting time.
var diff = _totalTime - _lastTotalTime; var diff = _totalTime - _lastTotalTime;
_time = _totalTime = value; _lastTime = _time = _totalTime = value;
_lastTotalTime = _totalTime - diff; _lastTotalTime = _totalTime - diff;
_direction = 1; _direction = 1;
} }
@ -36,39 +41,40 @@ class LinearAnimationInstance {
/// Returns the current time position of the animation in seconds /// Returns the current time position of the animation in seconds
double get time => _time; double get time => _time;
/// Returns the time the position was at when the previous advance was called.
double get lastTime => _lastTime;
/// Direction should only be +1 or -1 /// Direction should only be +1 or -1
set direction(int value) => _direction = value == -1 ? -1 : 1; set direction(int value) => _direction = value == -1 ? -1 : 1;
/// Returns the animation's play direction: 1 for forwards, -1 for backwards /// Returns the animation's play direction: 1 for forwards, -1 for backwards
int get direction => _direction; int get direction => _direction;
/// Returns the end time of the animation in seconds double get progress =>
double get endTime => (_time - animation.startTime) / (animation.endTime - animation.startTime);
(animation.enableWorkArea ? animation.workEnd : animation.duration)
.toDouble() /
animation.fps;
/// Returns the start time of the animation in seconds
double get startTime =>
(animation.enableWorkArea ? animation.workStart : 0).toDouble() /
animation.fps;
double get progress => (_time - startTime) / (endTime - startTime);
/// Resets the animation to the starting frame /// Resets the animation to the starting frame
void reset() => _time = startTime; void reset() => _time = animation.startTime;
/// Whether the controller driving this animation should keep requesting /// Whether the controller driving this animation should keep requesting
/// frames be drawn. /// frames be drawn.
bool get keepGoing => animation.loop != Loop.oneShot || !_didLoop; bool get keepGoing => animation.loop != Loop.oneShot || !_didLoop;
/// Apply the changes incurred during advance, also automatically fires any
/// accrued events.
void apply(CoreContext core, {double mix = 1}) {
animation.apply(time, coreContext: core, mix: mix);
}
bool advance(double elapsedSeconds) { bool advance(double elapsedSeconds) {
var deltaSeconds = elapsedSeconds * animation.speed * _direction; var deltaSeconds = elapsedSeconds * animation.speed * _direction;
_lastTotalTime = _totalTime; _lastTotalTime = _totalTime;
_totalTime += deltaSeconds; _totalTime += deltaSeconds;
_lastTime = _time;
_time += deltaSeconds; _time += deltaSeconds;
double frames = _time * animation.fps; double frames = _time * animation.fps;
var fps = animation.fps;
var start = animation.enableWorkArea ? animation.workStart : 0; var start = animation.enableWorkArea ? animation.workStart : 0;
var end = animation.enableWorkArea ? animation.workEnd : animation.duration; var end = animation.enableWorkArea ? animation.workEnd : animation.duration;
@ -82,18 +88,18 @@ class LinearAnimationInstance {
case Loop.oneShot: case Loop.oneShot:
if (frames > end) { if (frames > end) {
keepGoing = false; keepGoing = false;
_spilledTime = (frames - end) / animation.fps; _spilledTime = (frames - end) / fps;
frames = end.toDouble(); frames = end.toDouble();
_time = frames / animation.fps; _time = frames / fps;
_didLoop = true; _didLoop = true;
} }
break; break;
case Loop.loop: case Loop.loop:
if (frames >= end) { if (frames >= end) {
_spilledTime = (frames - end) / animation.fps; _spilledTime = (frames - end) / fps;
frames = _time * animation.fps; frames = _time * fps;
frames = start + (frames - start) % range; frames = start + (frames - start) % range;
_time = frames / animation.fps; _time = frames / fps;
_didLoop = true; _didLoop = true;
} }
break; break;
@ -120,6 +126,7 @@ class LinearAnimationInstance {
// advanced on regular intervals. // advanced on regular intervals.
break; break;
} }
_lastTime = _time;
} }
break; break;
} }

View File

@ -0,0 +1,51 @@
import 'package:rive/src/generated/animation/nested_linear_animation_base.dart';
import 'package:rive/src/rive_core/nested_artboard.dart';
export 'package:rive/src/generated/animation/nested_linear_animation_base.dart';
/// Need this abstraction to not depend on package:rive in rive_core.
// ignore: one_member_abstracts
abstract class NestedLinearAnimationInstance {
bool needsApply = true;
void goto(double value);
double get durationSeconds;
double get speed;
set speed(double value);
void advance(double elapsedSeconds);
void apply(covariant MountedArtboard artboard, double mix);
}
abstract class NestedLinearAnimation extends NestedLinearAnimationBase {
NestedLinearAnimationInstance? _linearAnimationInstance;
NestedLinearAnimationInstance? get linearAnimationInstance =>
_linearAnimationInstance;
set linearAnimationInstance(NestedLinearAnimationInstance? value) {
if (_linearAnimationInstance == value) {
return;
}
var from = _linearAnimationInstance;
_linearAnimationInstance = value;
linearAnimationInstanceChanged(from, value);
}
void linearAnimationInstanceChanged(
NestedLinearAnimationInstance? from, NestedLinearAnimationInstance? to) {}
@override
bool get isEnabled => true;
@override
void mixChanged(double from, double to) {
linearAnimationInstance?.needsApply = true;
}
@override
void advance(double elapsedSeconds, MountedArtboard mountedArtboard) {
if (linearAnimationInstance?.needsApply ?? false) {
linearAnimationInstance!.apply(mountedArtboard, mix);
linearAnimationInstance!.needsApply = false;
}
}
}

View File

@ -0,0 +1,24 @@
import 'package:rive/src/generated/animation/nested_remap_animation_base.dart';
import 'package:rive/src/rive_core/animation/nested_linear_animation.dart';
export 'package:rive/src/generated/animation/nested_remap_animation_base.dart';
class NestedRemapAnimation extends NestedRemapAnimationBase {
@override
void timeChanged(double from, double to) => syncTime();
void syncTime() {
if (linearAnimationInstance != null) {
linearAnimationInstance!
.goto(linearAnimationInstance!.durationSeconds * time);
}
}
@override
void linearAnimationInstanceChanged(NestedLinearAnimationInstance? from,
NestedLinearAnimationInstance? to) =>
syncTime();
@override
bool get isEnabled => true;
}

View File

@ -0,0 +1,32 @@
import 'package:rive/src/generated/animation/nested_simple_animation_base.dart';
import 'package:rive/src/rive_core/animation/nested_linear_animation.dart';
import 'package:rive/src/rive_core/nested_artboard.dart';
export 'package:rive/src/generated/animation/nested_simple_animation_base.dart';
class NestedSimpleAnimation extends NestedSimpleAnimationBase {
@override
void isPlayingChanged(bool from, bool to) {}
@override
void speedChanged(double from, double to) {
linearAnimationInstance?.speed = to;
}
@override
void linearAnimationInstanceChanged(
NestedLinearAnimationInstance? from, NestedLinearAnimationInstance? to) {
to?.speed = speed;
}
@override
bool get isEnabled => true;
@override
void advance(double elapsedSeconds, MountedArtboard mountedArtboard) {
if (isPlaying) {
linearAnimationInstance?.advance(elapsedSeconds);
}
super.advance(elapsedSeconds, mountedArtboard);
}
}

View File

@ -0,0 +1,14 @@
import 'package:rive/src/generated/animation/nested_state_machine_base.dart';
import 'package:rive/src/rive_core/nested_artboard.dart';
export 'package:rive/src/generated/animation/nested_state_machine_base.dart';
class NestedStateMachine extends NestedStateMachineBase {
@override
void advance(double elapsedSeconds, MountedArtboard mountedArtboard) {
// TODO: implement advance
}
@override
bool get isEnabled => false;
}

View File

@ -1,8 +1,9 @@
import 'package:rive/src/core/core.dart'; 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_input.dart';
import 'package:rive/src/rive_core/animation/state_machine_layer.dart'; import 'package:rive/src/rive_core/animation/state_machine_layer.dart';
import 'package:rive/src/rive_core/artboard.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'; export 'package:rive/src/generated/animation/state_machine_base.dart';
class StateMachine extends StateMachineBase { class StateMachine extends StateMachineBase {

View File

@ -1,8 +1,8 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/core/core.dart'; import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart';
import 'package:rive/src/generated/animation/state_machine_component_base.dart'; import 'package:rive/src/generated/animation/state_machine_component_base.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart';
export 'package:rive/src/generated/animation/state_machine_component_base.dart'; export 'package:rive/src/generated/animation/state_machine_component_base.dart';

View File

@ -1,8 +1,9 @@
import 'dart:collection'; 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.dart';
import 'package:rive/src/rive_core/animation/state_machine_component.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'; export 'package:rive/src/generated/animation/state_machine_input_base.dart';
abstract class StateMachineInput extends StateMachineInputBase { abstract class StateMachineInput extends StateMachineInputBase {

View File

@ -1,13 +1,14 @@
import 'dart:collection'; 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/any_state.dart';
import 'package:rive/src/rive_core/animation/entry_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/exit_state.dart';
import 'package:rive/src/rive_core/animation/layer_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.dart';
import 'package:rive/src/rive_core/animation/state_machine_component.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'; export 'package:rive/src/generated/animation/state_machine_layer_base.dart';
class StateMachineLayer extends StateMachineLayerBase { class StateMachineLayer extends StateMachineLayerBase {

View File

@ -1,6 +1,7 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/core/core.dart'; 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.dart';
import 'package:rive/src/rive_core/animation/animation_state_instance.dart'; import 'package:rive/src/rive_core/animation/animation_state_instance.dart';
import 'package:rive/src/rive_core/animation/layer_state.dart'; import 'package:rive/src/rive_core/animation/layer_state.dart';
@ -10,8 +11,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/state_instance.dart';
import 'package:rive/src/rive_core/animation/transition_condition.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/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'; import 'package:rive/src/rive_core/state_transition_flags.dart';
export 'package:rive/src/generated/animation/state_transition_base.dart'; export 'package:rive/src/generated/animation/state_transition_base.dart';
enum AllowTransition { no, waitingForExit, yes } enum AllowTransition { no, waitingForExit, yes }

View File

@ -1,7 +1,9 @@
import 'dart:collection'; 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/state_machine_bool.dart';
import 'package:rive/src/rive_core/animation/transition_condition.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'; export 'package:rive/src/generated/animation/transition_bool_condition_base.dart';
class TransitionBoolCondition extends TransitionBoolConditionBase { class TransitionBoolCondition extends TransitionBoolConditionBase {

View File

@ -1,9 +1,9 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/core/core.dart'; 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_machine_input.dart';
import 'package:rive/src/rive_core/animation/state_transition.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'; export 'package:rive/src/generated/animation/transition_condition_base.dart';

View File

@ -1,8 +1,8 @@
import 'dart:collection'; 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/state_machine_number.dart';
import 'package:rive/src/rive_core/animation/transition_condition.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'; export 'package:rive/src/generated/animation/transition_number_condition_base.dart';

View File

@ -1,7 +1,8 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/rive_core/animation/state_machine_trigger.dart';
import 'package:rive/src/generated/animation/transition_trigger_condition_base.dart'; import 'package:rive/src/generated/animation/transition_trigger_condition_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_trigger.dart';
export '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 { class TransitionTriggerCondition extends TransitionTriggerConditionBase {

View File

@ -1,5 +1,6 @@
import 'package:rive/src/rive_core/animation/transition_condition.dart';
import 'package:rive/src/generated/animation/transition_value_condition_base.dart'; import 'package:rive/src/generated/animation/transition_value_condition_base.dart';
import 'package:rive/src/rive_core/animation/transition_condition.dart';
export '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 { abstract class TransitionValueCondition extends TransitionValueConditionBase {

View File

@ -1,6 +1,7 @@
import 'dart:ui'; import 'dart:ui';
import 'package:rive/src/core/core.dart'; 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/animation.dart';
import 'package:rive/src/rive_core/animation/linear_animation.dart'; import 'package:rive/src/rive_core/animation/linear_animation.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart'; import 'package:rive/src/rive_core/animation/state_machine.dart';
@ -11,10 +12,10 @@ 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/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/rive_animation_controller.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/paint/shape_paint_mutator.dart';
import 'package:rive/src/rive_core/shapes/shape_paint_container.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'; import 'package:rive/src/utilities/dependency_sorter.dart';
export 'package:rive/src/generated/artboard_base.dart'; export 'package:rive/src/generated/artboard_base.dart';
@ -120,8 +121,10 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
return didUpdate; return didUpdate;
} }
final Set<NestedArtboard> _activeNestedArtboards = {};
/// Update any dirty components in this artboard. /// Update any dirty components in this artboard.
bool advance(double elapsedSeconds) { bool advance(double elapsedSeconds, {bool nested = false}) {
bool didUpdate = false; bool didUpdate = false;
for (final controller in _animationControllers) { for (final controller in _animationControllers) {
if (controller.isActive) { if (controller.isActive) {
@ -129,6 +132,14 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
didUpdate = true; didUpdate = true;
} }
} }
if (nested) {
var active = _activeNestedArtboards.toList(growable: false);
for (final activeNestedArtboard in active) {
activeNestedArtboard.advance(elapsedSeconds);
}
}
if (updateComponents() || didUpdate) { if (updateComponents() || didUpdate) {
return true; return true;
} }
@ -216,12 +227,18 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
if (!_components.add(component)) { if (!_components.add(component)) {
return; return;
} }
if (component is NestedArtboard) {
_activeNestedArtboards.add(component);
}
} }
/// Remove a component from the artboard and its various tracked lists of /// Remove a component from the artboard and its various tracked lists of
/// components. /// components.
void removeComponent(Component component) { void removeComponent(Component component) {
_components.remove(component); _components.remove(component);
if (component is NestedArtboard) {
_activeNestedArtboards.remove(component);
}
} }
/// Let the artboard know that the drawables need to be resorted before /// Let the artboard know that the drawables need to be resorted before

View File

@ -1,7 +1,8 @@
import 'package:rive/src/generated/bones/bone_base.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.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/math/vec2d.dart';
import 'package:rive/src/generated/bones/bone_base.dart';
export 'package:rive/src/generated/bones/bone_base.dart'; export 'package:rive/src/generated/bones/bone_base.dart';
typedef bool BoneCallback(Bone bone); typedef bool BoneCallback(Bone bone);

View File

@ -1,5 +1,6 @@
import 'package:rive/src/rive_core/math/vec2d.dart';
import 'package:rive/src/generated/bones/cubic_weight_base.dart'; import 'package:rive/src/generated/bones/cubic_weight_base.dart';
import 'package:rive/src/rive_core/math/vec2d.dart';
export 'package:rive/src/generated/bones/cubic_weight_base.dart'; export 'package:rive/src/generated/bones/cubic_weight_base.dart';
class CubicWeight extends CubicWeightBase { class CubicWeight extends CubicWeightBase {

View File

@ -1,12 +1,12 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:rive/src/generated/bones/skin_base.dart';
import 'package:rive/src/rive_core/bones/bone.dart'; import 'package:rive/src/rive_core/bones/bone.dart';
import 'package:rive/src/rive_core/bones/skinnable.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/bones/tendon.dart';
import 'package:rive/src/rive_core/component.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/mat2d.dart';
import 'package:rive/src/rive_core/shapes/path_vertex.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'; export 'package:rive/src/generated/bones/skin_base.dart';

View File

@ -1,6 +1,7 @@
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/bones/skeletal_component.dart';
import 'package:rive/src/rive_core/math/mat2d.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'; export 'package:rive/src/generated/bones/tendon_base.dart';
class Tendon extends TendonBase { class Tendon extends TendonBase {

View File

@ -1,8 +1,9 @@
import 'dart:typed_data'; 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/mat2d.dart';
import 'package:rive/src/rive_core/math/vec2d.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'; export 'package:rive/src/generated/bones/weight_base.dart';
class Weight extends WeightBase { class Weight extends WeightBase {

View File

@ -1,11 +1,11 @@
import 'package:rive/src/core/core.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:rive/src/core/core.dart';
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/rive_core/artboard.dart'; import 'package:rive/src/rive_core/artboard.dart';
import 'package:rive/src/rive_core/container_component.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/dependency_sorter.dart';
import 'package:rive/src/utilities/tops.dart'; import 'package:rive/src/utilities/tops.dart';
export 'package:rive/src/generated/component_base.dart'; export 'package:rive/src/generated/component_base.dart';
abstract class Component extends ComponentBase<RuntimeArtboard> abstract class Component extends ComponentBase<RuntimeArtboard>

View File

@ -1,8 +1,9 @@
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/rive_core/component.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/mat2d.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart'; import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/world_transform_component.dart'; import 'package:rive/src/rive_core/world_transform_component.dart';
export 'package:rive/src/generated/constraints/constraint_base.dart'; export 'package:rive/src/generated/constraints/constraint_base.dart';
/// A specialized [Component] which can be parented to any [TransformComponent] /// A specialized [Component] which can be parented to any [TransformComponent]

View File

@ -1,6 +1,7 @@
import 'package:rive/src/rive_core/math/vec2d.dart';
import 'package:rive/src/generated/constraints/distance_constraint_base.dart'; import 'package:rive/src/generated/constraints/distance_constraint_base.dart';
import 'package:rive/src/rive_core/math/vec2d.dart';
import 'package:rive/src/rive_core/transform_component.dart'; import 'package:rive/src/rive_core/transform_component.dart';
export 'package:rive/src/generated/constraints/distance_constraint_base.dart'; export 'package:rive/src/generated/constraints/distance_constraint_base.dart';
/// [DistanceConstraint]'s logical distancing method. /// [DistanceConstraint]'s logical distancing method.

View File

@ -1,11 +1,13 @@
import 'dart:math'; import 'dart:math';
import 'package:rive/src/generated/constraints/ik_constraint_base.dart';
import 'package:rive/src/rive_core/bones/bone.dart'; import 'package:rive/src/rive_core/bones/bone.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.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/transform_components.dart';
import 'package:rive/src/rive_core/math/vec2d.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'; import 'package:rive/src/rive_core/transform_component.dart';
export 'package:rive/src/generated/constraints/ik_constraint_base.dart'; export 'package:rive/src/generated/constraints/ik_constraint_base.dart';
/// A constraint which rotates its constrained bone and the parentBoneCount /// A constraint which rotates its constrained bone and the parentBoneCount

View File

@ -1,11 +1,12 @@
import 'dart:math'; import 'dart:math';
import 'package:rive/src/generated/constraints/rotation_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.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/transform_components.dart';
import 'package:rive/src/generated/constraints/rotation_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart'; import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart'; import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/rotation_constraint_base.dart'; export 'package:rive/src/generated/constraints/rotation_constraint_base.dart';
/// A constraint copies the rotation from the target component to the /// A constraint copies the rotation from the target component to the

View File

@ -1,9 +1,10 @@
import 'package:rive/src/generated/constraints/scale_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.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/transform_components.dart';
import 'package:rive/src/generated/constraints/scale_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart'; import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart'; import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/scale_constraint_base.dart'; export 'package:rive/src/generated/constraints/scale_constraint_base.dart';
/// A constraint copies the scale from the target component to the /// A constraint copies the scale from the target component to the

View File

@ -1,10 +1,11 @@
import 'dart:math'; import 'dart:math';
import 'package:rive/src/generated/constraints/transform_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/generated/constraints/transform_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart'; import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart'; import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/transform_constraint_base.dart'; export 'package:rive/src/generated/constraints/transform_constraint_base.dart';
/// A constraint copies the transform from the target component to the /// A constraint copies the transform from the target component to the

View File

@ -1,6 +1,7 @@
import 'package:rive/src/rive_core/math/transform_components.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart'; import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/math/transform_components.dart';
import 'package:rive/src/rive_core/transform_space.dart'; import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/transform_space_constraint_base.dart'; export 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
abstract class TransformSpaceConstraint extends TransformSpaceConstraintBase { abstract class TransformSpaceConstraint extends TransformSpaceConstraintBase {

View File

@ -1,9 +1,10 @@
import 'package:rive/src/generated/constraints/translation_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.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/math/vec2d.dart';
import 'package:rive/src/generated/constraints/translation_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart'; import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart'; import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/translation_constraint_base.dart'; export 'package:rive/src/generated/constraints/translation_constraint_base.dart';
/// A constraint copies the translation from the target component to the /// A constraint copies the translation from the target component to the

View File

@ -1,9 +1,9 @@
import 'package:rive/src/core/core.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rive/src/core/core.dart';
import 'package:rive/src/generated/container_component_base.dart';
import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/component.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/drawable.dart'; import 'package:rive/src/rive_core/drawable.dart';
import 'package:rive/src/generated/container_component_base.dart';
typedef bool DescentCallback(Component component); typedef bool DescentCallback(Component component);

View File

@ -1,7 +1,8 @@
import 'package:rive/src/core/core.dart'; 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/component.dart';
import 'package:rive/src/rive_core/draw_target.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'; export 'package:rive/src/generated/draw_rules_base.dart';
class DrawRules extends DrawRulesBase { class DrawRules extends DrawRulesBase {

View File

@ -1,6 +1,6 @@
import 'package:rive/src/core/core.dart'; import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/drawable.dart';
import 'package:rive/src/generated/draw_target_base.dart'; import 'package:rive/src/generated/draw_target_base.dart';
import 'package:rive/src/rive_core/drawable.dart';
export 'package:rive/src/generated/draw_target_base.dart'; export 'package:rive/src/generated/draw_target_base.dart';

View File

@ -1,12 +1,13 @@
import 'dart:ui'; 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_dirt.dart';
import 'package:rive/src/rive_core/component_flags.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/container_component.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/shapes/clipping_shape.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'; import 'package:rive/src/rive_core/transform_component.dart';
export 'package:rive/src/generated/drawable_base.dart'; export 'package:rive/src/generated/drawable_base.dart';
abstract class Drawable extends DrawableBase { abstract class Drawable extends DrawableBase {

View File

@ -0,0 +1,33 @@
import 'package:rive/src/generated/nested_animation_base.dart';
import 'package:rive/src/rive_core/animation/animation.dart';
import 'package:rive/src/rive_core/nested_artboard.dart';
export 'package:rive/src/generated/nested_animation_base.dart';
abstract class NestedAnimation<T extends Animation>
extends NestedAnimationBase {
NestedArtboard? get nestedArtboard =>
parent is NestedArtboard ? parent as NestedArtboard : null;
@override
void animationIdChanged(int from, int to) {}
bool get isEnabled;
void advance(double elapsedSeconds, MountedArtboard mountedArtboard);
// @override
// bool import(ImportStack stack) {
// var backboardImporter =
// stack.latest<BackboardImporter>(BackboardBase.typeKey);
// if (backboardImporter == null) {
// return false;
// }
// backboardImporter.addNestedArtboard(this);
// return super.import(stack);
// }
@override
void update(int dirt) {}
}

View File

@ -1,9 +1,16 @@
import 'dart:ui'; import 'dart:ui';
import 'package:rive/src/core/core.dart'; import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/backboard.dart';
import 'package:rive/src/rive_core/component_dirt.dart';
import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/generated/nested_artboard_base.dart'; import 'package:rive/src/generated/nested_artboard_base.dart';
import 'package:rive/src/rive_core/animation/nested_remap_animation.dart';
import 'package:rive/src/rive_core/animation/nested_simple_animation.dart';
import 'package:rive/src/rive_core/backboard.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/aabb.dart';
import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/rive_core/nested_animation.dart';
export 'package:rive/src/generated/nested_artboard_base.dart'; export 'package:rive/src/generated/nested_artboard_base.dart';
/// Represents the nested Artboard that'll actually be mounted and placed into /// Represents the nested Artboard that'll actually be mounted and placed into
@ -12,9 +19,14 @@ abstract class MountedArtboard {
void draw(Canvas canvas); void draw(Canvas canvas);
Mat2D get worldTransform; Mat2D get worldTransform;
set worldTransform(Mat2D value); set worldTransform(Mat2D value);
AABB get bounds;
} }
class NestedArtboard extends NestedArtboardBase { class NestedArtboard extends NestedArtboardBase {
/// [NestedAnimation]s applied to this [NestedArtboard].
final List<NestedAnimation> _animations = [];
Iterable<NestedAnimation> get animations => _animations;
MountedArtboard? _mountedArtboard; MountedArtboard? _mountedArtboard;
MountedArtboard? get mountedArtboard => _mountedArtboard; MountedArtboard? get mountedArtboard => _mountedArtboard;
set mountedArtboard(MountedArtboard? value) { set mountedArtboard(MountedArtboard? value) {
@ -30,12 +42,46 @@ class NestedArtboard extends NestedArtboardBase {
void artboardIdChanged(int from, int to) {} void artboardIdChanged(int from, int to) {}
@override
void childAdded(Component child) {
super.childAdded(child);
switch (child.coreType) {
case NestedRemapAnimationBase.typeKey:
case NestedSimpleAnimationBase.typeKey:
_animations.add(child as NestedAnimation);
break;
}
}
@override
void childRemoved(Component child) {
super.childRemoved(child);
switch (child.coreType) {
case NestedRemapAnimationBase.typeKey:
case NestedSimpleAnimationBase.typeKey:
_animations.remove(child as NestedAnimation);
break;
}
}
@override @override
void updateWorldTransform() { void updateWorldTransform() {
super.updateWorldTransform(); super.updateWorldTransform();
_mountedArtboard?.worldTransform = worldTransform; _mountedArtboard?.worldTransform = worldTransform;
} }
void advance(double elapsedSeconds) {
if (mountedArtboard == null) {
return;
}
for (final animation in _animations) {
if (animation.isEnabled) {
animation.advance(elapsedSeconds, mountedArtboard!);
}
}
}
@override @override
void draw(Canvas canvas) => mountedArtboard?.draw(canvas); void draw(Canvas canvas) => mountedArtboard?.draw(canvas);

View File

@ -1,6 +1,7 @@
import 'package:rive/src/generated/node_base.dart';
import 'package:rive/src/rive_core/math/aabb.dart'; import 'package:rive/src/rive_core/math/aabb.dart';
import 'package:rive/src/rive_core/math/vec2d.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'; export 'package:rive/src/generated/node_base.dart';
class _UnknownNode extends Node {} class _UnknownNode extends Node {}

View File

@ -1,9 +1,10 @@
import 'dart:ui'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/node.dart'; import 'package:rive/src/rive_core/node.dart';
import 'package:rive/src/rive_core/shapes/shape.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'; export 'package:rive/src/generated/shapes/clipping_shape_base.dart';
class ClippingShape extends ClippingShapeBase { class ClippingShape extends ClippingShapeBase {

View File

@ -1,9 +1,10 @@
import 'dart:math'; import 'dart:math';
import 'package:rive/src/core/core.dart'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/math/vec2d.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'; export 'package:rive/src/generated/shapes/cubic_asymmetric_vertex_base.dart';
class CubicAsymmetricVertex extends CubicAsymmetricVertexBase { class CubicAsymmetricVertex extends CubicAsymmetricVertexBase {

View File

@ -1,9 +1,10 @@
import 'dart:math'; import 'dart:math';
import 'package:rive/src/core/core.dart'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/math/vec2d.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'; export 'package:rive/src/generated/shapes/cubic_detached_vertex_base.dart';
class CubicDetachedVertex extends CubicDetachedVertexBase { class CubicDetachedVertex extends CubicDetachedVertexBase {

View File

@ -1,9 +1,10 @@
import 'dart:math'; import 'dart:math';
import 'package:rive/src/core/core.dart'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/math/vec2d.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'; export 'package:rive/src/generated/shapes/cubic_mirrored_vertex_base.dart';
class CubicMirroredVertex extends CubicMirroredVertexBase { class CubicMirroredVertex extends CubicMirroredVertexBase {

View File

@ -1,9 +1,10 @@
import 'dart:typed_data'; 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/bones/weight.dart';
import 'package:rive/src/rive_core/math/mat2d.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/math/vec2d.dart';
import 'package:rive/src/generated/shapes/cubic_vertex_base.dart';
export 'package:rive/src/generated/shapes/cubic_vertex_base.dart'; export 'package:rive/src/generated/shapes/cubic_vertex_base.dart';
abstract class CubicVertex extends CubicVertexBase { abstract class CubicVertex extends CubicVertexBase {

View File

@ -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/math/circle_constant.dart';
import 'package:rive/src/rive_core/shapes/cubic_detached_vertex.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/rive_core/shapes/path_vertex.dart';
import 'package:rive/src/generated/shapes/ellipse_base.dart';
export 'package:rive/src/generated/shapes/ellipse_base.dart'; export 'package:rive/src/generated/shapes/ellipse_base.dart';

View File

@ -1,8 +1,9 @@
import 'dart:ui'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/shapes/shape_paint_container.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'; export 'package:rive/src/generated/shapes/paint/fill_base.dart';
/// A fill Shape painter. /// A fill Shape painter.

View File

@ -1,8 +1,8 @@
import 'dart:ui' as ui; 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/container_component.dart';
import 'package:rive/src/rive_core/shapes/paint/linear_gradient.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'; export 'package:rive/src/generated/shapes/paint/gradient_stop_base.dart';

View File

@ -1,13 +1,14 @@
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:meta/meta.dart'; 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.dart';
import 'package:rive/src/rive_core/component_dirt.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/math/vec2d.dart';
import 'package:rive/src/rive_core/shapes/paint/gradient_stop.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/paint/shape_paint_mutator.dart';
import 'package:rive/src/rive_core/shapes/shape.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'; 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 /// A core linear gradient. Can be added as a child to a [Shape]'s [Fill] or

View File

@ -1,13 +1,14 @@
import 'dart:ui'; import 'dart:ui';
import 'package:meta/meta.dart'; 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.dart';
import 'package:rive/src/rive_core/component_dirt.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/container_component.dart';
import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.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.dart';
import 'package:rive/src/rive_core/shapes/shape_paint_container.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'; export 'package:rive/src/generated/shapes/paint/shape_paint_base.dart';
/// Generic ShapePaint that abstracts Stroke and Fill. Automatically hooks up /// Generic ShapePaint that abstracts Stroke and Fill. Automatically hooks up

View File

@ -1,9 +1,10 @@
import 'dart:ui'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/shapes/paint/shape_paint.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/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'; export 'package:rive/src/generated/shapes/paint/solid_color_base.dart';
/// A solid color painter for a shape. Works for both Fill and Stroke. /// A solid color painter for a shape. Works for both Fill and Stroke.

View File

@ -1,9 +1,10 @@
import 'package:flutter/material.dart'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/shapes/paint/stroke_effect.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.dart';
import 'package:rive/src/rive_core/shapes/shape_paint_container.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'; export 'package:rive/src/generated/shapes/paint/stroke_base.dart';
/// A stroke Shape painter. /// A stroke Shape painter.

View File

@ -1,11 +1,11 @@
import 'dart:ui'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/shapes/paint/stroke.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/stroke_effect.dart';
import 'package:rive/src/rive_core/shapes/paint/trim_path_drawing.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'; export 'package:rive/src/generated/shapes/paint/trim_path_base.dart';
enum TrimPathMode { enum TrimPathMode {

View File

@ -1,5 +1,6 @@
import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/generated/shapes/parametric_path_base.dart'; import 'package:rive/src/generated/shapes/parametric_path_base.dart';
import 'package:rive/src/rive_core/math/mat2d.dart';
export 'package:rive/src/generated/shapes/parametric_path_base.dart'; export 'package:rive/src/generated/shapes/parametric_path_base.dart';
abstract class ParametricPath extends ParametricPathBase { abstract class ParametricPath extends ParametricPathBase {

View File

@ -1,6 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'dart:ui' as ui; 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.dart';
import 'package:rive/src/rive_core/component_dirt.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/component_flags.dart';
@ -11,7 +12,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/path_vertex.dart';
import 'package:rive/src/rive_core/shapes/shape.dart'; import 'package:rive/src/rive_core/shapes/shape.dart';
import 'package:rive/src/rive_core/shapes/straight_vertex.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'; export 'package:rive/src/generated/shapes/path_base.dart';
/// An abstract low level path that gets implemented by parametric and point /// An abstract low level path that gets implemented by parametric and point

View File

@ -1,11 +1,12 @@
import 'dart:typed_data'; 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/bones/weight.dart';
import 'package:rive/src/rive_core/component.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/mat2d.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/shapes/path.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'; export 'package:rive/src/generated/shapes/path_vertex_base.dart';
abstract class PathVertex<T extends Weight> extends PathVertexBase { abstract class PathVertex<T extends Weight> extends PathVertexBase {

View File

@ -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/bones/skinnable.dart';
import 'package:rive/src/rive_core/component.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_dirt.dart';
import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/rive_core/shapes/path_vertex.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'; export 'package:rive/src/generated/shapes/points_path_base.dart';

View File

@ -1,9 +1,9 @@
import 'dart:math'; 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/bones/weight.dart';
import 'package:rive/src/rive_core/shapes/path_vertex.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/rive_core/shapes/straight_vertex.dart';
import 'package:rive/src/generated/shapes/polygon_base.dart';
export 'package:rive/src/generated/shapes/polygon_base.dart'; export 'package:rive/src/generated/shapes/polygon_base.dart';

View File

@ -1,6 +1,7 @@
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/path_vertex.dart';
import 'package:rive/src/rive_core/shapes/straight_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'; export 'package:rive/src/generated/shapes/rectangle_base.dart';
class Rectangle extends RectangleBase { class Rectangle extends RectangleBase {

View File

@ -1,6 +1,7 @@
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:collection/collection.dart'; 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/component_dirt.dart';
import 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart' as core; 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'; import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart';
@ -8,7 +9,6 @@ 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.dart';
import 'package:rive/src/rive_core/shapes/path_composer.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/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'; export 'package:rive/src/generated/shapes/shape_base.dart';

View File

@ -1,9 +1,10 @@
import 'dart:math'; 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/bones/weight.dart';
import 'package:rive/src/rive_core/shapes/path_vertex.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/rive_core/shapes/straight_vertex.dart';
import 'package:rive/src/generated/shapes/star_base.dart';
export 'package:rive/src/generated/shapes/star_base.dart'; export 'package:rive/src/generated/shapes/star_base.dart';
class Star extends StarBase { class Star extends StarBase {

View File

@ -1,8 +1,9 @@
import 'package:rive/src/core/core.dart'; 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/bones/weight.dart';
import 'package:rive/src/rive_core/component.dart'; import 'package:rive/src/rive_core/component.dart';
import 'package:rive/src/rive_core/math/vec2d.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'; export 'package:rive/src/generated/shapes/straight_vertex_base.dart';
class StraightVertex extends StraightVertexBase { class StraightVertex extends StraightVertexBase {

View File

@ -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/path_vertex.dart';
import 'package:rive/src/rive_core/shapes/straight_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 the Base class for external use (e.g. rive.dart)
export 'package:rive/src/generated/shapes/triangle_base.dart'; export 'package:rive/src/generated/shapes/triangle_base.dart';

View File

@ -1,8 +1,8 @@
import 'dart:collection'; import 'dart:collection';
import 'package:rive/src/core/core.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.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.dart';
import 'package:rive/src/rive_core/animation/animation_state_instance.dart'; import 'package:rive/src/rive_core/animation/animation_state_instance.dart';
import 'package:rive/src/rive_core/animation/any_state.dart'; import 'package:rive/src/rive_core/animation/any_state.dart';
@ -25,6 +25,7 @@ typedef OnLayerStateChange = void Function(LayerState);
class LayerController { class LayerController {
final StateMachineLayer layer; final StateMachineLayer layer;
final StateInstance anyStateInstance; final StateInstance anyStateInstance;
final CoreContext core;
StateInstance? _currentState; StateInstance? _currentState;
StateInstance? _stateFrom; StateInstance? _stateFrom;
@ -37,8 +38,11 @@ class LayerController {
/// Takes the state machine name and state name /// Takes the state machine name and state name
final OnLayerStateChange? onLayerStateChange; final OnLayerStateChange? onLayerStateChange;
LayerController(this.layer, {this.onLayerStateChange}) LayerController(
: assert(layer.anyState != null), this.layer, {
required this.core,
this.onLayerStateChange,
}) : assert(layer.anyState != null),
anyStateInstance = layer.anyState!.makeInstance() { anyStateInstance = layer.anyState!.makeInstance() {
_changeState(layer.entryState); _changeState(layer.entryState);
} }
@ -237,6 +241,7 @@ class StateMachineController extends RiveAnimationController<CoreContext> {
for (final layer in stateMachine.layers) { for (final layer in stateMachine.layers) {
layerControllers.add(LayerController( layerControllers.add(LayerController(
layer, layer,
core: core,
onLayerStateChange: _onStateChange, onLayerStateChange: _onStateChange,
)); ));
} }

View File

@ -1,4 +1,6 @@
import 'package:flutter/foundation.dart'; 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.dart';
import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/component_dirt.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
@ -13,11 +15,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/mat2d.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/shapes/clipping_shape.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 'package:rive/src/rive_core/world_transform_component.dart'; import 'package:rive/src/rive_core/world_transform_component.dart';
import 'constraints/distance_constraint.dart'; import 'constraints/distance_constraint.dart';
export 'package:rive/src/generated/transform_component_base.dart'; export 'package:rive/src/generated/transform_component_base.dart';
abstract class TransformComponent extends TransformComponentBase { abstract class TransformComponent extends TransformComponentBase {

View File

@ -1,6 +1,7 @@
import 'package:rive/src/generated/world_transform_component_base.dart';
import 'package:rive/src/rive_core/component_dirt.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/math/mat2d.dart';
import 'package:rive/src/generated/world_transform_component_base.dart';
export 'package:rive/src/generated/world_transform_component_base.dart'; export 'package:rive/src/generated/world_transform_component_base.dart';
/// A Component with world transform. /// A Component with world transform.

View File

@ -1,6 +1,9 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:rive/src/core/core.dart'; import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/linear_animation_instance.dart';
import 'package:rive/src/rive_core/animation/nested_linear_animation.dart';
import 'package:rive/src/rive_core/artboard.dart'; import 'package:rive/src/rive_core/artboard.dart';
import 'package:rive/src/rive_core/math/aabb.dart';
import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/rive_core/nested_artboard.dart'; import 'package:rive/src/rive_core/nested_artboard.dart';
@ -12,16 +15,74 @@ class RuntimeNestedArtboard extends NestedArtboard {
object.copy(this); object.copy(this);
if (sourceArtboard != null) { if (sourceArtboard != null) {
object.sourceArtboard = sourceArtboard; object.sourceArtboard = sourceArtboard;
object.mountedArtboard = var runtimeArtboardInstance =
RuntimeMountedArtboard(sourceArtboard!.instance()); sourceArtboard!.instance() as RuntimeArtboard;
object.mountedArtboard = RuntimeMountedArtboard(runtimeArtboardInstance);
} }
return object as K; return object as K;
} }
@override
void onAdded() {
super.onAdded();
if (mountedArtboard is! RuntimeMountedArtboard ||
sourceArtboard == null ||
animations.isEmpty) {
return;
}
var runtimeLinearAnimations =
sourceArtboard!.linearAnimations.toList(growable: false);
for (final animation in animations) {
if (animation is NestedLinearAnimation) {
var animationId = animation.animationId;
if (animationId >= 0 && animationId < runtimeLinearAnimations.length) {
animation.linearAnimationInstance =
RuntimeNestedLinearAnimationInstance(LinearAnimationInstance(
runtimeLinearAnimations[animationId]));
}
}
}
}
}
class RuntimeNestedLinearAnimationInstance
extends NestedLinearAnimationInstance {
final LinearAnimationInstance linearAnimation;
RuntimeNestedLinearAnimationInstance(this.linearAnimation);
@override
void apply(RuntimeMountedArtboard artboard, double mix) {
linearAnimation.animation.apply(linearAnimation.time,
coreContext: artboard.artboardInstance, mix: mix);
}
@override
void advance(double elapsedSeconds) {
needsApply = true;
linearAnimation.advance(elapsedSeconds * speed);
}
@override
double speed = 1;
@override
void goto(double value) {
var localTime = linearAnimation.animation.globalToLocalTime(value);
if (localTime == linearAnimation.time) {
return;
}
needsApply = true;
linearAnimation.time = localTime;
}
@override
double get durationSeconds => linearAnimation.animation.durationSeconds;
} }
class RuntimeMountedArtboard extends MountedArtboard { class RuntimeMountedArtboard extends MountedArtboard {
final Artboard artboardInstance; final RuntimeArtboard artboardInstance;
RuntimeMountedArtboard(this.artboardInstance); RuntimeMountedArtboard(this.artboardInstance);
@override @override
@ -37,4 +98,14 @@ class RuntimeMountedArtboard extends MountedArtboard {
artboardInstance.draw(canvas); artboardInstance.draw(canvas);
canvas.restore(); canvas.restore();
} }
@override
AABB get bounds {
var width = artboardInstance.width;
var height = artboardInstance.height;
var x = -artboardInstance.originX * width;
var y = -artboardInstance.originY * height;
return AABB.fromValues(x, y, x + width, y + height);
}
} }

View File

@ -33,8 +33,8 @@ void main() {
LinearAnimationInstance instance = LinearAnimationInstance instance =
LinearAnimationInstance(artboard.animations.first as LinearAnimation); LinearAnimationInstance(artboard.animations.first as LinearAnimation);
final startTime = instance.startTime; final startTime = instance.animation.startTime;
final endTime = instance.endTime; final endTime = instance.animation.endTime;
expect(startTime <= endTime, isTrue); expect(startTime <= endTime, isTrue);
expect(instance.direction, 1); expect(instance.direction, 1);
// Advance the animation to the mid point // Advance the animation to the mid point
@ -54,15 +54,15 @@ void main() {
LinearAnimationInstance(artboard.animations.first as LinearAnimation); LinearAnimationInstance(artboard.animations.first as LinearAnimation);
// Check the starting position // Check the starting position
expect(instance.startTime < instance.endTime, isTrue); expect(instance.animation.startTime < instance.animation.endTime, isTrue);
expect(instance.startTime, instance.time); expect(instance.animation.startTime, instance.time);
// Advance // Advance
instance.advance(instance.endTime); instance.advance(instance.animation.endTime);
expect(instance.time, instance.endTime); expect(instance.time, instance.animation.endTime);
// Reset // Reset
instance.reset(); instance.reset();
expect(instance.time, instance.startTime); expect(instance.time, instance.animation.startTime);
}); });
} }