mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-05-17 13:26:03 +08:00
Working on nnbd.
This commit is contained in:
@ -28,18 +28,16 @@ class _ExampleAnimationState extends State<ExampleAnimation> {
|
||||
// download this. The RiveFile just expects a list of bytes.
|
||||
rootBundle.load('assets/dino.riv').then(
|
||||
(data) async {
|
||||
final file = RiveFile();
|
||||
|
||||
// Load the RiveFile from the binary data.
|
||||
if (file.import(data)) {
|
||||
// The artboard is the root of the animation and gets drawn in the
|
||||
// Rive widget.
|
||||
final artboard = file.mainArtboard;
|
||||
// Add a controller to play back a known animation on the main/default
|
||||
// artboard. We store a reference to it so we can toggle playback.
|
||||
artboard.addController(_controller = SimpleAnimation('Run'));
|
||||
setState(() => _riveArtboard = artboard);
|
||||
}
|
||||
final file = RiveFile.import(data);
|
||||
|
||||
// The artboard is the root of the animation and gets drawn in the
|
||||
// Rive widget.
|
||||
final artboard = file.mainArtboard;
|
||||
// Add a controller to play back a known animation on the main/default
|
||||
// artboard. We store a reference to it so we can toggle playback.
|
||||
artboard.addController(_controller = SimpleAnimation('Run'));
|
||||
setState(() => _riveArtboard = artboard);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -11,10 +11,6 @@ class ExampleStateMachine extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ExampleStateMachineState extends State<ExampleStateMachine> {
|
||||
void _togglePlay() {
|
||||
setState(() => _controller.isActive = !_controller.isActive);
|
||||
}
|
||||
|
||||
/// Tracks if the animation is playing by whether controller is running.
|
||||
bool get isPlaying => _controller?.isActive ?? false;
|
||||
|
||||
@ -31,22 +27,20 @@ class _ExampleStateMachineState extends State<ExampleStateMachine> {
|
||||
// download this. The RiveFile just expects a list of bytes.
|
||||
rootBundle.load('assets/rocket.riv').then(
|
||||
(data) async {
|
||||
final file = RiveFile();
|
||||
|
||||
// Load the RiveFile from the binary data.
|
||||
if (file.import(data)) {
|
||||
// The artboard is the root of the animation and gets drawn in the
|
||||
// Rive widget.
|
||||
final artboard = file.mainArtboard;
|
||||
var controller =
|
||||
StateMachineController.fromArtboard(artboard, 'Button');
|
||||
if (controller != null) {
|
||||
artboard.addController(controller);
|
||||
_hoverInput = controller.findInput('Hover');
|
||||
_pressInput = controller.findInput('Press');
|
||||
}
|
||||
setState(() => _riveArtboard = artboard);
|
||||
final file = RiveFile.import(data);
|
||||
|
||||
// The artboard is the root of the animation and gets drawn in the
|
||||
// Rive widget.
|
||||
final artboard = file.mainArtboard;
|
||||
var controller =
|
||||
StateMachineController.fromArtboard(artboard, 'Button');
|
||||
if (controller != null) {
|
||||
artboard.addController(controller);
|
||||
_hoverInput = controller.findInput('Hover');
|
||||
_pressInput = controller.findInput('Press');
|
||||
}
|
||||
setState(() => _riveArtboard = artboard);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -1,22 +1,23 @@
|
||||
library rive;
|
||||
|
||||
export 'package:rive/src/rive_file.dart';
|
||||
export 'package:rive/src/rive.dart';
|
||||
export 'package:rive/src/runtime_artboard.dart';
|
||||
export 'package:rive/src/controllers/simple_controller.dart';
|
||||
export 'package:rive/src/rive_core/rive_animation_controller.dart';
|
||||
export 'package:rive/src/extensions.dart';
|
||||
export 'package:rive/src/extensions.dart';
|
||||
export 'package:rive/src/rive.dart';
|
||||
export 'package:rive/src/rive_core/animation/linear_animation.dart';
|
||||
export 'package:rive/src/rive_core/animation/linear_animation_instance.dart';
|
||||
export 'package:rive/src/rive_core/animation/loop.dart';
|
||||
export 'package:rive/src/rive_core/animation/state_machine.dart';
|
||||
export 'package:rive/src/rive_core/artboard.dart';
|
||||
export 'package:rive/src/rive_core/shapes/shape.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/fill.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/stroke.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/solid_color.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/radial_gradient.dart';
|
||||
export 'package:rive/src/rive_core/rive_animation_controller.dart';
|
||||
export 'package:rive/src/rive_core/runtime/runtime_header.dart'
|
||||
show riveVersion;
|
||||
export 'package:rive/src/extensions.dart';
|
||||
export 'package:rive/src/rive_core/animation/state_machine.dart';
|
||||
export 'package:rive/src/state_machine_controller.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/fill.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/linear_gradient.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/radial_gradient.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/solid_color.dart';
|
||||
export 'package:rive/src/rive_core/shapes/paint/stroke.dart';
|
||||
export 'package:rive/src/rive_core/shapes/shape.dart';
|
||||
export 'package:rive/src/rive_file.dart';
|
||||
export 'package:rive/src/runtime_artboard.dart';
|
||||
export 'package:rive/src/state_machine_controller.dart';
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:rive/src/extensions.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/rive_animation_controller.dart';
|
||||
@ -5,39 +6,33 @@ import 'package:rive/src/runtime_artboard.dart';
|
||||
|
||||
/// A simple [RiveAnimationController] that plays back a LinearAnimation defined
|
||||
/// by an artist. All playback parameters (looping, speed, keyframes) are artist
|
||||
/// defined in the Rive editor.
|
||||
/// defined in the Rive editor. This takes a declaritive approach of using an
|
||||
/// [animationName] as the only requirement for resolving the animation. When
|
||||
/// the controller is added to an artboard (note that due to widget lifecycles
|
||||
/// it could get re-initialized on another artboard later) it'll look for the
|
||||
/// animation. Not finding the animation is a condition this example deals with
|
||||
/// by simply nulling the [AnimationInstance] _instance which means it won't be
|
||||
/// applied during advance cycles. Another approach would be let this throw, but
|
||||
/// this one is a little more forgiving which can be desireable with files
|
||||
/// dynamically loaded (downloaded even) at runtime.
|
||||
class SimpleAnimation extends RiveAnimationController<RuntimeArtboard> {
|
||||
SimpleAnimation(this.animationName, {double mix})
|
||||
: _mix = mix?.clamp(0, 1)?.toDouble() ?? 1.0;
|
||||
LinearAnimationInstance? _instance;
|
||||
|
||||
LinearAnimationInstance _instance;
|
||||
final String animationName;
|
||||
bool _stopOnNextApply = false;
|
||||
double _mix;
|
||||
|
||||
// Controls the level of mix for the animation, clamped between 0 and 1
|
||||
double _mix;
|
||||
SimpleAnimation(this.animationName, {double mix = 1})
|
||||
: _mix = mix.clamp(0, 1).toDouble();
|
||||
LinearAnimationInstance? get instance => _instance;
|
||||
double get mix => _mix;
|
||||
set mix(double value) => _mix = value?.clamp(0, 1)?.toDouble() ?? 1;
|
||||
|
||||
LinearAnimationInstance get instance => _instance;
|
||||
|
||||
@override
|
||||
bool init(RuntimeArtboard artboard) {
|
||||
var animation = artboard.animations.firstWhere(
|
||||
(animation) =>
|
||||
animation is LinearAnimation && animation.name == animationName,
|
||||
orElse: () => null,
|
||||
);
|
||||
if (animation != null) {
|
||||
_instance = LinearAnimationInstance(animation as LinearAnimation);
|
||||
}
|
||||
isActive = true;
|
||||
return _instance != null;
|
||||
}
|
||||
set mix(double value) => _mix = value.clamp(0, 1).toDouble();
|
||||
|
||||
@override
|
||||
void apply(RuntimeArtboard artboard, double elapsedSeconds) {
|
||||
if (_stopOnNextApply) {
|
||||
if (_stopOnNextApply || _instance == null) {
|
||||
isActive = false;
|
||||
}
|
||||
|
||||
@ -47,12 +42,23 @@ class SimpleAnimation extends RiveAnimationController<RuntimeArtboard> {
|
||||
// stopping playback. We do this by tracking _stopOnNextApply making sure to
|
||||
// reset it when the controller is re-activated. Fixes #28 and should help
|
||||
// with issues #51 and #56.
|
||||
_instance.animation.apply(_instance.time, coreContext: artboard, mix: mix);
|
||||
if (!_instance.advance(elapsedSeconds)) {
|
||||
_instance!.animation
|
||||
.apply(_instance!.time, coreContext: artboard, mix: mix);
|
||||
if (!_instance!.advance(elapsedSeconds)) {
|
||||
_stopOnNextApply = true;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool init(RuntimeArtboard artboard) {
|
||||
var animation = artboard.animationByName(animationName);
|
||||
if (animation != null) {
|
||||
_instance = LinearAnimationInstance(animation as LinearAnimation);
|
||||
}
|
||||
isActive = true;
|
||||
return _instance != null;
|
||||
}
|
||||
|
||||
@override
|
||||
void onActivate() {
|
||||
// We override onActivate to reset stopOnNextApply. This ensures that when
|
||||
|
@ -1,5 +1,7 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:rive/src/rive_core/runtime/exceptions/rive_format_error_exception.dart';
|
||||
|
||||
export 'package:rive/src/animation_list.dart';
|
||||
export 'package:rive/src/state_machine_components.dart';
|
||||
export 'package:rive/src/state_transition_conditions.dart';
|
||||
@ -19,21 +21,35 @@ typedef PropertyChangeCallback = void Function(dynamic from, dynamic to);
|
||||
typedef BatchAddCallback = void Function();
|
||||
|
||||
abstract class Core<T extends CoreContext> {
|
||||
covariant T context;
|
||||
static const int missingId = -1;
|
||||
covariant late T context;
|
||||
int get coreType;
|
||||
int id;
|
||||
int id = missingId;
|
||||
Set<int> get coreTypes => {};
|
||||
bool _hasValidated = false;
|
||||
bool get hasValidated => _hasValidated;
|
||||
|
||||
void onAddedDirty();
|
||||
void onAdded();
|
||||
void onAdded() {}
|
||||
void onRemoved() {}
|
||||
void remove() => context?.removeObject(this);
|
||||
void remove() => context.removeObject(this);
|
||||
bool import(ImportStack stack) => true;
|
||||
|
||||
bool validate() => true;
|
||||
}
|
||||
|
||||
class InternalCoreHelper {
|
||||
static void markValid(Core object) {
|
||||
object._hasValidated = true;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CoreContext {
|
||||
Core makeCoreInstance(int typeKey);
|
||||
T resolve<T>(int id);
|
||||
static const int invalidPropertyKey = 0;
|
||||
|
||||
Core? makeCoreInstance(int typeKey);
|
||||
T? resolve<T>(int id);
|
||||
T resolveWithDefault<T>(int id, T defaultValue);
|
||||
void markDependencyOrderDirty();
|
||||
bool markDependenciesDirty(covariant Core rootObject);
|
||||
void removeObject<T extends Core>(T object);
|
||||
@ -51,7 +67,7 @@ abstract class ImportStackObject {
|
||||
/// certain type.
|
||||
class ImportStack {
|
||||
final _latests = HashMap<int, ImportStackObject>();
|
||||
T latest<T extends ImportStackObject>(int coreType) {
|
||||
T? latest<T extends ImportStackObject>(int coreType) {
|
||||
var latest = _latests[coreType];
|
||||
if (latest is T) {
|
||||
return latest;
|
||||
@ -59,7 +75,17 @@ class ImportStack {
|
||||
return null;
|
||||
}
|
||||
|
||||
bool makeLatest(int coreType, ImportStackObject importObject) {
|
||||
T requireLatest<T extends ImportStackObject>(int coreType) {
|
||||
var object = latest<T>(coreType);
|
||||
if (object == null) {
|
||||
throw RiveFormatErrorException(
|
||||
'Rive file is corrupt. Couldn\'t find expected object of type '
|
||||
'$coreType in import stack.');
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
bool makeLatest(int coreType, ImportStackObject? importObject) {
|
||||
var latest = _latests[coreType];
|
||||
if (latest != null) {
|
||||
if (!latest.resolve()) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
|
||||
|
||||
// ignore: one_member_abstracts
|
||||
abstract class CoreFieldType<T> {
|
||||
abstract class CoreFieldType<T extends Object> {
|
||||
T deserialize(BinaryReader reader);
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ class ArtboardImporter extends ImportStackObject {
|
||||
@override
|
||||
bool resolve() {
|
||||
for (final object in artboard.objects.skip(1)) {
|
||||
if (object is Component && object.parentId == null) {
|
||||
if (object is Component &&
|
||||
object.parentId == ComponentBase.parentIdInitialValue) {
|
||||
object.parent = artboard;
|
||||
}
|
||||
object?.onAddedDirty();
|
||||
|
@ -4,22 +4,22 @@ import 'package:rive/src/rive_core/animation/keyed_object.dart';
|
||||
|
||||
class LinearAnimationImporter extends ImportStackObject {
|
||||
final LinearAnimation linearAnimation;
|
||||
final keyedObjects = <KeyedObject>[];
|
||||
// final keyedObjects = <KeyedObject>[];
|
||||
|
||||
LinearAnimationImporter(this.linearAnimation);
|
||||
|
||||
void addKeyedObject(KeyedObject object) {
|
||||
linearAnimation.context.addObject(object);
|
||||
|
||||
keyedObjects.add(object);
|
||||
|
||||
// keyedObjects.add(object);
|
||||
linearAnimation.internalAddKeyedObject(object);
|
||||
}
|
||||
|
||||
@override
|
||||
bool resolve() {
|
||||
for (final keyedObject in keyedObjects) {
|
||||
keyedObject?.objectId ??= linearAnimation.artboard.id;
|
||||
}
|
||||
// for (final keyedObject in keyedObjects) {
|
||||
// keyedObject.objectId ??= linearAnimation.artboard.id;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,16 @@
|
||||
/// Extensions to the runtime core classes
|
||||
|
||||
import 'package:rive/src/rive_core/artboard.dart';
|
||||
import 'package:collection/collection.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/artboard.dart';
|
||||
|
||||
/// Artboard extensions
|
||||
extension ArtboardAdditions on Artboard {
|
||||
/// Returns an animation with the given name, or null if no animation with
|
||||
/// that name exists in the artboard
|
||||
LinearAnimationInstance animationByName(String name) {
|
||||
final animation = animations.firstWhere(
|
||||
(animation) => animation is LinearAnimation && animation.name == name,
|
||||
orElse: () => null,
|
||||
);
|
||||
LinearAnimationInstance? animationByName(String name) {
|
||||
final animation = animations.firstWhereOrNull(
|
||||
(animation) => animation is LinearAnimation && animation.name == name);
|
||||
if (animation != null) {
|
||||
return LinearAnimationInstance(animation as LinearAnimation);
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ abstract class AnimationBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Name field with key 55.
|
||||
String _name;
|
||||
static const String nameInitialValue = '';
|
||||
String _name = nameInitialValue;
|
||||
static const int namePropertyKey = 55;
|
||||
|
||||
/// Name of the animation.
|
||||
|
@ -19,7 +19,8 @@ abstract class AnimationStateBase extends LayerState {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// AnimationId field with key 149.
|
||||
int _animationId;
|
||||
static const int animationIdInitialValue = -1;
|
||||
int _animationId = animationIdInitialValue;
|
||||
static const int animationIdPropertyKey = 149;
|
||||
|
||||
/// Id of the animation this layer state refers to.
|
||||
|
@ -13,7 +13,8 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// X1 field with key 63.
|
||||
double _x1 = 0.42;
|
||||
static const double x1InitialValue = 0.42;
|
||||
double _x1 = x1InitialValue;
|
||||
static const int x1PropertyKey = 63;
|
||||
double get x1 => _x1;
|
||||
|
||||
@ -32,7 +33,8 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Y1 field with key 64.
|
||||
double _y1 = 0;
|
||||
static const double y1InitialValue = 0;
|
||||
double _y1 = y1InitialValue;
|
||||
static const int y1PropertyKey = 64;
|
||||
double get y1 => _y1;
|
||||
|
||||
@ -51,7 +53,8 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// X2 field with key 65.
|
||||
double _x2 = 0.58;
|
||||
static const double x2InitialValue = 0.58;
|
||||
double _x2 = x2InitialValue;
|
||||
static const int x2PropertyKey = 65;
|
||||
double get x2 => _x2;
|
||||
|
||||
@ -70,7 +73,8 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Y2 field with key 66.
|
||||
double _y2 = 1;
|
||||
static const double y2InitialValue = 1;
|
||||
double _y2 = y2InitialValue;
|
||||
static const int y2PropertyKey = 66;
|
||||
double get y2 => _y2;
|
||||
|
||||
|
@ -13,7 +13,8 @@ abstract class KeyedObjectBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// ObjectId field with key 51.
|
||||
int _objectId;
|
||||
static const int objectIdInitialValue = 0;
|
||||
int _objectId = objectIdInitialValue;
|
||||
static const int objectIdPropertyKey = 51;
|
||||
|
||||
/// Identifier used to track the object that is keyed.
|
||||
|
@ -13,7 +13,8 @@ abstract class KeyedPropertyBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// PropertyKey field with key 53.
|
||||
int _propertyKey;
|
||||
static const int propertyKeyInitialValue = CoreContext.invalidPropertyKey;
|
||||
int _propertyKey = propertyKeyInitialValue;
|
||||
static const int propertyKeyPropertyKey = 53;
|
||||
|
||||
/// The property type that is keyed.
|
||||
|
@ -12,7 +12,8 @@ abstract class KeyFrameBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Frame field with key 67.
|
||||
int _frame;
|
||||
static const int frameInitialValue = 0;
|
||||
int _frame = frameInitialValue;
|
||||
static const int framePropertyKey = 67;
|
||||
|
||||
/// Timecode as frame number can be converted to time by dividing by animation
|
||||
@ -34,7 +35,8 @@ abstract class KeyFrameBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InterpolationType field with key 68.
|
||||
int _interpolationType;
|
||||
static const int interpolationTypeInitialValue = 0;
|
||||
int _interpolationType = interpolationTypeInitialValue;
|
||||
static const int interpolationTypePropertyKey = 68;
|
||||
|
||||
/// The type of interpolation index in KeyframeInterpolation applied to this
|
||||
@ -57,7 +59,8 @@ abstract class KeyFrameBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InterpolatorId field with key 69.
|
||||
int _interpolatorId;
|
||||
static const int interpolatorIdInitialValue = -1;
|
||||
int _interpolatorId = interpolatorIdInitialValue;
|
||||
static const int interpolatorIdPropertyKey = 69;
|
||||
|
||||
/// The id of the custom interpolator used when interpolation is Cubic.
|
||||
|
@ -14,7 +14,8 @@ abstract class KeyFrameColorBase extends KeyFrame {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Value field with key 88.
|
||||
int _value;
|
||||
static const int valueInitialValue = 0;
|
||||
int _value = valueInitialValue;
|
||||
static const int valuePropertyKey = 88;
|
||||
int get value => _value;
|
||||
|
||||
|
@ -14,7 +14,8 @@ abstract class KeyFrameDoubleBase extends KeyFrame {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Value field with key 70.
|
||||
double _value;
|
||||
static const double valueInitialValue = 0;
|
||||
double _value = valueInitialValue;
|
||||
static const int valuePropertyKey = 70;
|
||||
double get value => _value;
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
/// Core automatically generated
|
||||
/// lib/src/generated/animation/keyframe_draw_order_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 KeyFrameDrawOrderBase extends KeyFrame {
|
||||
static const int typeKey = 32;
|
||||
@override
|
||||
int get coreType => KeyFrameDrawOrderBase.typeKey;
|
||||
@override
|
||||
Set<int> get coreTypes =>
|
||||
{KeyFrameDrawOrderBase.typeKey, KeyFrameBase.typeKey};
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/// Core automatically generated
|
||||
/// lib/src/generated/animation/keyframe_draw_order_value_base.dart.
|
||||
/// Do not modify manually.
|
||||
|
||||
import 'package:rive/src/core/core.dart';
|
||||
|
||||
abstract class KeyFrameDrawOrderValueBase<T extends CoreContext>
|
||||
extends Core<T> {
|
||||
static const int typeKey = 33;
|
||||
@override
|
||||
int get coreType => KeyFrameDrawOrderValueBase.typeKey;
|
||||
@override
|
||||
Set<int> get coreTypes => {KeyFrameDrawOrderValueBase.typeKey};
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// DrawableId field with key 77.
|
||||
int _drawableId;
|
||||
static const int drawableIdPropertyKey = 77;
|
||||
|
||||
/// The id of the Drawable this KeyFrameDrawOrderValue's value is for.
|
||||
int get drawableId => _drawableId;
|
||||
|
||||
/// Change the [_drawableId] field value.
|
||||
/// [drawableIdChanged] will be invoked only if the field's value has changed.
|
||||
set drawableId(int value) {
|
||||
if (_drawableId == value) {
|
||||
return;
|
||||
}
|
||||
int from = _drawableId;
|
||||
_drawableId = value;
|
||||
drawableIdChanged(from, value);
|
||||
}
|
||||
|
||||
void drawableIdChanged(int from, int to);
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Value field with key 78.
|
||||
int _value;
|
||||
static const int valuePropertyKey = 78;
|
||||
|
||||
/// The draw order value to apply to the Drawable.
|
||||
int get value => _value;
|
||||
|
||||
/// Change the [_value] field value.
|
||||
/// [valueChanged] will be invoked only if the field's value has changed.
|
||||
set value(int value) {
|
||||
if (_value == value) {
|
||||
return;
|
||||
}
|
||||
int from = _value;
|
||||
_value = value;
|
||||
valueChanged(from, value);
|
||||
}
|
||||
|
||||
void valueChanged(int from, int to);
|
||||
}
|
@ -14,7 +14,8 @@ abstract class KeyFrameIdBase extends KeyFrame {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Value field with key 122.
|
||||
int _value;
|
||||
static const int valueInitialValue = -1;
|
||||
int _value = valueInitialValue;
|
||||
static const int valuePropertyKey = 122;
|
||||
int get value => _value;
|
||||
|
||||
|
@ -15,7 +15,8 @@ abstract class LinearAnimationBase extends Animation {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Fps field with key 56.
|
||||
int _fps = 60;
|
||||
static const int fpsInitialValue = 60;
|
||||
int _fps = fpsInitialValue;
|
||||
static const int fpsPropertyKey = 56;
|
||||
|
||||
/// Frames per second used to quantize keyframe times to discrete values that
|
||||
@ -37,7 +38,8 @@ abstract class LinearAnimationBase extends Animation {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Duration field with key 57.
|
||||
int _duration = 60;
|
||||
static const int durationInitialValue = 60;
|
||||
int _duration = durationInitialValue;
|
||||
static const int durationPropertyKey = 57;
|
||||
|
||||
/// Duration expressed in number of frames.
|
||||
@ -58,7 +60,8 @@ abstract class LinearAnimationBase extends Animation {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Speed field with key 58.
|
||||
double _speed = 1;
|
||||
static const double speedInitialValue = 1;
|
||||
double _speed = speedInitialValue;
|
||||
static const int speedPropertyKey = 58;
|
||||
|
||||
/// Playback speed multiplier.
|
||||
@ -79,7 +82,8 @@ abstract class LinearAnimationBase extends Animation {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// LoopValue field with key 59.
|
||||
int _loopValue = 0;
|
||||
static const int loopValueInitialValue = 0;
|
||||
int _loopValue = loopValueInitialValue;
|
||||
static const int loopValuePropertyKey = 59;
|
||||
|
||||
/// Loop value option matches Loop enumeration.
|
||||
@ -100,7 +104,8 @@ abstract class LinearAnimationBase extends Animation {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// WorkStart field with key 60.
|
||||
int _workStart;
|
||||
static const int workStartInitialValue = -1;
|
||||
int _workStart = workStartInitialValue;
|
||||
static const int workStartPropertyKey = 60;
|
||||
|
||||
/// Start of the work area in frames.
|
||||
@ -121,7 +126,8 @@ abstract class LinearAnimationBase extends Animation {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// WorkEnd field with key 61.
|
||||
int _workEnd;
|
||||
static const int workEndInitialValue = -1;
|
||||
int _workEnd = workEndInitialValue;
|
||||
static const int workEndPropertyKey = 61;
|
||||
|
||||
/// End of the work area in frames.
|
||||
@ -142,7 +148,8 @@ abstract class LinearAnimationBase extends Animation {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// EnableWorkArea field with key 62.
|
||||
bool _enableWorkArea = false;
|
||||
static const bool enableWorkAreaInitialValue = false;
|
||||
bool _enableWorkArea = enableWorkAreaInitialValue;
|
||||
static const int enableWorkAreaPropertyKey = 62;
|
||||
|
||||
/// Whether or not the work area is enabled.
|
||||
|
@ -19,7 +19,8 @@ abstract class StateMachineBoolBase extends StateMachineInput {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Value field with key 141.
|
||||
bool _value = false;
|
||||
static const bool valueInitialValue = false;
|
||||
bool _value = valueInitialValue;
|
||||
static const int valuePropertyKey = 141;
|
||||
bool get value => _value;
|
||||
|
||||
|
@ -14,7 +14,8 @@ abstract class StateMachineComponentBase<T extends CoreContext>
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Name field with key 138.
|
||||
String _name;
|
||||
static const String nameInitialValue = '';
|
||||
String _name = nameInitialValue;
|
||||
static const int namePropertyKey = 138;
|
||||
|
||||
/// Non-unique identifier, used to give friendly names to state machine
|
||||
|
@ -19,7 +19,8 @@ abstract class StateMachineDoubleBase extends StateMachineInput {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Value field with key 140.
|
||||
double _value = 0;
|
||||
static const double valueInitialValue = 0;
|
||||
double _value = valueInitialValue;
|
||||
static const int valuePropertyKey = 140;
|
||||
double get value => _value;
|
||||
|
||||
|
@ -15,7 +15,8 @@ abstract class StateTransitionBase extends StateMachineLayerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// StateToId field with key 151.
|
||||
int _stateToId;
|
||||
static const int stateToIdInitialValue = -1;
|
||||
int _stateToId = stateToIdInitialValue;
|
||||
static const int stateToIdPropertyKey = 151;
|
||||
|
||||
/// Id of the state this transition originates from.
|
||||
@ -36,7 +37,8 @@ abstract class StateTransitionBase extends StateMachineLayerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Flags field with key 152.
|
||||
int _flags = 0;
|
||||
static const int flagsInitialValue = 0;
|
||||
int _flags = flagsInitialValue;
|
||||
static const int flagsPropertyKey = 152;
|
||||
int get flags => _flags;
|
||||
|
||||
@ -55,7 +57,8 @@ abstract class StateTransitionBase extends StateMachineLayerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Duration field with key 158.
|
||||
int _duration = 0;
|
||||
static const int durationInitialValue = 0;
|
||||
int _duration = durationInitialValue;
|
||||
static const int durationPropertyKey = 158;
|
||||
|
||||
/// Duration of the trasition (mix time) in milliseconds.
|
||||
|
@ -13,7 +13,8 @@ abstract class TransitionConditionBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InputId field with key 155.
|
||||
int _inputId;
|
||||
static const int inputIdInitialValue = -1;
|
||||
int _inputId = inputIdInitialValue;
|
||||
static const int inputIdPropertyKey = 155;
|
||||
|
||||
/// Id of the StateMachineInput referenced.
|
||||
|
@ -19,7 +19,8 @@ abstract class TransitionDoubleConditionBase extends TransitionValueCondition {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Value field with key 157.
|
||||
double _value = 0;
|
||||
static const double valueInitialValue = 0;
|
||||
double _value = valueInitialValue;
|
||||
static const int valuePropertyKey = 157;
|
||||
double get value => _value;
|
||||
|
||||
|
@ -15,7 +15,8 @@ abstract class TransitionValueConditionBase extends TransitionCondition {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OpValue field with key 156.
|
||||
int _opValue = 0;
|
||||
static const int opValueInitialValue = 0;
|
||||
int _opValue = opValueInitialValue;
|
||||
static const int opValuePropertyKey = 156;
|
||||
|
||||
/// Integer representation of the StateMachineOp enum.
|
||||
|
@ -18,7 +18,8 @@ abstract class ArtboardBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Width field with key 7.
|
||||
double _width;
|
||||
static const double widthInitialValue = 0;
|
||||
double _width = widthInitialValue;
|
||||
static const int widthPropertyKey = 7;
|
||||
|
||||
/// Width of the artboard.
|
||||
@ -39,7 +40,8 @@ abstract class ArtboardBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Height field with key 8.
|
||||
double _height;
|
||||
static const double heightInitialValue = 0;
|
||||
double _height = heightInitialValue;
|
||||
static const int heightPropertyKey = 8;
|
||||
|
||||
/// Height of the artboard.
|
||||
@ -60,7 +62,8 @@ abstract class ArtboardBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// X field with key 9.
|
||||
double _x;
|
||||
static const double xInitialValue = 0;
|
||||
double _x = xInitialValue;
|
||||
static const int xPropertyKey = 9;
|
||||
|
||||
/// X coordinate in editor world space.
|
||||
@ -81,7 +84,8 @@ abstract class ArtboardBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Y field with key 10.
|
||||
double _y;
|
||||
static const double yInitialValue = 0;
|
||||
double _y = yInitialValue;
|
||||
static const int yPropertyKey = 10;
|
||||
|
||||
/// Y coordinate in editor world space.
|
||||
@ -102,7 +106,8 @@ abstract class ArtboardBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OriginX field with key 11.
|
||||
double _originX;
|
||||
static const double originXInitialValue = 0;
|
||||
double _originX = originXInitialValue;
|
||||
static const int originXPropertyKey = 11;
|
||||
|
||||
/// Origin x in normalized coordinates (0.5 = center, 0 = left, 1 = right).
|
||||
@ -123,7 +128,8 @@ abstract class ArtboardBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OriginY field with key 12.
|
||||
double _originY;
|
||||
static const double originYInitialValue = 0;
|
||||
double _originY = originYInitialValue;
|
||||
static const int originYPropertyKey = 12;
|
||||
|
||||
/// Origin y in normalized coordinates (0.5 = center, 0 = top, 1 = bottom).
|
||||
|
@ -22,7 +22,8 @@ abstract class BoneBase extends SkeletalComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Length field with key 89.
|
||||
double _length = 0;
|
||||
static const double lengthInitialValue = 0;
|
||||
double _length = lengthInitialValue;
|
||||
static const int lengthPropertyKey = 89;
|
||||
double get length => _length;
|
||||
|
||||
|
@ -15,7 +15,8 @@ abstract class CubicWeightBase extends Weight {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InValues field with key 110.
|
||||
int _inValues = 255;
|
||||
static const int inValuesInitialValue = 255;
|
||||
int _inValues = inValuesInitialValue;
|
||||
static const int inValuesPropertyKey = 110;
|
||||
int get inValues => _inValues;
|
||||
|
||||
@ -34,7 +35,8 @@ abstract class CubicWeightBase extends Weight {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InIndices field with key 111.
|
||||
int _inIndices = 1;
|
||||
static const int inIndicesInitialValue = 1;
|
||||
int _inIndices = inIndicesInitialValue;
|
||||
static const int inIndicesPropertyKey = 111;
|
||||
int get inIndices => _inIndices;
|
||||
|
||||
@ -53,7 +55,8 @@ abstract class CubicWeightBase extends Weight {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OutValues field with key 112.
|
||||
int _outValues = 255;
|
||||
static const int outValuesInitialValue = 255;
|
||||
int _outValues = outValuesInitialValue;
|
||||
static const int outValuesPropertyKey = 112;
|
||||
int get outValues => _outValues;
|
||||
|
||||
@ -72,7 +75,8 @@ abstract class CubicWeightBase extends Weight {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OutIndices field with key 113.
|
||||
int _outIndices = 1;
|
||||
static const int outIndicesInitialValue = 1;
|
||||
int _outIndices = outIndicesInitialValue;
|
||||
static const int outIndicesPropertyKey = 113;
|
||||
int get outIndices => _outIndices;
|
||||
|
||||
|
@ -24,7 +24,8 @@ abstract class RootBoneBase extends Bone {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// X field with key 90.
|
||||
double _x = 0;
|
||||
static const double xInitialValue = 0;
|
||||
double _x = xInitialValue;
|
||||
static const int xPropertyKey = 90;
|
||||
@override
|
||||
double get x => _x;
|
||||
@ -45,7 +46,8 @@ abstract class RootBoneBase extends Bone {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Y field with key 91.
|
||||
double _y = 0;
|
||||
static const double yInitialValue = 0;
|
||||
double _y = yInitialValue;
|
||||
static const int yPropertyKey = 91;
|
||||
@override
|
||||
double get y => _y;
|
||||
|
@ -15,7 +15,8 @@ abstract class SkinBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Xx field with key 104.
|
||||
double _xx = 1;
|
||||
static const double xxInitialValue = 1;
|
||||
double _xx = xxInitialValue;
|
||||
static const int xxPropertyKey = 104;
|
||||
|
||||
/// x component of x unit vector in the bind transform
|
||||
@ -36,7 +37,8 @@ abstract class SkinBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Yx field with key 105.
|
||||
double _yx = 0;
|
||||
static const double yxInitialValue = 0;
|
||||
double _yx = yxInitialValue;
|
||||
static const int yxPropertyKey = 105;
|
||||
|
||||
/// y component of x unit vector in the bind transform
|
||||
@ -57,7 +59,8 @@ abstract class SkinBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Xy field with key 106.
|
||||
double _xy = 0;
|
||||
static const double xyInitialValue = 0;
|
||||
double _xy = xyInitialValue;
|
||||
static const int xyPropertyKey = 106;
|
||||
|
||||
/// x component of y unit vector in the bind transform
|
||||
@ -78,7 +81,8 @@ abstract class SkinBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Yy field with key 107.
|
||||
double _yy = 1;
|
||||
static const double yyInitialValue = 1;
|
||||
double _yy = yyInitialValue;
|
||||
static const int yyPropertyKey = 107;
|
||||
|
||||
/// y component of y unit vector in the bind transform
|
||||
@ -99,7 +103,8 @@ abstract class SkinBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Tx field with key 108.
|
||||
double _tx = 0;
|
||||
static const double txInitialValue = 0;
|
||||
double _tx = txInitialValue;
|
||||
static const int txPropertyKey = 108;
|
||||
|
||||
/// x position component of the bind transform
|
||||
@ -120,7 +125,8 @@ abstract class SkinBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Ty field with key 109.
|
||||
double _ty = 0;
|
||||
static const double tyInitialValue = 0;
|
||||
double _ty = tyInitialValue;
|
||||
static const int tyPropertyKey = 109;
|
||||
|
||||
/// y position component of the bind transform
|
||||
|
@ -13,7 +13,8 @@ abstract class TendonBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// BoneId field with key 95.
|
||||
int _boneId;
|
||||
static const int boneIdInitialValue = -1;
|
||||
int _boneId = boneIdInitialValue;
|
||||
static const int boneIdPropertyKey = 95;
|
||||
|
||||
/// Identifier used to track the bone this tendon connects to.
|
||||
@ -34,7 +35,8 @@ abstract class TendonBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Xx field with key 96.
|
||||
double _xx = 1;
|
||||
static const double xxInitialValue = 1;
|
||||
double _xx = xxInitialValue;
|
||||
static const int xxPropertyKey = 96;
|
||||
|
||||
/// x component of x unit vector in the bind transform
|
||||
@ -55,7 +57,8 @@ abstract class TendonBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Yx field with key 97.
|
||||
double _yx = 0;
|
||||
static const double yxInitialValue = 0;
|
||||
double _yx = yxInitialValue;
|
||||
static const int yxPropertyKey = 97;
|
||||
|
||||
/// y component of x unit vector in the bind transform
|
||||
@ -76,7 +79,8 @@ abstract class TendonBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Xy field with key 98.
|
||||
double _xy = 0;
|
||||
static const double xyInitialValue = 0;
|
||||
double _xy = xyInitialValue;
|
||||
static const int xyPropertyKey = 98;
|
||||
|
||||
/// x component of y unit vector in the bind transform
|
||||
@ -97,7 +101,8 @@ abstract class TendonBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Yy field with key 99.
|
||||
double _yy = 1;
|
||||
static const double yyInitialValue = 1;
|
||||
double _yy = yyInitialValue;
|
||||
static const int yyPropertyKey = 99;
|
||||
|
||||
/// y component of y unit vector in the bind transform
|
||||
@ -118,7 +123,8 @@ abstract class TendonBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Tx field with key 100.
|
||||
double _tx = 0;
|
||||
static const double txInitialValue = 0;
|
||||
double _tx = txInitialValue;
|
||||
static const int txPropertyKey = 100;
|
||||
|
||||
/// x position component of the bind transform
|
||||
@ -139,7 +145,8 @@ abstract class TendonBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Ty field with key 101.
|
||||
double _ty = 0;
|
||||
static const double tyInitialValue = 0;
|
||||
double _ty = tyInitialValue;
|
||||
static const int tyPropertyKey = 101;
|
||||
|
||||
/// y position component of the bind transform
|
||||
|
@ -13,7 +13,8 @@ abstract class WeightBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Values field with key 102.
|
||||
int _values = 255;
|
||||
static const int valuesInitialValue = 255;
|
||||
int _values = valuesInitialValue;
|
||||
static const int valuesPropertyKey = 102;
|
||||
int get values => _values;
|
||||
|
||||
@ -32,7 +33,8 @@ abstract class WeightBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Indices field with key 103.
|
||||
int _indices = 1;
|
||||
static const int indicesInitialValue = 1;
|
||||
int _indices = indicesInitialValue;
|
||||
static const int indicesPropertyKey = 103;
|
||||
int get indices => _indices;
|
||||
|
||||
|
@ -12,7 +12,8 @@ abstract class ComponentBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Name field with key 4.
|
||||
String _name;
|
||||
static const String nameInitialValue = '';
|
||||
String _name = nameInitialValue;
|
||||
static const int namePropertyKey = 4;
|
||||
|
||||
/// Non-unique identifier, used to give friendly names to elements in the
|
||||
@ -34,7 +35,8 @@ abstract class ComponentBase<T extends CoreContext> extends Core<T> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// ParentId field with key 5.
|
||||
int _parentId;
|
||||
static const int parentIdInitialValue = 0;
|
||||
int _parentId = parentIdInitialValue;
|
||||
static const int parentIdPropertyKey = 5;
|
||||
|
||||
/// Identifier used to track parent ContainerComponent.
|
||||
|
@ -18,7 +18,8 @@ abstract class DrawRulesBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// DrawTargetId field with key 121.
|
||||
int _drawTargetId;
|
||||
static const int drawTargetIdInitialValue = -1;
|
||||
int _drawTargetId = drawTargetIdInitialValue;
|
||||
static const int drawTargetIdPropertyKey = 121;
|
||||
|
||||
/// Id of the DrawTarget that is currently active for this set of rules.
|
||||
|
@ -13,7 +13,8 @@ abstract class DrawTargetBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// DrawableId field with key 119.
|
||||
int _drawableId;
|
||||
static const int drawableIdInitialValue = -1;
|
||||
int _drawableId = drawableIdInitialValue;
|
||||
static const int drawableIdPropertyKey = 119;
|
||||
|
||||
/// Id of the drawable this target references.
|
||||
@ -34,7 +35,8 @@ abstract class DrawTargetBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// PlacementValue field with key 120.
|
||||
int _placementValue = 0;
|
||||
static const int placementValueInitialValue = 0;
|
||||
int _placementValue = placementValueInitialValue;
|
||||
static const int placementValuePropertyKey = 120;
|
||||
|
||||
/// Backing enum value for the Placement.
|
||||
|
@ -22,7 +22,8 @@ abstract class DrawableBase extends Node {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// BlendModeValue field with key 23.
|
||||
int _blendModeValue = 3;
|
||||
static const int blendModeValueInitialValue = 3;
|
||||
int _blendModeValue = blendModeValueInitialValue;
|
||||
static const int blendModeValuePropertyKey = 23;
|
||||
int get blendModeValue => _blendModeValue;
|
||||
|
||||
@ -42,7 +43,8 @@ abstract class DrawableBase extends Node {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// DrawableFlags field with key 129.
|
||||
int _drawableFlags = 0;
|
||||
static const int drawableFlagsInitialValue = 0;
|
||||
int _drawableFlags = drawableFlagsInitialValue;
|
||||
static const int drawableFlagsPropertyKey = 129;
|
||||
int get drawableFlags => _drawableFlags;
|
||||
|
||||
|
@ -20,7 +20,8 @@ abstract class NodeBase extends TransformComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// X field with key 13.
|
||||
double _x = 0;
|
||||
static const double xInitialValue = 0;
|
||||
double _x = xInitialValue;
|
||||
static const int xPropertyKey = 13;
|
||||
@override
|
||||
double get x => _x;
|
||||
@ -41,7 +42,8 @@ abstract class NodeBase extends TransformComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Y field with key 14.
|
||||
double _y = 0;
|
||||
static const double yInitialValue = 0;
|
||||
double _y = yInitialValue;
|
||||
static const int yPropertyKey = 14;
|
||||
@override
|
||||
double get y => _y;
|
||||
|
@ -123,7 +123,7 @@ import 'package:rive/src/rive_core/shapes/triangle.dart';
|
||||
|
||||
// ignore: avoid_classes_with_only_static_members
|
||||
class RiveCoreContext {
|
||||
static Core makeCoreInstance(int typeKey) {
|
||||
static Core? makeCoreInstance(int typeKey) {
|
||||
switch (typeKey) {
|
||||
case DrawTargetBase.typeKey:
|
||||
return DrawTarget();
|
||||
@ -237,12 +237,8 @@ class RiveCoreContext {
|
||||
static void setObjectProperty(Core object, int propertyKey, Object value) {
|
||||
switch (propertyKey) {
|
||||
case ComponentBase.namePropertyKey:
|
||||
if (object is ComponentBase) {
|
||||
if (value is String) {
|
||||
object.name = value;
|
||||
} else if (value == null) {
|
||||
object.name = null;
|
||||
}
|
||||
if (object is ComponentBase && value is String) {
|
||||
object.name = value;
|
||||
}
|
||||
break;
|
||||
case ComponentBase.parentIdPropertyKey:
|
||||
@ -251,12 +247,8 @@ class RiveCoreContext {
|
||||
}
|
||||
break;
|
||||
case DrawTargetBase.drawableIdPropertyKey:
|
||||
if (object is DrawTargetBase) {
|
||||
if (value is int) {
|
||||
object.drawableId = value;
|
||||
} else if (value == null) {
|
||||
object.drawableId = null;
|
||||
}
|
||||
if (object is DrawTargetBase && value is int) {
|
||||
object.drawableId = value;
|
||||
}
|
||||
break;
|
||||
case DrawTargetBase.placementValuePropertyKey:
|
||||
@ -265,12 +257,8 @@ class RiveCoreContext {
|
||||
}
|
||||
break;
|
||||
case AnimationStateBase.animationIdPropertyKey:
|
||||
if (object is AnimationStateBase) {
|
||||
if (value is int) {
|
||||
object.animationId = value;
|
||||
} else if (value == null) {
|
||||
object.animationId = null;
|
||||
}
|
||||
if (object is AnimationStateBase && value is int) {
|
||||
object.animationId = value;
|
||||
}
|
||||
break;
|
||||
case KeyedObjectBase.objectIdPropertyKey:
|
||||
@ -279,21 +267,13 @@ class RiveCoreContext {
|
||||
}
|
||||
break;
|
||||
case TransitionConditionBase.inputIdPropertyKey:
|
||||
if (object is TransitionConditionBase) {
|
||||
if (value is int) {
|
||||
object.inputId = value;
|
||||
} else if (value == null) {
|
||||
object.inputId = null;
|
||||
}
|
||||
if (object is TransitionConditionBase && value is int) {
|
||||
object.inputId = value;
|
||||
}
|
||||
break;
|
||||
case StateMachineComponentBase.namePropertyKey:
|
||||
if (object is StateMachineComponentBase) {
|
||||
if (value is String) {
|
||||
object.name = value;
|
||||
} else if (value == null) {
|
||||
object.name = null;
|
||||
}
|
||||
if (object is StateMachineComponentBase && value is String) {
|
||||
object.name = value;
|
||||
}
|
||||
break;
|
||||
case KeyedPropertyBase.propertyKeyPropertyKey:
|
||||
@ -317,12 +297,8 @@ class RiveCoreContext {
|
||||
}
|
||||
break;
|
||||
case KeyFrameBase.interpolatorIdPropertyKey:
|
||||
if (object is KeyFrameBase) {
|
||||
if (value is int) {
|
||||
object.interpolatorId = value;
|
||||
} else if (value == null) {
|
||||
object.interpolatorId = null;
|
||||
}
|
||||
if (object is KeyFrameBase && value is int) {
|
||||
object.interpolatorId = value;
|
||||
}
|
||||
break;
|
||||
case KeyFrameIdBase.valuePropertyKey:
|
||||
@ -838,7 +814,7 @@ class RiveCoreContext {
|
||||
static CoreFieldType doubleType = CoreDoubleType();
|
||||
static CoreFieldType colorType = CoreColorType();
|
||||
static CoreFieldType boolType = CoreBoolType();
|
||||
static CoreFieldType coreType(int propertyKey) {
|
||||
static CoreFieldType? coreType(int propertyKey) {
|
||||
switch (propertyKey) {
|
||||
case ComponentBase.namePropertyKey:
|
||||
case StateMachineComponentBase.namePropertyKey:
|
||||
@ -973,7 +949,7 @@ class RiveCoreContext {
|
||||
case AnimationBase.namePropertyKey:
|
||||
return (object as AnimationBase).name;
|
||||
}
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
static int getUint(Core object, int propertyKey) {
|
||||
|
@ -14,7 +14,8 @@ abstract class ClippingShapeBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// SourceId field with key 92.
|
||||
int _sourceId;
|
||||
static const int sourceIdInitialValue = -1;
|
||||
int _sourceId = sourceIdInitialValue;
|
||||
static const int sourceIdPropertyKey = 92;
|
||||
|
||||
/// Identifier used to track the node to use as a clipping source.
|
||||
@ -35,7 +36,8 @@ abstract class ClippingShapeBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// FillRule field with key 93.
|
||||
int _fillRule = 0;
|
||||
static const int fillRuleInitialValue = 0;
|
||||
int _fillRule = fillRuleInitialValue;
|
||||
static const int fillRulePropertyKey = 93;
|
||||
|
||||
/// Backing enum value for the clipping fill rule (nonZero or evenOdd).
|
||||
@ -56,7 +58,8 @@ abstract class ClippingShapeBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// IsVisible field with key 94.
|
||||
bool _isVisible = true;
|
||||
static const bool isVisibleInitialValue = true;
|
||||
bool _isVisible = isVisibleInitialValue;
|
||||
static const int isVisiblePropertyKey = 94;
|
||||
bool get isVisible => _isVisible;
|
||||
|
||||
|
@ -23,7 +23,8 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Rotation field with key 79.
|
||||
double _rotation = 0;
|
||||
static const double rotationInitialValue = 0;
|
||||
double _rotation = rotationInitialValue;
|
||||
static const int rotationPropertyKey = 79;
|
||||
|
||||
/// The control points' angle.
|
||||
@ -44,7 +45,8 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InDistance field with key 80.
|
||||
double _inDistance = 0;
|
||||
static const double inDistanceInitialValue = 0;
|
||||
double _inDistance = inDistanceInitialValue;
|
||||
static const int inDistancePropertyKey = 80;
|
||||
|
||||
/// The in point's distance from the translation of the point.
|
||||
@ -65,7 +67,8 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OutDistance field with key 81.
|
||||
double _outDistance = 0;
|
||||
static const double outDistanceInitialValue = 0;
|
||||
double _outDistance = outDistanceInitialValue;
|
||||
static const int outDistancePropertyKey = 81;
|
||||
|
||||
/// The out point's distance from the translation of the point.
|
||||
|
@ -23,7 +23,8 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InRotation field with key 84.
|
||||
double _inRotation = 0;
|
||||
static const double inRotationInitialValue = 0;
|
||||
double _inRotation = inRotationInitialValue;
|
||||
static const int inRotationPropertyKey = 84;
|
||||
|
||||
/// The in point's angle.
|
||||
@ -44,7 +45,8 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InDistance field with key 85.
|
||||
double _inDistance = 0;
|
||||
static const double inDistanceInitialValue = 0;
|
||||
double _inDistance = inDistanceInitialValue;
|
||||
static const int inDistancePropertyKey = 85;
|
||||
|
||||
/// The in point's distance from the translation of the point.
|
||||
@ -65,7 +67,8 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OutRotation field with key 86.
|
||||
double _outRotation = 0;
|
||||
static const double outRotationInitialValue = 0;
|
||||
double _outRotation = outRotationInitialValue;
|
||||
static const int outRotationPropertyKey = 86;
|
||||
|
||||
/// The out point's angle.
|
||||
@ -87,7 +90,8 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OutDistance field with key 87.
|
||||
double _outDistance = 0;
|
||||
static const double outDistanceInitialValue = 0;
|
||||
double _outDistance = outDistanceInitialValue;
|
||||
static const int outDistancePropertyKey = 87;
|
||||
|
||||
/// The out point's distance from the translation of the point.
|
||||
|
@ -23,7 +23,8 @@ abstract class CubicMirroredVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Rotation field with key 82.
|
||||
double _rotation = 0;
|
||||
static const double rotationInitialValue = 0;
|
||||
double _rotation = rotationInitialValue;
|
||||
static const int rotationPropertyKey = 82;
|
||||
|
||||
/// The control points' angle.
|
||||
@ -44,7 +45,8 @@ abstract class CubicMirroredVertexBase extends CubicVertex {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Distance field with key 83.
|
||||
double _distance = 0;
|
||||
static const double distanceInitialValue = 0;
|
||||
double _distance = distanceInitialValue;
|
||||
static const int distancePropertyKey = 83;
|
||||
|
||||
/// The control points' distance from the translation of the point.
|
||||
|
@ -20,7 +20,8 @@ abstract class FillBase extends ShapePaint {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// FillRule field with key 40.
|
||||
int _fillRule = 0;
|
||||
static const int fillRuleInitialValue = 0;
|
||||
int _fillRule = fillRuleInitialValue;
|
||||
static const int fillRulePropertyKey = 40;
|
||||
int get fillRule => _fillRule;
|
||||
|
||||
|
@ -14,7 +14,8 @@ abstract class GradientStopBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// ColorValue field with key 38.
|
||||
int _colorValue = 0xFFFFFFFF;
|
||||
static const int colorValueInitialValue = 0xFFFFFFFF;
|
||||
int _colorValue = colorValueInitialValue;
|
||||
static const int colorValuePropertyKey = 38;
|
||||
int get colorValue => _colorValue;
|
||||
|
||||
@ -33,7 +34,8 @@ abstract class GradientStopBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Position field with key 39.
|
||||
double _position = 0;
|
||||
static const double positionInitialValue = 0;
|
||||
double _position = positionInitialValue;
|
||||
static const int positionPropertyKey = 39;
|
||||
double get position => _position;
|
||||
|
||||
|
@ -19,7 +19,8 @@ abstract class LinearGradientBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// StartX field with key 42.
|
||||
double _startX = 0;
|
||||
static const double startXInitialValue = 0;
|
||||
double _startX = startXInitialValue;
|
||||
static const int startXPropertyKey = 42;
|
||||
double get startX => _startX;
|
||||
|
||||
@ -38,7 +39,8 @@ abstract class LinearGradientBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// StartY field with key 33.
|
||||
double _startY = 0;
|
||||
static const double startYInitialValue = 0;
|
||||
double _startY = startYInitialValue;
|
||||
static const int startYPropertyKey = 33;
|
||||
double get startY => _startY;
|
||||
|
||||
@ -57,7 +59,8 @@ abstract class LinearGradientBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// EndX field with key 34.
|
||||
double _endX = 0;
|
||||
static const double endXInitialValue = 0;
|
||||
double _endX = endXInitialValue;
|
||||
static const int endXPropertyKey = 34;
|
||||
double get endX => _endX;
|
||||
|
||||
@ -76,7 +79,8 @@ abstract class LinearGradientBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// EndY field with key 35.
|
||||
double _endY = 0;
|
||||
static const double endYInitialValue = 0;
|
||||
double _endY = endYInitialValue;
|
||||
static const int endYPropertyKey = 35;
|
||||
double get endY => _endY;
|
||||
|
||||
@ -95,7 +99,8 @@ abstract class LinearGradientBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Opacity field with key 46.
|
||||
double _opacity = 1;
|
||||
static const double opacityInitialValue = 1;
|
||||
double _opacity = opacityInitialValue;
|
||||
static const int opacityPropertyKey = 46;
|
||||
double get opacity => _opacity;
|
||||
|
||||
|
@ -19,7 +19,8 @@ abstract class ShapePaintBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// IsVisible field with key 41.
|
||||
bool _isVisible = true;
|
||||
static const bool isVisibleInitialValue = true;
|
||||
bool _isVisible = isVisibleInitialValue;
|
||||
static const int isVisiblePropertyKey = 41;
|
||||
bool get isVisible => _isVisible;
|
||||
|
||||
|
@ -14,7 +14,8 @@ abstract class SolidColorBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// ColorValue field with key 37.
|
||||
int _colorValue = 0xFF747474;
|
||||
static const int colorValueInitialValue = 0xFF747474;
|
||||
int _colorValue = colorValueInitialValue;
|
||||
static const int colorValuePropertyKey = 37;
|
||||
int get colorValue => _colorValue;
|
||||
|
||||
|
@ -21,7 +21,8 @@ abstract class StrokeBase extends ShapePaint {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Thickness field with key 47.
|
||||
double _thickness = 1;
|
||||
static const double thicknessInitialValue = 1;
|
||||
double _thickness = thicknessInitialValue;
|
||||
static const int thicknessPropertyKey = 47;
|
||||
double get thickness => _thickness;
|
||||
|
||||
@ -40,7 +41,8 @@ abstract class StrokeBase extends ShapePaint {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Cap field with key 48.
|
||||
int _cap = 0;
|
||||
static const int capInitialValue = 0;
|
||||
int _cap = capInitialValue;
|
||||
static const int capPropertyKey = 48;
|
||||
int get cap => _cap;
|
||||
|
||||
@ -59,7 +61,8 @@ abstract class StrokeBase extends ShapePaint {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Join field with key 49.
|
||||
int _join = 0;
|
||||
static const int joinInitialValue = 0;
|
||||
int _join = joinInitialValue;
|
||||
static const int joinPropertyKey = 49;
|
||||
int get join => _join;
|
||||
|
||||
@ -78,7 +81,8 @@ abstract class StrokeBase extends ShapePaint {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// TransformAffectsStroke field with key 50.
|
||||
bool _transformAffectsStroke = true;
|
||||
static const bool transformAffectsStrokeInitialValue = true;
|
||||
bool _transformAffectsStroke = transformAffectsStrokeInitialValue;
|
||||
static const int transformAffectsStrokePropertyKey = 50;
|
||||
bool get transformAffectsStroke => _transformAffectsStroke;
|
||||
|
||||
|
@ -14,7 +14,8 @@ abstract class TrimPathBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Start field with key 114.
|
||||
double _start = 0;
|
||||
static const double startInitialValue = 0;
|
||||
double _start = startInitialValue;
|
||||
static const int startPropertyKey = 114;
|
||||
double get start => _start;
|
||||
|
||||
@ -33,7 +34,8 @@ abstract class TrimPathBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// End field with key 115.
|
||||
double _end = 0;
|
||||
static const double endInitialValue = 0;
|
||||
double _end = endInitialValue;
|
||||
static const int endPropertyKey = 115;
|
||||
double get end => _end;
|
||||
|
||||
@ -52,7 +54,8 @@ abstract class TrimPathBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Offset field with key 116.
|
||||
double _offset = 0;
|
||||
static const double offsetInitialValue = 0;
|
||||
double _offset = offsetInitialValue;
|
||||
static const int offsetPropertyKey = 116;
|
||||
double get offset => _offset;
|
||||
|
||||
@ -71,7 +74,8 @@ abstract class TrimPathBase extends Component {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// ModeValue field with key 117.
|
||||
int _modeValue = 0;
|
||||
static const int modeValueInitialValue = 0;
|
||||
int _modeValue = modeValueInitialValue;
|
||||
static const int modeValuePropertyKey = 117;
|
||||
int get modeValue => _modeValue;
|
||||
|
||||
|
@ -25,7 +25,8 @@ abstract class ParametricPathBase extends Path {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Width field with key 20.
|
||||
double _width = 0;
|
||||
static const double widthInitialValue = 0;
|
||||
double _width = widthInitialValue;
|
||||
static const int widthPropertyKey = 20;
|
||||
|
||||
/// Width of the parametric path.
|
||||
@ -46,7 +47,8 @@ abstract class ParametricPathBase extends Path {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Height field with key 21.
|
||||
double _height = 0;
|
||||
static const double heightInitialValue = 0;
|
||||
double _height = heightInitialValue;
|
||||
static const int heightPropertyKey = 21;
|
||||
|
||||
/// Height of the parametric path.
|
||||
@ -67,7 +69,8 @@ abstract class ParametricPathBase extends Path {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OriginX field with key 123.
|
||||
double _originX = 0.5;
|
||||
static const double originXInitialValue = 0.5;
|
||||
double _originX = originXInitialValue;
|
||||
static const int originXPropertyKey = 123;
|
||||
|
||||
/// Origin x in normalized coordinates (0.5 = center, 0 = left, 1 = right).
|
||||
@ -88,7 +91,8 @@ abstract class ParametricPathBase extends Path {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// OriginY field with key 124.
|
||||
double _originY = 0.5;
|
||||
static const double originYInitialValue = 0.5;
|
||||
double _originY = originYInitialValue;
|
||||
static const int originYPropertyKey = 124;
|
||||
|
||||
/// Origin y in normalized coordinates (0.5 = center, 0 = top, 1 = bottom).
|
||||
|
@ -22,7 +22,8 @@ abstract class PathBase extends Node {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// PathFlags field with key 128.
|
||||
int _pathFlags = 0;
|
||||
static const int pathFlagsInitialValue = 0;
|
||||
int _pathFlags = pathFlagsInitialValue;
|
||||
static const int pathFlagsPropertyKey = 128;
|
||||
int get pathFlags => _pathFlags;
|
||||
|
||||
|
@ -18,7 +18,8 @@ abstract class PathVertexBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// X field with key 24.
|
||||
double _x;
|
||||
static const double xInitialValue = 0;
|
||||
double _x = xInitialValue;
|
||||
static const int xPropertyKey = 24;
|
||||
|
||||
/// X value for the translation of the vertex.
|
||||
@ -39,7 +40,8 @@ abstract class PathVertexBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Y field with key 25.
|
||||
double _y;
|
||||
static const double yInitialValue = 0;
|
||||
double _y = yInitialValue;
|
||||
static const int yPropertyKey = 25;
|
||||
|
||||
/// Y value for the translation of the vertex.
|
||||
|
@ -24,7 +24,8 @@ abstract class PointsPathBase extends Path {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// IsClosed field with key 32.
|
||||
bool _isClosed;
|
||||
static const bool isClosedInitialValue = false;
|
||||
bool _isClosed = isClosedInitialValue;
|
||||
static const int isClosedPropertyKey = 32;
|
||||
|
||||
/// If the path should close back on its first vertex.
|
||||
|
@ -26,7 +26,8 @@ abstract class PolygonBase extends ParametricPath {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Points field with key 125.
|
||||
int _points = 5;
|
||||
static const int pointsInitialValue = 5;
|
||||
int _points = pointsInitialValue;
|
||||
static const int pointsPropertyKey = 125;
|
||||
|
||||
/// The number of points for the polygon.
|
||||
@ -47,7 +48,8 @@ abstract class PolygonBase extends ParametricPath {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// CornerRadius field with key 126.
|
||||
double _cornerRadius = 0;
|
||||
static const double cornerRadiusInitialValue = 0;
|
||||
double _cornerRadius = cornerRadiusInitialValue;
|
||||
static const int cornerRadiusPropertyKey = 126;
|
||||
|
||||
/// The corner radius.
|
||||
|
@ -26,7 +26,8 @@ abstract class RectangleBase extends ParametricPath {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// CornerRadius field with key 31.
|
||||
double _cornerRadius = 0;
|
||||
static const double cornerRadiusInitialValue = 0;
|
||||
double _cornerRadius = cornerRadiusInitialValue;
|
||||
static const int cornerRadiusPropertyKey = 31;
|
||||
|
||||
/// Radius of the corners of this rectangle
|
||||
|
@ -28,7 +28,8 @@ abstract class StarBase extends Polygon {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// InnerRadius field with key 127.
|
||||
double _innerRadius = 0.5;
|
||||
static const double innerRadiusInitialValue = 0.5;
|
||||
double _innerRadius = innerRadiusInitialValue;
|
||||
static const int innerRadiusPropertyKey = 127;
|
||||
|
||||
/// Percentage of width/height to project inner points of the star.
|
||||
|
@ -22,7 +22,8 @@ abstract class StraightVertexBase extends PathVertex<Weight> {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Radius field with key 26.
|
||||
double _radius = 0;
|
||||
static const double radiusInitialValue = 0;
|
||||
double _radius = radiusInitialValue;
|
||||
static const int radiusPropertyKey = 26;
|
||||
|
||||
/// Radius of the vertex
|
||||
|
@ -19,7 +19,8 @@ abstract class TransformComponentBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Rotation field with key 15.
|
||||
double _rotation = 0;
|
||||
static const double rotationInitialValue = 0;
|
||||
double _rotation = rotationInitialValue;
|
||||
static const int rotationPropertyKey = 15;
|
||||
double get rotation => _rotation;
|
||||
|
||||
@ -38,7 +39,8 @@ abstract class TransformComponentBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// ScaleX field with key 16.
|
||||
double _scaleX = 1;
|
||||
static const double scaleXInitialValue = 1;
|
||||
double _scaleX = scaleXInitialValue;
|
||||
static const int scaleXPropertyKey = 16;
|
||||
double get scaleX => _scaleX;
|
||||
|
||||
@ -57,7 +59,8 @@ abstract class TransformComponentBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// ScaleY field with key 17.
|
||||
double _scaleY = 1;
|
||||
static const double scaleYInitialValue = 1;
|
||||
double _scaleY = scaleYInitialValue;
|
||||
static const int scaleYPropertyKey = 17;
|
||||
double get scaleY => _scaleY;
|
||||
|
||||
@ -76,7 +79,8 @@ abstract class TransformComponentBase extends ContainerComponent {
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// Opacity field with key 18.
|
||||
double _opacity = 1;
|
||||
static const double opacityInitialValue = 1;
|
||||
double _opacity = opacityInitialValue;
|
||||
static const int opacityPropertyKey = 18;
|
||||
double get opacity => _opacity;
|
||||
|
||||
|
@ -31,16 +31,11 @@ class Rive extends LeafRenderObjectWidget {
|
||||
final Alignment alignment;
|
||||
|
||||
const Rive({
|
||||
@required
|
||||
this.artboard,
|
||||
@Deprecated("Replaced by [useArtboardSize] in order to avoid confusion "
|
||||
"with Flutter's intrinsics contract.")
|
||||
bool useIntrinsicSize,
|
||||
bool useArtboardSize = false,
|
||||
required this.artboard,
|
||||
this.useArtboardSize = false,
|
||||
this.fit = BoxFit.contain,
|
||||
this.alignment = Alignment.center,
|
||||
}) : assert(useArtboardSize != null),
|
||||
useArtboardSize = useIntrinsicSize ?? useArtboardSize;
|
||||
});
|
||||
|
||||
@override
|
||||
RenderObject createRenderObject(BuildContext context) {
|
||||
@ -48,8 +43,7 @@ class Rive extends LeafRenderObjectWidget {
|
||||
..artboard = artboard
|
||||
..fit = fit
|
||||
..alignment = alignment
|
||||
..artboardSize =
|
||||
artboard == null ? Size.zero : Size(artboard.width, artboard.height)
|
||||
..artboardSize = Size(artboard.width, artboard.height)
|
||||
..useArtboardSize = useArtboardSize;
|
||||
}
|
||||
|
||||
@ -60,8 +54,7 @@ class Rive extends LeafRenderObjectWidget {
|
||||
..artboard = artboard
|
||||
..fit = fit
|
||||
..alignment = alignment
|
||||
..artboardSize =
|
||||
artboard == null ? Size.zero : Size(artboard.width, artboard.height)
|
||||
..artboardSize = Size(artboard.width, artboard.height)
|
||||
..useArtboardSize = useArtboardSize;
|
||||
}
|
||||
|
||||
@ -72,7 +65,7 @@ class Rive extends LeafRenderObjectWidget {
|
||||
}
|
||||
|
||||
class RiveRenderObject extends RiveRenderBox {
|
||||
RuntimeArtboard _artboard;
|
||||
late RuntimeArtboard _artboard;
|
||||
|
||||
RuntimeArtboard get artboard => _artboard;
|
||||
|
||||
@ -80,15 +73,13 @@ class RiveRenderObject extends RiveRenderBox {
|
||||
if (_artboard == value) {
|
||||
return;
|
||||
}
|
||||
_artboard?.redraw?.removeListener(scheduleRepaint);
|
||||
_artboard.redraw.removeListener(scheduleRepaint);
|
||||
_artboard = value as RuntimeArtboard;
|
||||
_artboard?.redraw?.addListener(scheduleRepaint);
|
||||
_artboard.redraw.addListener(scheduleRepaint);
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_artboard?.redraw?.removeListener(scheduleRepaint);
|
||||
}
|
||||
void dispose() => _artboard.redraw.removeListener(scheduleRepaint);
|
||||
|
||||
@override
|
||||
AABB get aabb {
|
||||
|
@ -4,27 +4,21 @@ import 'package:rive/src/generated/animation/animation_base.dart';
|
||||
export 'package:rive/src/generated/animation/animation_base.dart';
|
||||
|
||||
class Animation extends AnimationBase<RuntimeArtboard> {
|
||||
Artboard _artboard;
|
||||
late Artboard _artboard;
|
||||
Artboard get artboard => _artboard;
|
||||
set artboard(Artboard value) {
|
||||
if (_artboard == value) {
|
||||
return;
|
||||
}
|
||||
_artboard?.internalRemoveAnimation(this);
|
||||
_artboard.internalRemoveAnimation(this);
|
||||
_artboard = value;
|
||||
_artboard?.internalAddAnimation(this);
|
||||
_artboard.internalAddAnimation(this);
|
||||
}
|
||||
|
||||
@override
|
||||
void onAdded() {}
|
||||
@override
|
||||
void onAddedDirty() {}
|
||||
@override
|
||||
void onRemoved() {
|
||||
artboard = null;
|
||||
super.onRemoved();
|
||||
}
|
||||
|
||||
void onAdded() {}
|
||||
@override
|
||||
void nameChanged(String from, String to) {}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:rive/src/core/core.dart';
|
||||
import 'package:rive/src/rive_core/animation/linear_animation.dart';
|
||||
import 'package:rive/src/generated/animation/animation_state_base.dart';
|
||||
export 'package:rive/src/generated/animation/animation_state_base.dart';
|
||||
@ -8,26 +9,26 @@ class AnimationState extends AnimationStateBase {
|
||||
return '${super.toString()} ($id) -> ${_animation?.name}';
|
||||
}
|
||||
|
||||
LinearAnimation _animation;
|
||||
LinearAnimation get animation => _animation;
|
||||
set animation(LinearAnimation value) {
|
||||
LinearAnimation? _animation;
|
||||
LinearAnimation? get animation => _animation;
|
||||
set animation(LinearAnimation? value) {
|
||||
if (_animation == value) {
|
||||
return;
|
||||
}
|
||||
_animation = value;
|
||||
animationId = value?.id;
|
||||
animationId = value?.id ?? Core.missingId;
|
||||
}
|
||||
|
||||
@override
|
||||
void animationIdChanged(int from, int to) {
|
||||
animation = id == null ? null : context?.resolve(to);
|
||||
animation = id == Core.missingId ? null : context.resolve(to);
|
||||
}
|
||||
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
super.onAddedDirty();
|
||||
if (animationId != null) {
|
||||
animation = context?.resolve(animationId);
|
||||
if (animationId != Core.missingId) {
|
||||
animation = context.resolve(animationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ double _getSlope(double aT, double aA1, double aA2) {
|
||||
}
|
||||
|
||||
class CubicInterpolator extends CubicInterpolatorBase implements Interpolator {
|
||||
_CubicEase _ease;
|
||||
_CubicEase _ease = _CubicEase.make(0.42, 0, 0.58, 1);
|
||||
@override
|
||||
bool equalParameters(Interpolator other) {
|
||||
if (other is CubicInterpolator) {
|
||||
@ -36,10 +36,7 @@ class CubicInterpolator extends CubicInterpolatorBase implements Interpolator {
|
||||
}
|
||||
|
||||
@override
|
||||
void onAdded() {
|
||||
_updateStoredCubic();
|
||||
}
|
||||
|
||||
void onAdded() => _updateStoredCubic();
|
||||
@override
|
||||
void onAddedDirty() {}
|
||||
@override
|
||||
@ -68,10 +65,9 @@ class CubicInterpolator extends CubicInterpolatorBase implements Interpolator {
|
||||
}
|
||||
|
||||
class _Cubic extends _CubicEase {
|
||||
Float64List _values;
|
||||
final Float64List _values = Float64List(splineTableSize);
|
||||
final double x1, y1, x2, y2;
|
||||
_Cubic(this.x1, this.y1, this.x2, this.y2) {
|
||||
_values = Float64List(splineTableSize);
|
||||
for (int i = 0; i < splineTableSize; ++i) {
|
||||
_values[i] = _calcBezier(i * sampleStepSize, x1, x2);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
|
||||
}
|
||||
|
||||
void apply(double time, double mix, CoreContext coreContext) {
|
||||
Core object = coreContext.resolve(objectId);
|
||||
Core? object = coreContext.resolve(objectId);
|
||||
if (object == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ class KeyFrameList<T extends KeyFrameInterface> {
|
||||
List<T> _keyframes = [];
|
||||
Iterable<T> get keyframes => _keyframes;
|
||||
set keyframes(Iterable<T> frames) => _keyframes = frames.toList();
|
||||
T after(T keyframe) {
|
||||
T? after(T keyframe) {
|
||||
var index = _keyframes.indexOf(keyframe);
|
||||
if (index != -1 && index + 1 < _keyframes.length) {
|
||||
return _keyframes[index + 1];
|
||||
@ -68,22 +68,23 @@ class KeyedProperty extends KeyedPropertyBase<RuntimeArtboard>
|
||||
bool internalRemoveKeyFrame(KeyFrame frame) {
|
||||
var removed = _keyframes.remove(frame);
|
||||
if (_keyframes.isEmpty) {
|
||||
context?.dirty(_checkShouldRemove);
|
||||
context.dirty(_checkShouldRemove);
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
void _checkShouldRemove() {
|
||||
if (_keyframes.isEmpty) {
|
||||
context?.removeObject(this);
|
||||
context.removeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
void markKeyFrameOrderDirty() {
|
||||
context?.dirty(_sortAndValidateKeyFrames);
|
||||
context.dirty(_sortAndValidateKeyFrames);
|
||||
}
|
||||
|
||||
void _sortAndValidateKeyFrames() {
|
||||
assert(hasValidated);
|
||||
sort();
|
||||
for (int i = 0; i < _keyframes.length - 1; i++) {
|
||||
var a = _keyframes[i];
|
||||
|
@ -8,12 +8,11 @@ export 'package:rive/src/generated/animation/keyframe_base.dart';
|
||||
|
||||
abstract class KeyFrame extends KeyFrameBase<RuntimeArtboard>
|
||||
implements KeyFrameInterface {
|
||||
double _timeInSeconds;
|
||||
double _timeInSeconds = 0;
|
||||
double get seconds => _timeInSeconds;
|
||||
bool get canInterpolate => true;
|
||||
KeyFrameInterpolation get interpolation => interpolationType == null
|
||||
? null
|
||||
: KeyFrameInterpolation.values[interpolationType];
|
||||
KeyFrameInterpolation get interpolation =>
|
||||
KeyFrameInterpolation.values[interpolationType];
|
||||
set interpolation(KeyFrameInterpolation value) {
|
||||
interpolationType = value.index;
|
||||
}
|
||||
@ -22,7 +21,7 @@ abstract class KeyFrame extends KeyFrameBase<RuntimeArtboard>
|
||||
void interpolationTypeChanged(int from, int to) {}
|
||||
@override
|
||||
void interpolatorIdChanged(int from, int to) {
|
||||
interpolator = context?.resolve(to);
|
||||
interpolator = context.resolve(to);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -33,8 +32,8 @@ abstract class KeyFrame extends KeyFrameBase<RuntimeArtboard>
|
||||
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
if (interpolatorId != null) {
|
||||
interpolator = context?.resolve(interpolatorId);
|
||||
if (interpolatorId != Core.missingId) {
|
||||
interpolator = context.resolve(interpolatorId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,14 +47,14 @@ abstract class KeyFrame extends KeyFrameBase<RuntimeArtboard>
|
||||
void apply(Core object, int propertyKey, double mix);
|
||||
void applyInterpolation(Core object, int propertyKey, double seconds,
|
||||
covariant KeyFrame nextFrame, double mix);
|
||||
Interpolator _interpolator;
|
||||
Interpolator get interpolator => _interpolator;
|
||||
set interpolator(Interpolator value) {
|
||||
Interpolator? _interpolator;
|
||||
Interpolator? get interpolator => _interpolator;
|
||||
set interpolator(Interpolator? value) {
|
||||
if (_interpolator == value) {
|
||||
return;
|
||||
}
|
||||
_interpolator = value;
|
||||
interpolatorId = value?.id;
|
||||
interpolatorId = value?.id ?? Core.missingId;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -13,7 +13,9 @@ void _apply(Core<CoreContext> object, int propertyKey, double mix, int value) {
|
||||
Color(RiveCoreContext.getColor(object, propertyKey)),
|
||||
Color(value),
|
||||
mix);
|
||||
RiveCoreContext.setColor(object, propertyKey, mixedColor.value);
|
||||
if (mixedColor != null) {
|
||||
RiveCoreContext.setColor(object, propertyKey, mixedColor.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,21 +23,20 @@ class KeyFrameColor extends KeyFrameColorBase {
|
||||
@override
|
||||
void apply(Core<CoreContext> object, int propertyKey, double mix) =>
|
||||
_apply(object, propertyKey, mix, value);
|
||||
@override
|
||||
void onAdded() {
|
||||
super.onAdded();
|
||||
interpolation ??= KeyFrameInterpolation.linear;
|
||||
KeyFrameColor() {
|
||||
interpolation = KeyFrameInterpolation.linear;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyInterpolation(Core<CoreContext> object, int propertyKey,
|
||||
double currentTime, KeyFrameColor nextFrame, double mix) {
|
||||
var f = (currentTime - seconds) / (nextFrame.seconds - seconds);
|
||||
if (interpolator != null) {
|
||||
f = interpolator.transform(f);
|
||||
f = interpolator!.transform(f);
|
||||
}
|
||||
var color = Color.lerp(Color(value), Color(nextFrame.value), f);
|
||||
if (color != null) {
|
||||
_apply(object, propertyKey, mix, color.value);
|
||||
}
|
||||
_apply(object, propertyKey, mix,
|
||||
Color.lerp(Color(value), Color(nextFrame.value), f).value);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -23,18 +23,15 @@ class KeyFrameDouble extends KeyFrameDoubleBase {
|
||||
@override
|
||||
void apply(Core<CoreContext> object, int propertyKey, double mix) =>
|
||||
_apply(object, propertyKey, mix, value);
|
||||
@override
|
||||
void onAdded() {
|
||||
super.onAdded();
|
||||
interpolation ??= KeyFrameInterpolation.linear;
|
||||
KeyFrameDouble() {
|
||||
interpolation = KeyFrameInterpolation.linear;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyInterpolation(Core<CoreContext> object, int propertyKey,
|
||||
double currentTime, KeyFrameDouble nextFrame, double mix) {
|
||||
var f = (currentTime - seconds) / (nextFrame.seconds - seconds);
|
||||
if (interpolator != null) {
|
||||
f = interpolator.transform(f);
|
||||
f = interpolator!.transform(f);
|
||||
}
|
||||
_apply(object, propertyKey, mix, value + (nextFrame.value - value) * f);
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:rive/src/core/core.dart';
|
||||
import 'package:rive/src/rive_core/animation/keyframe_interpolation.dart';
|
||||
import 'package:rive/src/generated/animation/keyframe_id_base.dart';
|
||||
import 'package:rive/src/generated/rive_core_context.dart';
|
||||
export 'package:rive/src/generated/animation/keyframe_id_base.dart';
|
||||
@ -12,12 +11,6 @@ class KeyFrameId extends KeyFrameIdBase {
|
||||
RiveCoreContext.setUint(object, propertyKey, value);
|
||||
}
|
||||
|
||||
@override
|
||||
void onAdded() {
|
||||
super.onAdded();
|
||||
interpolation ??= KeyFrameInterpolation.hold;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyInterpolation(Core<CoreContext> object, int propertyKey,
|
||||
double currentTime, KeyFrameId nextFrame, double mix) {
|
||||
|
@ -4,20 +4,21 @@ 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';
|
||||
|
||||
class _UnknownLayerState extends LayerState {}
|
||||
|
||||
abstract class LayerState extends LayerStateBase {
|
||||
final Set<StateTransition> _transitions = {};
|
||||
Iterable<StateTransition> get transitions => _transitions;
|
||||
static final LayerState unknown = _UnknownLayerState();
|
||||
@override
|
||||
void onAdded() {}
|
||||
@override
|
||||
void onAddedDirty() {}
|
||||
void internalAddTransition(StateTransition transition) {
|
||||
assert(transition != null);
|
||||
_transitions.add(transition);
|
||||
}
|
||||
|
||||
void internalRemoveTransition(StateTransition transition) {
|
||||
assert(transition != null);
|
||||
_transitions.remove(transition);
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,6 @@ class LinearAnimation extends LinearAnimationBase {
|
||||
final _keyedObjects = HashMap<int, KeyedObject>();
|
||||
Iterable<KeyedObject> get keyedObjects => _keyedObjects.values;
|
||||
bool internalAddKeyedObject(KeyedObject object) {
|
||||
assert(
|
||||
object.objectId != null,
|
||||
'KeyedObject must be referencing a Core object '
|
||||
'before being added to an animation.');
|
||||
var value = _keyedObjects[object.objectId];
|
||||
if (value != null && value != object) {
|
||||
return false;
|
||||
@ -22,8 +18,7 @@ class LinearAnimation extends LinearAnimationBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
void apply(double time, {double mix = 1, CoreContext coreContext}) {
|
||||
coreContext ??= context;
|
||||
void apply(double time, {required CoreContext coreContext, double mix = 1}) {
|
||||
for (final keyedObject in _keyedObjects.values) {
|
||||
keyedObject.apply(time, mix, coreContext);
|
||||
}
|
||||
|
@ -5,39 +5,16 @@ import 'package:rive/src/generated/animation/state_machine_component_base.dart';
|
||||
export 'package:rive/src/generated/animation/state_machine_component_base.dart';
|
||||
|
||||
abstract class StateMachineComponent extends StateMachineComponentBase {
|
||||
StateMachine _stateMachine;
|
||||
StateMachine get stateMachine => _stateMachine;
|
||||
set stateMachine(StateMachine value) {
|
||||
if (_stateMachine == value) {
|
||||
return;
|
||||
}
|
||||
var from = _stateMachine;
|
||||
_stateMachine = value;
|
||||
machineChanged(from, _stateMachine);
|
||||
}
|
||||
|
||||
late StateMachine stateMachine;
|
||||
ListBase<StateMachineComponent> machineComponentList(StateMachine machine);
|
||||
void machineChanged(StateMachine from, StateMachine to) {
|
||||
if (from != null) {
|
||||
machineComponentList(from)?.remove(this);
|
||||
}
|
||||
if (to != null) {
|
||||
machineComponentList(to)?.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void nameChanged(String from, String to) {}
|
||||
@override
|
||||
void onAdded() {}
|
||||
@override
|
||||
void onAddedDirty() {}
|
||||
@override
|
||||
void onRemoved() {
|
||||
super.onRemoved();
|
||||
if (stateMachine != null) {
|
||||
machineComponentList(stateMachine).remove(this);
|
||||
}
|
||||
machineComponentList(stateMachine).remove(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -5,9 +5,12 @@ import 'package:rive/src/generated/animation/state_machine_input_base.dart';
|
||||
export 'package:rive/src/generated/animation/state_machine_input_base.dart';
|
||||
|
||||
abstract class StateMachineInput extends StateMachineInputBase {
|
||||
static final StateMachineInput unknown = _StateMachineUnknownInput();
|
||||
@override
|
||||
ListBase<StateMachineComponent> machineComponentList(StateMachine machine) =>
|
||||
machine?.inputs;
|
||||
stateMachine.inputs;
|
||||
bool isValidType<T>() => false;
|
||||
dynamic get controllerValue => null;
|
||||
}
|
||||
|
||||
class _StateMachineUnknownInput extends StateMachineInput {}
|
||||
|
@ -10,19 +10,16 @@ import 'package:rive/src/generated/animation/state_machine_layer_base.dart';
|
||||
export 'package:rive/src/generated/animation/state_machine_layer_base.dart';
|
||||
|
||||
class StateMachineLayer extends StateMachineLayerBase {
|
||||
LayerState _entryState;
|
||||
LayerState _anyState;
|
||||
LayerState _exitState;
|
||||
LayerState _entryState = LayerState.unknown;
|
||||
LayerState _anyState = LayerState.unknown;
|
||||
LayerState _exitState = LayerState.unknown;
|
||||
LayerState get entryState => _entryState;
|
||||
LayerState get anyState => _anyState;
|
||||
LayerState get exitState => _exitState;
|
||||
@override
|
||||
ListBase<StateMachineComponent> machineComponentList(StateMachine machine) =>
|
||||
machine?.layers;
|
||||
@override
|
||||
void onAdded() {}
|
||||
stateMachine.layers;
|
||||
bool internalAddState(LayerState state) {
|
||||
assert(state != null);
|
||||
switch (state.coreType) {
|
||||
case AnyStateBase.typeKey:
|
||||
_anyState = state;
|
||||
|
@ -7,14 +7,18 @@ export 'package:rive/src/generated/animation/state_transition_base.dart';
|
||||
|
||||
class StateTransition extends StateTransitionBase {
|
||||
final StateTransitionConditions conditions = StateTransitionConditions();
|
||||
LayerState stateTo;
|
||||
LayerState stateTo = LayerState.unknown;
|
||||
static final StateTransition unknown = StateTransition();
|
||||
@override
|
||||
bool validate() {
|
||||
return super.validate() && stateTo != LayerState.unknown;
|
||||
}
|
||||
|
||||
@override
|
||||
void onAdded() {}
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
if (stateToId != null) {
|
||||
stateTo = context?.resolve(stateToId);
|
||||
}
|
||||
stateTo = context.resolveWithDefault(stateToId, LayerState.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -52,5 +56,5 @@ class StateTransition extends StateTransitionBase {
|
||||
@override
|
||||
void durationChanged(int from, int to) {}
|
||||
@override
|
||||
void stateToIdChanged(int from, int to) => stateTo = context?.resolve(to);
|
||||
void stateToIdChanged(int from, int to) {}
|
||||
}
|
||||
|
@ -15,26 +15,26 @@ enum TransitionConditionOp {
|
||||
}
|
||||
|
||||
abstract class TransitionCondition extends TransitionConditionBase {
|
||||
StateMachineInput _input;
|
||||
StateMachineInput _input = StateMachineInput.unknown;
|
||||
StateMachineInput get input => _input;
|
||||
set input(StateMachineInput value) {
|
||||
if (_input == value) {
|
||||
return;
|
||||
}
|
||||
_input = value;
|
||||
inputId = _input?.id;
|
||||
inputId = _input.id;
|
||||
}
|
||||
|
||||
@override
|
||||
void inputIdChanged(int from, int to) {
|
||||
input = to == null ? null : context?.resolve(to);
|
||||
input = context.resolveWithDefault(to, StateMachineInput.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
void onAdded() {}
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
input = inputId == null ? null : context.resolve(inputId);
|
||||
input = context.resolveWithDefault(inputId, StateMachineInput.unknown);
|
||||
}
|
||||
|
||||
bool evaluate(HashMap<int, dynamic> values);
|
||||
|
@ -8,8 +8,6 @@ class TransitionDoubleCondition extends TransitionDoubleConditionBase {
|
||||
@override
|
||||
void valueChanged(double from, double to) {}
|
||||
@override
|
||||
bool validate() => input == null || input is StateMachineDouble;
|
||||
@override
|
||||
bool evaluate(HashMap<int, dynamic> values) {
|
||||
var doubleInput = input as StateMachineDouble;
|
||||
dynamic providedValue = values[input.id];
|
||||
@ -29,6 +27,5 @@ class TransitionDoubleCondition extends TransitionDoubleConditionBase {
|
||||
case TransitionConditionOp.greaterThan:
|
||||
return inputValue > value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -15,14 +15,17 @@ import 'package:rive/src/utilities/dependency_sorter.dart';
|
||||
import 'package:rive/src/generated/artboard_base.dart';
|
||||
export 'package:rive/src/generated/artboard_base.dart';
|
||||
|
||||
class _UnknownArtboard extends Artboard {}
|
||||
|
||||
class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
static final Artboard unknown = _UnknownArtboard();
|
||||
@override
|
||||
bool get canBeOrphaned => true;
|
||||
final Path path = Path();
|
||||
List<Component> _dependencyOrder = [];
|
||||
final List<Drawable> _drawables = [];
|
||||
final List<DrawRules> _rules = [];
|
||||
List<DrawTarget> _sortedDrawRules;
|
||||
List<DrawTarget> _sortedDrawRules = [];
|
||||
final Set<Component> _components = {};
|
||||
List<Drawable> get drawables => _drawables;
|
||||
final AnimationList _animations = AnimationList();
|
||||
@ -35,8 +38,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
@override
|
||||
Artboard get artboard => this;
|
||||
Vec2D get originWorld {
|
||||
return Vec2D.fromValues(
|
||||
x + width * (originX ?? 0), y + height * (originY ?? 0));
|
||||
return Vec2D.fromValues(x + width * originX, y + height * originY);
|
||||
}
|
||||
|
||||
bool updateComponents() {
|
||||
@ -91,7 +93,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
|
||||
void onComponentDirty(Component component) {
|
||||
if ((dirt & ComponentDirt.components) == 0) {
|
||||
context?.markNeedsAdvance();
|
||||
context.markNeedsAdvance();
|
||||
_dirt |= ComponentDirt.components;
|
||||
}
|
||||
if (component.graphOrder < _dirtDepth) {
|
||||
@ -104,7 +106,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
void sortDependencies() {
|
||||
var optimistic = DependencySorter<Component>();
|
||||
var order = optimistic.sort(this);
|
||||
if (order == null) {
|
||||
if (order.isEmpty) {
|
||||
var robust = TarjansDependencySorter<Component>();
|
||||
order = robust.sort(this);
|
||||
}
|
||||
@ -118,8 +120,8 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
@override
|
||||
void update(int dirt) {
|
||||
if (dirt & ComponentDirt.worldTransform != 0) {
|
||||
var rect = Rect.fromLTWH(
|
||||
width * -(originX ?? 0), height * -(originY ?? 0), width, height);
|
||||
var rect =
|
||||
Rect.fromLTWH(width * -originX, height * -originY, width, height);
|
||||
path.reset();
|
||||
path.addRect(rect);
|
||||
}
|
||||
@ -158,7 +160,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
|
||||
void markDrawOrderDirty() {
|
||||
if ((dirt & ComponentDirt.drawOrder) == 0) {
|
||||
context?.markNeedsAdvance();
|
||||
context.markNeedsAdvance();
|
||||
_dirt |= ComponentDirt.drawOrder;
|
||||
}
|
||||
}
|
||||
@ -166,12 +168,12 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
void draw(Canvas canvas) {
|
||||
canvas.save();
|
||||
canvas.clipRect(Rect.fromLTWH(0, 0, width, height));
|
||||
canvas.translate(width * (originX ?? 0), height * (originY ?? 0));
|
||||
canvas.translate(width * originX, height * originY);
|
||||
for (final fill in fills) {
|
||||
fill.draw(canvas, path);
|
||||
}
|
||||
for (var drawable = _firstDrawable;
|
||||
drawable != null;
|
||||
drawable != Drawable.unknown;
|
||||
drawable = drawable.prev) {
|
||||
if (drawable.isHidden) {
|
||||
continue;
|
||||
@ -208,7 +210,6 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
|
||||
final Set<RiveAnimationController> _animationControllers = {};
|
||||
bool addController(RiveAnimationController controller) {
|
||||
assert(controller != null);
|
||||
if (_animationControllers.contains(controller) ||
|
||||
!controller.init(context)) {
|
||||
return false;
|
||||
@ -216,13 +217,12 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
controller.isActiveChanged.addListener(_onControllerPlayingChanged);
|
||||
_animationControllers.add(controller);
|
||||
if (controller.isActive) {
|
||||
context?.markNeedsAdvance();
|
||||
context.markNeedsAdvance();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool removeController(RiveAnimationController controller) {
|
||||
assert(controller != null);
|
||||
if (_animationControllers.remove(controller)) {
|
||||
controller.isActiveChanged.removeListener(_onControllerPlayingChanged);
|
||||
controller.dispose();
|
||||
@ -231,7 +231,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
return false;
|
||||
}
|
||||
|
||||
void _onControllerPlayingChanged() => context?.markNeedsAdvance();
|
||||
void _onControllerPlayingChanged() => context.markNeedsAdvance();
|
||||
@override
|
||||
void onFillsChanged() {}
|
||||
@override
|
||||
@ -240,7 +240,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
void onStrokesChanged() {}
|
||||
@override
|
||||
Vec2D get worldTranslation => Vec2D();
|
||||
Drawable _firstDrawable;
|
||||
Drawable _firstDrawable = Drawable.unknown;
|
||||
void computeDrawOrder() {
|
||||
_drawables.clear();
|
||||
_rules.clear();
|
||||
@ -254,7 +254,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
for (final nodeRules in _rules) {
|
||||
for (final target in nodeRules.targets) {
|
||||
root.dependents.add(target);
|
||||
var dependentRules = target.drawable?.flattenedDrawRules;
|
||||
var dependentRules = target.drawable.flattenedDrawRules;
|
||||
if (dependentRules != null) {
|
||||
for (final dependentRule in dependentRules.targets) {
|
||||
dependentRule.dependents.add(target);
|
||||
@ -269,27 +269,27 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
|
||||
void sortDrawOrder() {
|
||||
for (final rule in _sortedDrawRules) {
|
||||
rule.first = rule.last = null;
|
||||
rule.first = rule.last = Drawable.unknown;
|
||||
}
|
||||
_firstDrawable = null;
|
||||
Drawable lastDrawable;
|
||||
_firstDrawable = Drawable.unknown;
|
||||
Drawable lastDrawable = Drawable.unknown;
|
||||
for (final drawable in _drawables) {
|
||||
var rules = drawable.flattenedDrawRules;
|
||||
var target = rules?.activeTarget;
|
||||
if (target != null) {
|
||||
if (target.first == null) {
|
||||
if (target.first == Drawable.unknown) {
|
||||
target.first = target.last = drawable;
|
||||
drawable.prev = drawable.next = null;
|
||||
drawable.prev = drawable.next = Drawable.unknown;
|
||||
} else {
|
||||
target.last.next = drawable;
|
||||
drawable.prev = target.last;
|
||||
target.last = drawable;
|
||||
drawable.next = null;
|
||||
drawable.next = Drawable.unknown;
|
||||
}
|
||||
} else {
|
||||
drawable.prev = lastDrawable;
|
||||
drawable.next = null;
|
||||
if (lastDrawable == null) {
|
||||
drawable.next = Drawable.unknown;
|
||||
if (lastDrawable == Drawable.unknown) {
|
||||
lastDrawable = _firstDrawable = drawable;
|
||||
} else {
|
||||
lastDrawable.next = drawable;
|
||||
@ -298,12 +298,12 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
}
|
||||
}
|
||||
for (final rule in _sortedDrawRules) {
|
||||
if (rule.first == null) {
|
||||
if (rule.first == Drawable.unknown) {
|
||||
continue;
|
||||
}
|
||||
switch (rule.placement) {
|
||||
case DrawTargetPlacement.before:
|
||||
if (rule.drawable.prev != null) {
|
||||
if (rule.drawable.prev != Drawable.unknown) {
|
||||
rule.drawable.prev.next = rule.first;
|
||||
rule.first.prev = rule.drawable.prev;
|
||||
}
|
||||
@ -314,7 +314,7 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
rule.last.next = rule.drawable;
|
||||
break;
|
||||
case DrawTargetPlacement.after:
|
||||
if (rule.drawable.next != null) {
|
||||
if (rule.drawable.next != Drawable.unknown) {
|
||||
rule.drawable.next.prev = rule.last;
|
||||
rule.last.next = rule.drawable.next;
|
||||
}
|
||||
|
@ -2,10 +2,9 @@ import 'package:rive/src/generated/backboard_base.dart';
|
||||
export 'package:rive/src/generated/backboard_base.dart';
|
||||
|
||||
class Backboard extends BackboardBase {
|
||||
static final Backboard unknown = Backboard();
|
||||
@override
|
||||
void onAdded() {}
|
||||
@override
|
||||
void onAddedDirty() {}
|
||||
@override
|
||||
void onRemoved() {}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class Bone extends BoneBase {
|
||||
}
|
||||
}
|
||||
|
||||
Bone get firstChildBone {
|
||||
Bone? get firstChildBone {
|
||||
for (final child in children) {
|
||||
if (child.coreType == BoneBase.typeKey) {
|
||||
return child as Bone;
|
||||
|
@ -1,4 +1,14 @@
|
||||
import 'package:rive/src/generated/bones/skeletal_component_base.dart';
|
||||
export 'package:rive/src/generated/bones/skeletal_component_base.dart';
|
||||
|
||||
abstract class SkeletalComponent extends SkeletalComponentBase {}
|
||||
class _UnknownSkeletalComponent extends SkeletalComponent {
|
||||
@override
|
||||
double x = 0;
|
||||
@override
|
||||
double y = 0;
|
||||
}
|
||||
|
||||
// ignore: avoid_classes_with_only_static_members
|
||||
abstract class SkeletalComponent extends SkeletalComponentBase {
|
||||
static final SkeletalComponent unknown = _UnknownSkeletalComponent();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ export 'package:rive/src/generated/bones/skin_base.dart';
|
||||
class Skin extends SkinBase {
|
||||
final List<Tendon> _tendons = [];
|
||||
List<Tendon> get tendons => _tendons;
|
||||
Float32List _boneTransforms;
|
||||
Float32List _boneTransforms = Float32List(0);
|
||||
final Mat2D _worldTransform = Mat2D();
|
||||
@override
|
||||
void onDirty(int mask) {
|
||||
@ -20,7 +20,7 @@ class Skin extends SkinBase {
|
||||
@override
|
||||
void update(int dirt) {
|
||||
var size = (_tendons.length + 1) * 6;
|
||||
if (_boneTransforms == null || _boneTransforms.length != size) {
|
||||
if (_boneTransforms.length != size) {
|
||||
_boneTransforms = Float32List(size);
|
||||
_boneTransforms[0] = 1;
|
||||
_boneTransforms[1] = 0;
|
||||
@ -71,7 +71,7 @@ class Skin extends SkinBase {
|
||||
void buildDependencies() {
|
||||
super.buildDependencies();
|
||||
for (final tendon in _tendons) {
|
||||
tendon.bone?.addDependent(this);
|
||||
tendon.bone.addDependent(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ class Skin extends SkinBase {
|
||||
case TendonBase.typeKey:
|
||||
_tendons.add(child as Tendon);
|
||||
markRebuildDependencies();
|
||||
parent?.markRebuildDependencies();
|
||||
parent.markRebuildDependencies();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -98,7 +98,7 @@ class Skin extends SkinBase {
|
||||
} else {
|
||||
markRebuildDependencies();
|
||||
}
|
||||
parent?.markRebuildDependencies();
|
||||
parent.markRebuildDependencies();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,10 @@ import 'package:rive/src/rive_core/bones/skin.dart';
|
||||
import 'package:rive/src/rive_core/component.dart';
|
||||
|
||||
abstract class Skinnable {
|
||||
Skin _skin;
|
||||
Skin get skin => _skin;
|
||||
Skin? _skin;
|
||||
Skin? get skin => _skin;
|
||||
void appendChild(Component child);
|
||||
void addSkin(Skin skin) {
|
||||
assert(skin != null);
|
||||
_skin = skin;
|
||||
markSkinDirty();
|
||||
}
|
||||
|
@ -5,15 +5,15 @@ export 'package:rive/src/generated/bones/tendon_base.dart';
|
||||
|
||||
class Tendon extends TendonBase {
|
||||
final Mat2D _bind = Mat2D();
|
||||
Mat2D _inverseBind;
|
||||
SkeletalComponent _bone;
|
||||
Mat2D? _inverseBind = Mat2D();
|
||||
SkeletalComponent _bone = SkeletalComponent.unknown;
|
||||
SkeletalComponent get bone => _bone;
|
||||
Mat2D get inverseBind {
|
||||
if (_inverseBind == null) {
|
||||
_inverseBind = Mat2D();
|
||||
Mat2D.invert(_inverseBind, _bind);
|
||||
Mat2D.invert(_inverseBind!, _bind);
|
||||
}
|
||||
return _inverseBind;
|
||||
return _inverseBind!;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -21,9 +21,7 @@ class Tendon extends TendonBase {
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
super.onAddedDirty();
|
||||
if (boneId != null) {
|
||||
_bone = context?.resolve(boneId);
|
||||
}
|
||||
_bone = context.resolveWithDefault(boneId, SkeletalComponent.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -9,7 +9,7 @@ export 'package:rive/src/generated/component_base.dart';
|
||||
|
||||
abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
implements DependencyGraphNode<Component>, Parentable<Component> {
|
||||
Artboard _artboard;
|
||||
Artboard _artboard = Artboard.unknown;
|
||||
dynamic _userData;
|
||||
bool get canBeOrphaned => false;
|
||||
int graphOrder = 0;
|
||||
@ -21,7 +21,7 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
}
|
||||
dirt |= value;
|
||||
onDirty(dirt);
|
||||
artboard?.onComponentDirty(this);
|
||||
artboard.onComponentDirty(this);
|
||||
if (!recurse) {
|
||||
return true;
|
||||
}
|
||||
@ -38,9 +38,9 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
if (_artboard == value) {
|
||||
return;
|
||||
}
|
||||
_artboard?.removeComponent(this);
|
||||
_artboard.removeComponent(this);
|
||||
_artboard = value;
|
||||
_artboard?.addComponent(this);
|
||||
_artboard.addComponent(this);
|
||||
}
|
||||
|
||||
@mustCallSuper
|
||||
@ -48,7 +48,7 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
bool resolveArtboard() {
|
||||
int sanity = maxTreeDepth;
|
||||
for (Component curr = this;
|
||||
curr != null && sanity > 0;
|
||||
curr != ContainerComponent.unknown && sanity > 0;
|
||||
curr = curr.parent, sanity--) {
|
||||
visitAncestor(curr);
|
||||
if (curr is Artboard) {
|
||||
@ -56,7 +56,7 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_changeArtboard(null);
|
||||
_changeArtboard(Artboard.unknown);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -72,8 +72,9 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
|
||||
void userDataChanged(dynamic from, dynamic to) {}
|
||||
@override
|
||||
void parentIdChanged(int from, int to) => parent = context?.resolve(to);
|
||||
ContainerComponent _parent;
|
||||
void parentIdChanged(int from, int to) =>
|
||||
parent = context.resolveWithDefault(to, ContainerComponent.unknown);
|
||||
ContainerComponent _parent = ContainerComponent.unknown;
|
||||
@override
|
||||
ContainerComponent get parent => _parent;
|
||||
set parent(ContainerComponent value) {
|
||||
@ -82,20 +83,16 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
}
|
||||
var old = _parent;
|
||||
_parent = value;
|
||||
parentId = value?.id;
|
||||
parentId = value.id;
|
||||
parentChanged(old, value);
|
||||
}
|
||||
|
||||
@protected
|
||||
void parentChanged(ContainerComponent from, ContainerComponent to) {
|
||||
if (from != null) {
|
||||
from.children.remove(this);
|
||||
from.childRemoved(this);
|
||||
}
|
||||
if (to != null) {
|
||||
to.children.add(this);
|
||||
to.childAdded(this);
|
||||
}
|
||||
from.children.remove(this);
|
||||
from.childRemoved(this);
|
||||
to.children.add(this);
|
||||
to.childAdded(this);
|
||||
markRebuildDependencies();
|
||||
}
|
||||
|
||||
@ -104,7 +101,6 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
@override
|
||||
Set<Component> get dependents => _dependents;
|
||||
bool addDependent(Component dependent) {
|
||||
assert(dependent != null, 'Dependent cannot be null.');
|
||||
assert(artboard == dependent.artboard,
|
||||
'Components must be in the same artboard.');
|
||||
if (!_dependents.add(dependent)) {
|
||||
@ -116,7 +112,7 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
|
||||
bool isValidParent(Component parent) => parent is ContainerComponent;
|
||||
void markRebuildDependencies() {
|
||||
if (context == null || !context.markDependenciesDirty(this)) {
|
||||
if (!context.markDependenciesDirty(this)) {
|
||||
return;
|
||||
}
|
||||
for (final dependent in _dependents) {
|
||||
@ -137,9 +133,7 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
void onAdded() {}
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
if (parentId != null) {
|
||||
parent = context?.resolve(parentId);
|
||||
}
|
||||
parent = context.resolveWithDefault(parentId, ContainerComponent.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -154,14 +148,12 @@ abstract class Component extends ComponentBase<RuntimeArtboard>
|
||||
dependent.onDependencyRemoved(this);
|
||||
}
|
||||
_dependents.clear();
|
||||
if (parent != null) {
|
||||
if (parent != ContainerComponent.unknown) {
|
||||
parent.children.remove(this);
|
||||
parent.childRemoved(this);
|
||||
}
|
||||
if (artboard != null) {
|
||||
context?.markDependencyOrderDirty();
|
||||
_changeArtboard(null);
|
||||
}
|
||||
context.markDependencyOrderDirty();
|
||||
_changeArtboard(Artboard.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -7,8 +7,15 @@ import 'package:rive/src/generated/container_component_base.dart';
|
||||
|
||||
typedef bool DescentCallback(Component component);
|
||||
|
||||
class _UnknownParent extends ContainerComponent {
|
||||
@override
|
||||
void update(int dirt) => throw UnsupportedError(
|
||||
'Something is incorrectly referencing an unknown parent');
|
||||
}
|
||||
|
||||
abstract class ContainerComponent extends ContainerComponentBase {
|
||||
final ContainerChildren children = ContainerChildren();
|
||||
static final unknown = _UnknownParent();
|
||||
void appendChild(Component child) {
|
||||
child.parent = this;
|
||||
}
|
||||
@ -40,14 +47,13 @@ abstract class ContainerComponent extends ContainerComponentBase {
|
||||
}
|
||||
|
||||
void removeRecursive() {
|
||||
assert(context != null);
|
||||
Set<Component> deathRow = {this};
|
||||
forEachChild((child) => deathRow.add(child));
|
||||
deathRow.forEach(context.removeObject);
|
||||
}
|
||||
|
||||
void buildDrawOrder(
|
||||
List<Drawable> drawables, DrawRules rules, List<DrawRules> allRules) {
|
||||
List<Drawable> drawables, DrawRules? rules, List<DrawRules> allRules) {
|
||||
for (final child in children) {
|
||||
if (child is ContainerComponent) {
|
||||
child.buildDrawOrder(drawables, rules, allRules);
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:rive/src/core/core.dart';
|
||||
import 'package:rive/src/rive_core/component.dart';
|
||||
import 'package:rive/src/rive_core/draw_target.dart';
|
||||
import 'package:rive/src/generated/draw_rules_base.dart';
|
||||
@ -6,23 +7,20 @@ export 'package:rive/src/generated/draw_rules_base.dart';
|
||||
class DrawRules extends DrawRulesBase {
|
||||
final Set<DrawTarget> _targets = {};
|
||||
Set<DrawTarget> get targets => _targets;
|
||||
DrawTarget _activeTarget;
|
||||
DrawTarget get activeTarget => _activeTarget;
|
||||
set activeTarget(DrawTarget value) => drawTargetId = value?.id;
|
||||
DrawTarget? _activeTarget;
|
||||
DrawTarget? get activeTarget => _activeTarget;
|
||||
set activeTarget(DrawTarget? value) =>
|
||||
drawTargetId = value?.id ?? Core.missingId;
|
||||
@override
|
||||
void drawTargetIdChanged(int from, int to) {
|
||||
_activeTarget = to == null ? null : context?.resolve(to);
|
||||
artboard?.markDrawOrderDirty();
|
||||
_activeTarget = context.resolve(to);
|
||||
artboard.markDrawOrderDirty();
|
||||
}
|
||||
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
super.onAddedDirty();
|
||||
if (drawTargetId != null) {
|
||||
_activeTarget = context?.resolve(drawTargetId);
|
||||
} else {
|
||||
_activeTarget = null;
|
||||
}
|
||||
_activeTarget = context.resolve(drawTargetId);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -5,16 +5,16 @@ export 'package:rive/src/generated/draw_target_base.dart';
|
||||
enum DrawTargetPlacement { before, after }
|
||||
|
||||
class DrawTarget extends DrawTargetBase {
|
||||
Drawable first;
|
||||
Drawable last;
|
||||
Drawable _drawable;
|
||||
Drawable first = Drawable.unknown;
|
||||
Drawable last = Drawable.unknown;
|
||||
Drawable _drawable = Drawable.unknown;
|
||||
Drawable get drawable => _drawable;
|
||||
set drawable(Drawable value) {
|
||||
if (_drawable == value) {
|
||||
return;
|
||||
}
|
||||
_drawable = value;
|
||||
drawableId = value?.id;
|
||||
drawableId = value.id;
|
||||
}
|
||||
|
||||
DrawTargetPlacement get placement =>
|
||||
@ -22,22 +22,18 @@ class DrawTarget extends DrawTargetBase {
|
||||
set placement(DrawTargetPlacement value) => placementValue = value.index;
|
||||
@override
|
||||
void drawableIdChanged(int from, int to) {
|
||||
drawable = context?.resolve(to);
|
||||
drawable = context.resolveWithDefault(to, Drawable.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
super.onAddedDirty();
|
||||
if (drawableId != null) {
|
||||
drawable = context?.resolve(drawableId);
|
||||
} else {
|
||||
drawable = null;
|
||||
}
|
||||
drawable = context.resolveWithDefault(drawableId, Drawable.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
void placementValueChanged(int from, int to) {
|
||||
artboard?.markDrawOrderDirty();
|
||||
artboard.markDrawOrderDirty();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -8,13 +8,20 @@ import 'package:rive/src/generated/drawable_base.dart';
|
||||
import 'package:rive/src/rive_core/transform_component.dart';
|
||||
export 'package:rive/src/generated/drawable_base.dart';
|
||||
|
||||
class _UnknownDrawable extends Drawable {
|
||||
@override
|
||||
void draw(Canvas canvas) =>
|
||||
throw UnsupportedError('Cannot draw an unknown drawable.');
|
||||
}
|
||||
|
||||
abstract class Drawable extends DrawableBase {
|
||||
DrawRules flattenedDrawRules;
|
||||
Drawable prev;
|
||||
Drawable next;
|
||||
static final Drawable unknown = _UnknownDrawable();
|
||||
DrawRules? flattenedDrawRules;
|
||||
Drawable prev = Drawable.unknown;
|
||||
Drawable next = Drawable.unknown;
|
||||
@override
|
||||
void buildDrawOrder(
|
||||
List<Drawable> drawables, DrawRules rules, List<DrawRules> allRules) {
|
||||
List<Drawable> drawables, DrawRules? rules, List<DrawRules> allRules) {
|
||||
flattenedDrawRules = drawRules ?? rules;
|
||||
drawables.add(this);
|
||||
super.buildDrawOrder(drawables, rules, allRules);
|
||||
@ -25,9 +32,9 @@ abstract class Drawable extends DrawableBase {
|
||||
set blendMode(BlendMode value) => blendModeValue = value.index;
|
||||
@override
|
||||
void blendModeValueChanged(int from, int to) {}
|
||||
List<ClippingShape> _clippingShapes;
|
||||
List<ClippingShape> _clippingShapes = [];
|
||||
bool clip(Canvas canvas) {
|
||||
if (_clippingShapes == null) {
|
||||
if (_clippingShapes.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
canvas.save();
|
||||
@ -51,14 +58,16 @@ abstract class Drawable extends DrawableBase {
|
||||
super.update(dirt);
|
||||
if (dirt & ComponentDirt.clip != 0) {
|
||||
List<ClippingShape> clippingShapes = [];
|
||||
for (ContainerComponent p = this; p != null; p = p.parent) {
|
||||
for (ContainerComponent p = this;
|
||||
p != ContainerComponent.unknown;
|
||||
p = p.parent) {
|
||||
if (p is TransformComponent) {
|
||||
if (p.clippingShapes != null) {
|
||||
if (p.clippingShapes.isNotEmpty) {
|
||||
clippingShapes.addAll(p.clippingShapes);
|
||||
}
|
||||
}
|
||||
}
|
||||
_clippingShapes = clippingShapes.isEmpty ? null : clippingShapes;
|
||||
_clippingShapes = clippingShapes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,23 +31,17 @@ class AABB {
|
||||
double get maxX => _buffer[2];
|
||||
double get minY => _buffer[1];
|
||||
double get maxY => _buffer[3];
|
||||
AABB() {
|
||||
_buffer = Float32List.fromList([0.0, 0.0, 0.0, 0.0]);
|
||||
}
|
||||
AABB.clone(AABB a) {
|
||||
_buffer = Float32List.fromList(a.values);
|
||||
}
|
||||
AABB.fromValues(double a, double b, double c, double d) {
|
||||
_buffer = Float32List.fromList([a, b, c, d]);
|
||||
}
|
||||
AABB.empty() {
|
||||
_buffer = Float32List.fromList([
|
||||
double.maxFinite,
|
||||
double.maxFinite,
|
||||
-double.maxFinite,
|
||||
-double.maxFinite
|
||||
]);
|
||||
}
|
||||
AABB() : _buffer = Float32List.fromList([0.0, 0.0, 0.0, 0.0]);
|
||||
AABB.clone(AABB a) : _buffer = Float32List.fromList(a.values);
|
||||
AABB.fromValues(double a, double b, double c, double d)
|
||||
: _buffer = Float32List.fromList([a, b, c, d]);
|
||||
AABB.empty()
|
||||
: _buffer = Float32List.fromList([
|
||||
double.maxFinite,
|
||||
double.maxFinite,
|
||||
-double.maxFinite,
|
||||
-double.maxFinite
|
||||
]);
|
||||
factory AABB.expand(AABB from, double amount) {
|
||||
var aabb = AABB.clone(from);
|
||||
if (aabb.width < amount) {
|
||||
@ -69,7 +63,7 @@ class AABB {
|
||||
return aabb;
|
||||
}
|
||||
bool get isEmpty => !AABB.isValid(this);
|
||||
Vec2D includePoint(Vec2D point, Mat2D transform) {
|
||||
Vec2D includePoint(Vec2D point, Mat2D? transform) {
|
||||
var transformedPoint = transform == null
|
||||
? point
|
||||
: Vec2D.transformMat2D(Vec2D(), point, transform);
|
||||
@ -94,9 +88,8 @@ class AABB {
|
||||
}
|
||||
}
|
||||
|
||||
AABB.fromMinMax(Vec2D min, Vec2D max) {
|
||||
_buffer = Float32List.fromList([min[0], min[1], max[0], max[1]]);
|
||||
}
|
||||
AABB.fromMinMax(Vec2D min, Vec2D max)
|
||||
: _buffer = Float32List.fromList([min[0], min[1], max[0], max[1]]);
|
||||
static bool areEqual(AABB a, AABB b) {
|
||||
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3];
|
||||
}
|
||||
@ -202,8 +195,8 @@ class AABB {
|
||||
], transform: matrix);
|
||||
}
|
||||
|
||||
AABB.fromPoints(Iterable<Vec2D> points,
|
||||
{Mat2D transform, double expand = 0}) {
|
||||
factory AABB.fromPoints(Iterable<Vec2D> points,
|
||||
{Mat2D? transform, double expand = 0}) {
|
||||
double minX = double.maxFinite;
|
||||
double minY = double.maxFinite;
|
||||
double maxX = -double.maxFinite;
|
||||
@ -243,6 +236,6 @@ class AABB {
|
||||
maxY += diff;
|
||||
}
|
||||
}
|
||||
_buffer = Float32List.fromList([minX, minY, maxX, maxY]);
|
||||
return AABB.fromValues(minX, minY, maxX, maxY);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
import "dart:math";
|
||||
import "dart:typed_data";
|
||||
import "transform_components.dart";
|
||||
import "vec2d.dart";
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'package:rive/src/rive_core/math/transform_components.dart';
|
||||
import 'package:rive/src/rive_core/math/vec2d.dart';
|
||||
|
||||
class _Identity extends Mat2D {
|
||||
@override
|
||||
void operator []=(int index, double value) => throw UnsupportedError(
|
||||
'Cannot change components of the identity matrix.');
|
||||
}
|
||||
|
||||
class Mat2D {
|
||||
Float32List _buffer;
|
||||
static final Mat2D identity = _Identity();
|
||||
final Float32List _buffer;
|
||||
Float32List get values {
|
||||
return _buffer;
|
||||
}
|
||||
@ -38,23 +45,16 @@ class Mat2D {
|
||||
_buffer[index] = value;
|
||||
}
|
||||
|
||||
Mat2D() {
|
||||
_buffer = Float32List.fromList([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]);
|
||||
}
|
||||
Mat2D.fromTranslation(Vec2D translation) {
|
||||
_buffer = Float32List.fromList(
|
||||
[1.0, 0.0, 0.0, 1.0, translation[0], translation[1]]);
|
||||
}
|
||||
Mat2D.fromScaling(Vec2D scaling) {
|
||||
_buffer = Float32List.fromList([scaling[0], 0, 0, scaling[1], 0, 0]);
|
||||
}
|
||||
Mat2D.fromMat4(Float64List mat4) {
|
||||
_buffer = Float32List.fromList(
|
||||
[mat4[0], mat4[1], mat4[4], mat4[5], mat4[12], mat4[13]]);
|
||||
}
|
||||
Mat2D.clone(Mat2D copy) {
|
||||
_buffer = Float32List.fromList(copy.values);
|
||||
}
|
||||
Mat2D() : _buffer = Float32List.fromList([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]);
|
||||
Mat2D.fromTranslation(Vec2D translation)
|
||||
: _buffer = Float32List.fromList(
|
||||
[1.0, 0.0, 0.0, 1.0, translation[0], translation[1]]);
|
||||
Mat2D.fromScaling(Vec2D scaling)
|
||||
: _buffer = Float32List.fromList([scaling[0], 0, 0, scaling[1], 0, 0]);
|
||||
Mat2D.fromMat4(Float64List mat4)
|
||||
: _buffer = Float32List.fromList(
|
||||
[mat4[0], mat4[1], mat4[4], mat4[5], mat4[12], mat4[13]]);
|
||||
Mat2D.clone(Mat2D copy) : _buffer = Float32List.fromList(copy.values);
|
||||
static Mat2D fromRotation(Mat2D o, double rad) {
|
||||
double s = sin(rad);
|
||||
double c = cos(rad);
|
||||
@ -109,6 +109,17 @@ class Mat2D {
|
||||
o[3] *= y;
|
||||
}
|
||||
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Mat2D multiplySkipIdentity(Mat2D a, Mat2D b) {
|
||||
if (a == Mat2D.identity) {
|
||||
return b;
|
||||
} else if (b == Mat2D.identity) {
|
||||
return a;
|
||||
} else {
|
||||
return multiply(Mat2D(), a, b);
|
||||
}
|
||||
}
|
||||
|
||||
static Mat2D multiply(Mat2D o, Mat2D a, Mat2D b) {
|
||||
double a0 = a[0],
|
||||
a1 = a[1],
|
||||
@ -181,7 +192,7 @@ class Mat2D {
|
||||
return t;
|
||||
}
|
||||
|
||||
static void identity(Mat2D mat) {
|
||||
static void setIdentity(Mat2D mat) {
|
||||
mat[0] = 1.0;
|
||||
mat[1] = 0.0;
|
||||
mat[2] = 0.0;
|
||||
@ -210,7 +221,7 @@ class Mat2D {
|
||||
if (r != 0.0) {
|
||||
Mat2D.fromRotation(m, r);
|
||||
} else {
|
||||
Mat2D.identity(m);
|
||||
Mat2D.setIdentity(m);
|
||||
}
|
||||
m[4] = result[0];
|
||||
m[5] = result[1];
|
||||
|
@ -9,13 +9,13 @@ class ProjectionResult {
|
||||
class Segment2D {
|
||||
final Vec2D start;
|
||||
final Vec2D end;
|
||||
Vec2D diff;
|
||||
double lengthSquared;
|
||||
Vec2D? diff;
|
||||
double lengthSquared = 0;
|
||||
Segment2D(this.start, this.end);
|
||||
ProjectionResult projectPoint(Vec2D point, {bool clamp = true}) {
|
||||
if (diff == null) {
|
||||
diff = Vec2D.subtract(Vec2D(), start, end);
|
||||
lengthSquared = Vec2D.squaredLength(diff);
|
||||
lengthSquared = Vec2D.squaredLength(diff!);
|
||||
}
|
||||
if (lengthSquared == 0) {
|
||||
return ProjectionResult(0, start);
|
||||
|
@ -1,9 +1,9 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'vec2d.dart';
|
||||
import 'package:rive/src/rive_core/math/vec2d.dart';
|
||||
|
||||
class TransformComponents {
|
||||
Float32List _buffer;
|
||||
final Float32List _buffer;
|
||||
Float32List get values {
|
||||
return _buffer;
|
||||
}
|
||||
@ -16,12 +16,10 @@ class TransformComponents {
|
||||
_buffer[index] = value;
|
||||
}
|
||||
|
||||
TransformComponents() {
|
||||
_buffer = Float32List.fromList([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]);
|
||||
}
|
||||
TransformComponents.clone(TransformComponents copy) {
|
||||
_buffer = Float32List.fromList(copy.values);
|
||||
}
|
||||
TransformComponents()
|
||||
: _buffer = Float32List.fromList([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]);
|
||||
TransformComponents.clone(TransformComponents copy)
|
||||
: _buffer = Float32List.fromList(copy.values);
|
||||
double get x {
|
||||
return _buffer[0];
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'package:rive/src/rive_core/math/mat2d.dart';
|
||||
import 'package:rive/src/utilities/utilities.dart';
|
||||
import 'mat2d.dart';
|
||||
|
||||
class Vec2D {
|
||||
Float32List _buffer;
|
||||
final Float32List _buffer;
|
||||
Float32List get values {
|
||||
return _buffer;
|
||||
}
|
||||
@ -17,15 +17,9 @@ class Vec2D {
|
||||
_buffer[index] = value;
|
||||
}
|
||||
|
||||
Vec2D() {
|
||||
_buffer = Float32List.fromList([0.0, 0.0]);
|
||||
}
|
||||
Vec2D.clone(Vec2D copy) {
|
||||
_buffer = Float32List.fromList(copy._buffer);
|
||||
}
|
||||
Vec2D.fromValues(double x, double y) {
|
||||
_buffer = Float32List.fromList([x, y]);
|
||||
}
|
||||
Vec2D() : _buffer = Float32List.fromList([0.0, 0.0]);
|
||||
Vec2D.clone(Vec2D copy) : _buffer = Float32List.fromList(copy._buffer);
|
||||
Vec2D.fromValues(double x, double y) : _buffer = Float32List.fromList([x, y]);
|
||||
static void copy(Vec2D o, Vec2D a) {
|
||||
o[0] = a[0];
|
||||
o[1] = a[1];
|
||||
|
@ -3,7 +3,10 @@ import 'package:rive/src/rive_core/math/vec2d.dart';
|
||||
import 'package:rive/src/generated/node_base.dart';
|
||||
export 'package:rive/src/generated/node_base.dart';
|
||||
|
||||
class _UnknownNode extends Node {}
|
||||
|
||||
class Node extends NodeBase {
|
||||
static final Node unknown = _UnknownNode();
|
||||
set translation(Vec2D pos) {
|
||||
x = pos[0];
|
||||
y = pos[1];
|
||||
|
@ -1,8 +1,7 @@
|
||||
import 'dart:collection';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:rive/src/rive_core/runtime/exceptions/rive_format_error_exception.dart';
|
||||
import 'package:rive/src/rive_core/runtime/exceptions/rive_unsupported_version_exception.dart';
|
||||
import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
|
||||
import 'exceptions/rive_format_error_exception.dart';
|
||||
|
||||
class RuntimeVersion {
|
||||
final int major;
|
||||
@ -11,8 +10,6 @@ class RuntimeVersion {
|
||||
String versionString() {
|
||||
return '$major.$minor';
|
||||
}
|
||||
|
||||
bool get includesStateMachines => major >= 6 && minor >= 4;
|
||||
}
|
||||
|
||||
const riveVersion = RuntimeVersion(7, 0);
|
||||
@ -23,9 +20,9 @@ class RuntimeHeader {
|
||||
final int fileId;
|
||||
final HashMap<int, int> propertyToFieldIndex;
|
||||
RuntimeHeader(
|
||||
{@required this.fileId,
|
||||
@required this.version,
|
||||
this.propertyToFieldIndex});
|
||||
{required this.fileId,
|
||||
required this.version,
|
||||
required this.propertyToFieldIndex});
|
||||
factory RuntimeHeader.read(BinaryReader reader) {
|
||||
var fingerprint = RuntimeHeader.fingerprint.codeUnits;
|
||||
for (int i = 0; i < fingerprint.length; i++) {
|
||||
|
@ -10,40 +10,36 @@ class ClippingShape extends ClippingShapeBase {
|
||||
final List<Shape> _shapes = [];
|
||||
PathFillType get fillType => PathFillType.values[fillRule];
|
||||
set fillType(PathFillType type) => fillRule = type.index;
|
||||
Node _source;
|
||||
Node _source = Node.unknown;
|
||||
Node get source => _source;
|
||||
set source(Node value) {
|
||||
if (_source == value) {
|
||||
return;
|
||||
}
|
||||
_source = value;
|
||||
sourceId = value?.id;
|
||||
sourceId = value.id;
|
||||
}
|
||||
|
||||
@override
|
||||
void fillRuleChanged(int from, int to) {
|
||||
parent?.addDirt(ComponentDirt.clip, recurse: true);
|
||||
parent.addDirt(ComponentDirt.clip, recurse: true);
|
||||
addDirt(ComponentDirt.path);
|
||||
}
|
||||
|
||||
@override
|
||||
void sourceIdChanged(int from, int to) {
|
||||
source = context?.resolve(to);
|
||||
}
|
||||
|
||||
void sourceIdChanged(int from, int to) =>
|
||||
source = context.resolveWithDefault(to, Node.unknown);
|
||||
@override
|
||||
void onAddedDirty() {
|
||||
super.onAddedDirty();
|
||||
if (sourceId != null) {
|
||||
source = context?.resolve(sourceId);
|
||||
}
|
||||
source = context.resolveWithDefault(sourceId, Node.unknown);
|
||||
}
|
||||
|
||||
@override
|
||||
void buildDependencies() {
|
||||
super.buildDependencies();
|
||||
_shapes.clear();
|
||||
_source?.forAll((component) {
|
||||
_source.forAll((component) {
|
||||
if (component is Shape) {
|
||||
_shapes.add(component);
|
||||
component.pathComposer.addDependent(this);
|
||||
@ -61,8 +57,7 @@ class ClippingShape extends ClippingShapeBase {
|
||||
|
||||
@override
|
||||
void update(int dirt) {
|
||||
if (dirt & (ComponentDirt.worldTransform | ComponentDirt.path) != 0 &&
|
||||
source != null) {
|
||||
if (dirt & (ComponentDirt.worldTransform | ComponentDirt.path) != 0) {
|
||||
clippingPath.reset();
|
||||
clippingPath.fillType = fillType;
|
||||
for (final shape in _shapes) {
|
||||
@ -78,6 +73,6 @@ class ClippingShape extends ClippingShapeBase {
|
||||
|
||||
@override
|
||||
void isVisibleChanged(bool from, bool to) {
|
||||
_source?.addDirt(ComponentDirt.paint);
|
||||
_source.addDirt(ComponentDirt.paint);
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import 'package:rive/src/generated/shapes/cubic_asymmetric_vertex_base.dart';
|
||||
export 'package:rive/src/generated/shapes/cubic_asymmetric_vertex_base.dart';
|
||||
|
||||
class CubicAsymmetricVertex extends CubicAsymmetricVertexBase {
|
||||
Vec2D _inPoint;
|
||||
Vec2D _outPoint;
|
||||
Vec2D? _inPoint;
|
||||
Vec2D? _outPoint;
|
||||
@override
|
||||
Vec2D get outPoint {
|
||||
return _outPoint ??= Vec2D.add(
|
||||
@ -57,20 +57,20 @@ class CubicAsymmetricVertex extends CubicAsymmetricVertexBase {
|
||||
void inDistanceChanged(double from, double to) {
|
||||
addDirt(ComponentDirt.worldTransform);
|
||||
_inPoint = _outPoint = null;
|
||||
path?.markPathDirty();
|
||||
path.markPathDirty();
|
||||
}
|
||||
|
||||
@override
|
||||
void outDistanceChanged(double from, double to) {
|
||||
addDirt(ComponentDirt.worldTransform);
|
||||
_inPoint = _outPoint = null;
|
||||
path?.markPathDirty();
|
||||
path.markPathDirty();
|
||||
}
|
||||
|
||||
@override
|
||||
void rotationChanged(double from, double to) {
|
||||
addDirt(ComponentDirt.worldTransform);
|
||||
_inPoint = _outPoint = null;
|
||||
path?.markPathDirty();
|
||||
path.markPathDirty();
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user