Merge pull request #70 from rive-app/nnbd

nnbd, state machine, format 7
This commit is contained in:
Luigi Rosso
2021-03-29 17:05:18 -07:00
committed by GitHub
177 changed files with 3391 additions and 1282 deletions

View File

@ -1,3 +1,9 @@
## [0.7.0-nullsafety.0] - 2021-03-29 16:58:23
- NNBD support.
- State Machine runtime support.
- New binary format 7.0 with improved flexibility which is not compatible with 6.0 files. The Rive editor will be able to export both format 6.0 and 7.0, but please note that 6.0 is now deprecated and all new improvements and bug fixes to the format will be done on 7.0.
## [0.6.8] - 2021-02-12 11:11:11
- Adds support for Flutter's `getMinIntrinsicWidth` (max, height, etc.), e.g. for `IntrinsicWidth`

BIN
example/assets/rocket.riv Normal file

Binary file not shown.

View File

@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:rive/rive.dart';
class ExampleAnimation extends StatefulWidget {
const ExampleAnimation({Key? key}) : super(key: key);
@override
_ExampleAnimationState createState() => _ExampleAnimationState();
}
class _ExampleAnimationState extends State<ExampleAnimation> {
void _togglePlay() {
if (_controller == null) {
return;
}
setState(() => _controller!.isActive = !_controller!.isActive);
}
/// Tracks if the animation is playing by whether controller is running.
bool get isPlaying => _controller?.isActive ?? false;
Artboard? _riveArtboard;
RiveAnimationController? _controller;
@override
void initState() {
super.initState();
// Load the animation file from the bundle, note that you could also
// download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/dino.riv').then(
(data) async {
// Load the RiveFile from the binary data.
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);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Animation Example'),
),
body: Center(
child: _riveArtboard == null
? const SizedBox()
: Rive(artboard: _riveArtboard!),
),
floatingActionButton: FloatingActionButton(
onPressed: _togglePlay,
tooltip: isPlaying ? 'Pause' : 'Play',
child: Icon(
isPlaying ? Icons.pause : Icons.play_arrow,
),
),
);
}
}

View File

@ -0,0 +1,77 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:rive/rive.dart';
class ExampleStateMachine extends StatefulWidget {
const ExampleStateMachine({Key? key}) : super(key: key);
@override
_ExampleStateMachineState createState() => _ExampleStateMachineState();
}
class _ExampleStateMachineState extends State<ExampleStateMachine> {
/// Tracks if the animation is playing by whether controller is running.
bool get isPlaying => _controller?.isActive ?? false;
Artboard? _riveArtboard;
StateMachineController? _controller;
StateMachineInput<bool>? _hoverInput;
StateMachineInput<bool>? _pressInput;
@override
void initState() {
super.initState();
// Load the animation file from the bundle, note that you could also
// download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/rocket.riv').then(
(data) async {
// Load the RiveFile from the binary data.
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);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
title: const Text('State Machine Example'),
),
body: Center(
child: _riveArtboard == null
? const SizedBox()
: MouseRegion(
onEnter: (_) => _hoverInput?.value = true,
onExit: (_) => _hoverInput?.value = false,
child: GestureDetector(
onTapDown: (_) => _pressInput?.value = true,
onTapCancel: () => _pressInput?.value = false,
onTapUp: (_) => _pressInput?.value = false,
child: SizedBox(
width: 250,
height: 250,
child: Rive(
artboard: _riveArtboard!,
),
),
),
),
),
);
}
}

View File

@ -1,77 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rive/rive.dart';
import 'package:rive_example/example_animation.dart';
import 'package:rive_example/example_state_machine.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _togglePlay() {
setState(() => _controller.isActive = !_controller.isActive);
}
/// Tracks if the animation is playing by whether controller is running.
bool get isPlaying => _controller?.isActive ?? false;
Artboard _riveArtboard;
RiveAnimationController _controller;
@override
void initState() {
super.initState();
// Load the animation file from the bundle, note that you could also
// download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/off_road_car.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('idle'));
setState(() => _riveArtboard = artboard);
}
},
);
}
void main() => runApp(MaterialApp(
title: 'Navigation Basics',
home: Home(),
));
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: _riveArtboard == null
? const SizedBox()
: Rive(artboard: _riveArtboard),
appBar: AppBar(
title: const Text('Rive Examples'),
),
floatingActionButton: FloatingActionButton(
onPressed: _togglePlay,
tooltip: isPlaying ? 'Pause' : 'Play',
child: Icon(
isPlaying ? Icons.pause : Icons.play_arrow,
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
child: const Text('Animation'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (context) => const ExampleAnimation(),
),
);
},
),
const SizedBox(
height: 10,
),
ElevatedButton(
child: const Text('State Machine'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (context) => const ExampleStateMachine(),
),
);
},
),
],
),
),
);

View File

@ -54,7 +54,7 @@
/* Begin PBXFileReference section */
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
33CC10ED2044A3C60003C045 /* rive_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "rive_example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
@ -105,7 +105,7 @@
33CC10EE2044A3C60003C045 /* Products */ = {
isa = PBXGroup;
children = (
33CC10ED2044A3C60003C045 /* rive_example.app */,
33CC10ED2044A3C60003C045 /* example.app */,
);
name = Products;
sourceTree = "<group>";
@ -172,7 +172,7 @@
);
name = Runner;
productName = Runner;
productReference = 33CC10ED2044A3C60003C045 /* rive_example.app */;
productReference = 33CC10ED2044A3C60003C045 /* example.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
@ -183,7 +183,7 @@
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "The Flutter Authors";
ORGANIZATIONNAME = "";
TargetAttributes = {
33CC10EC2044A3C60003C045 = {
CreatedOnToolsVersion = 9.2;
@ -202,7 +202,7 @@
};
};
buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 8.0";
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
@ -268,7 +268,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh\ntouch Flutter/ephemeral/tripwire\n";
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
};
/* End PBXShellScriptBuildPhase section */
@ -361,10 +361,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -491,10 +487,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -515,10 +507,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",

View File

@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "rive_example.app"
BuildableName = "example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
@ -27,23 +27,11 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00380F9121DF178D00097171"
BuildableName = "RunnerUITests.xctest"
BlueprintName = "RunnerUITests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "rive_example.app"
BuildableName = "example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
@ -66,7 +54,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "rive_example.app"
BuildableName = "example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
@ -75,7 +63,7 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
@ -85,7 +73,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "rive_example.app"
BuildableName = "example.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>

View File

@ -5,10 +5,10 @@
// 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = rive_example
PRODUCT_NAME = example
// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = com.example.riveExample
PRODUCT_BUNDLE_IDENTIFIER = com.example.example
// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2020 com.example. All rights reserved.
PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved.

View File

@ -1,12 +1,12 @@
name: rive_example
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:

View File

@ -1,20 +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/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';

View File

@ -1,10 +1,10 @@
import 'dart:collection';
import 'package:rive/src/rive_core/animation/animation.dart';
// TODO: figure out how to make this cleaner.
class AnimationList extends ListBase<Animation> {
final List<Animation> _values = [];
List<Animation> get values => _values;
// Lame way to do this due to how ListBase needs to expand a nullable list.
final List<Animation?> _values = [];
List<Animation> get values => _values.cast<Animation>();
@override
int get length => _values.length;
@ -13,7 +13,7 @@ class AnimationList extends ListBase<Animation> {
set length(int value) => _values.length = value;
@override
Animation operator [](int index) => _values[index];
Animation operator [](int index) => _values[index]!;
@override
void operator []=(int index, Animation value) => _values[index] = value;

View File

@ -3,8 +3,8 @@ import 'package:rive/src/rive_core/component.dart';
// TODO: figure out how to make this cleaner.
class ContainerChildren extends ListBase<Component> {
final List<Component> _values = [];
List<Component> get values => _values;
final List<Component?> _values = [];
List<Component> get values => _values.cast<Component>();
@override
int get length => _values.length;
@ -13,7 +13,7 @@ class ContainerChildren extends ListBase<Component> {
set length(int value) => _values.length = value;
@override
Component operator [](int index) => _values[index];
Component operator [](int index) => _values[index]!;
@override
void operator []=(int index, Component value) => _values[index] = value;

View File

@ -1,43 +1,37 @@
import 'package:rive/src/rive_core/animation/linear_animation.dart';
import 'package:rive/src/extensions.dart';
import 'package:rive/src/rive_core/animation/linear_animation_instance.dart';
import 'package:rive/src/rive_core/rive_animation_controller.dart';
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 +41,20 @@ 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) {
_instance = artboard.animationByName(animationName);
isActive = true;
return _instance != null;
}
@override
void onActivate() {
// We override onActivate to reset stopOnNextApply. This ensures that when

View File

@ -1,29 +1,111 @@
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';
export 'package:rive/src/container_children.dart';
export 'package:rive/src/runtime_artboard.dart';
export 'package:rive/src/generated/rive_core_context.dart';
export 'package:rive/src/core/importers/artboard_importer.dart';
export 'package:rive/src/core/importers/linear_animation_importer.dart';
export 'package:rive/src/core/importers/keyed_object_importer.dart';
export 'package:rive/src/core/importers/keyed_property_importer.dart';
export 'package:rive/src/core/importers/state_machine_importer.dart';
export 'package:rive/src/core/importers/state_machine_layer_importer.dart';
export 'package:rive/src/core/importers/layer_state_importer.dart';
export 'package:rive/src/core/importers/state_transition_importer.dart';
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 onRemoved();
void onAdded() {}
void onRemoved() {}
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);
T addObject<T extends Core>(T object);
T? addObject<T extends Core>(T? object);
void markNeedsAdvance();
void dirty(void Function() dirt);
}
// ignore: one_member_abstracts
abstract class ImportStackObject {
bool resolve();
}
/// Stack to help the RiveFile locate latest ImportStackObject created of a
/// certain type.
class ImportStack {
final _latests = HashMap<int, ImportStackObject>();
T? latest<T extends ImportStackObject>(int coreType) {
var latest = _latests[coreType];
if (latest is T) {
return latest;
}
return null;
}
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()) {
return false;
}
}
if (importObject != null) {
_latests[coreType] = importObject;
} else {
_latests.remove(coreType);
}
return true;
}
bool resolve() {
for (final object in _latests.values) {
if (!object.resolve()) {
return false;
}
}
return true;
}
}

View File

@ -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);
}

View File

@ -0,0 +1,44 @@
import 'package:rive/rive.dart';
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/animation.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart';
import 'package:rive/src/rive_core/component.dart';
class ArtboardImporter extends ImportStackObject {
final RuntimeArtboard artboard;
ArtboardImporter(this.artboard);
final List<LinearAnimation> animations = [];
void addComponent(Core<CoreContext>? object) => artboard.addObject(object);
void addAnimation(Animation animation) {
if (animation is LinearAnimation) {
animations.add(animation);
}
artboard.addObject(animation);
animation.artboard = artboard;
}
void addStateMachine(StateMachine animation) => addAnimation(animation);
@override
bool resolve() {
for (final object in artboard.objects.skip(1)) {
if (object is Component &&
object.parentId == ComponentBase.parentIdInitialValue) {
object.parent = artboard;
}
object?.onAddedDirty();
}
assert(!artboard.children.contains(artboard),
'artboard should never contain itself as a child');
for (final object in artboard.objects.toList(growable: false)) {
if (object == null) {
continue;
}
object.onAdded();
}
artboard.clean();
return true;
}
}

View File

@ -0,0 +1,17 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/keyed_object.dart';
import 'package:rive/src/rive_core/animation/keyed_property.dart';
class KeyedObjectImporter extends ImportStackObject {
final KeyedObject keyedObject;
KeyedObjectImporter(this.keyedObject);
void addKeyedProperty(KeyedProperty property) {
keyedObject.context.addObject(property);
keyedObject.internalAddKeyedProperty(property);
}
@override
bool resolve() => true;
}

View File

@ -0,0 +1,20 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/keyed_property.dart';
import 'package:rive/src/rive_core/animation/keyframe.dart';
import 'package:rive/src/rive_core/animation/linear_animation.dart';
class KeyedPropertyImporter extends ImportStackObject {
final KeyedProperty keyedProperty;
final LinearAnimation animation;
KeyedPropertyImporter(this.keyedProperty, this.animation);
void addKeyFrame(KeyFrame keyFrame) {
keyedProperty.context.addObject(keyFrame);
keyedProperty.internalAddKeyFrame(keyFrame);
keyFrame.computeSeconds(animation);
}
@override
bool resolve() => true;
}

View File

@ -0,0 +1,16 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/layer_state.dart';
import 'package:rive/src/rive_core/animation/state_transition.dart';
class LayerStateImporter extends ImportStackObject {
final LayerState state;
LayerStateImporter(this.state);
void addTransition(StateTransition transition) {
state.context.addObject(transition);
state.internalAddTransition(transition);
}
@override
bool resolve() => true;
}

View File

@ -0,0 +1,25 @@
import 'package:rive/rive.dart';
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/keyed_object.dart';
class LinearAnimationImporter extends ImportStackObject {
final LinearAnimation linearAnimation;
// final keyedObjects = <KeyedObject>[];
LinearAnimationImporter(this.linearAnimation);
void addKeyedObject(KeyedObject object) {
linearAnimation.context.addObject(object);
// keyedObjects.add(object);
linearAnimation.internalAddKeyedObject(object);
}
@override
bool resolve() {
// for (final keyedObject in keyedObjects) {
// keyedObject.objectId ??= linearAnimation.artboard.id;
// }
return true;
}
}

View File

@ -0,0 +1,16 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart';
import 'package:rive/src/rive_core/animation/state_machine_component.dart';
class StateMachineImporter extends ImportStackObject {
final StateMachine machine;
StateMachineImporter(this.machine);
void addMachineComponent(StateMachineComponent object) {
machine.context.addObject(object);
object.stateMachine = machine;
}
@override
bool resolve() => true;
}

View File

@ -0,0 +1,45 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/animation_state.dart';
import 'package:rive/src/rive_core/animation/layer_state.dart';
import 'package:rive/src/rive_core/animation/state_machine_layer.dart';
class StateMachineLayerImporter extends ImportStackObject {
final StateMachineLayer layer;
final ArtboardImporter artboardImporter;
StateMachineLayerImporter(this.layer, this.artboardImporter);
final List<LayerState> importedStates = [];
void addState(LayerState state) {
importedStates.add(state);
// Here the state gets assigned a core (artboard) id.
layer.context.addObject(state);
layer.internalAddState(state);
}
bool _resolved = false;
@override
bool resolve() {
assert(!_resolved);
_resolved = true;
for (final state in importedStates) {
if (state is AnimationState) {
int artboardAnimationIndex = state.animationId;
assert(artboardAnimationIndex >= 0 &&
artboardAnimationIndex < artboardImporter.animations.length);
state.animation = artboardImporter.animations[artboardAnimationIndex];
}
for (final transition in state.transitions) {
// At import time the stateToId is an index relative to the entire layer
// (which state in this layer). We can use that to find the matching
// importedState and assign back the core id that will resolve after the
// entire artboard imports.
assert(transition.stateToId >= 0 &&
transition.stateToId < importedStates.length);
// transition.stateToId = importedStates[transition.stateToId].id;
transition.stateTo = importedStates[transition.stateToId];
}
}
return true;
}
}

View File

@ -0,0 +1,25 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/state_transition.dart';
import 'package:rive/src/rive_core/animation/transition_condition.dart';
class StateTransitionImporter extends ImportStackObject {
final StateMachineImporter stateMachineImporter;
final StateTransition transition;
StateTransitionImporter(this.transition, this.stateMachineImporter);
void addCondition(TransitionCondition condition) {
transition.context.addObject(condition);
transition.internalAddCondition(condition);
}
@override
bool resolve() {
var inputs = stateMachineImporter.machine.inputs;
for (final condition in transition.conditions) {
var inputIndex = condition.inputId;
assert(inputIndex >= 0 && inputIndex < inputs.length);
condition.inputId = inputs[inputIndex].id;
}
return true;
}
}

View File

@ -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);
}

View File

@ -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.
@ -27,7 +28,9 @@ abstract class AnimationBase<T extends CoreContext> extends Core<T> {
}
String from = _name;
_name = value;
nameChanged(from, value);
if (hasValidated) {
nameChanged(from, value);
}
}
void nameChanged(String from, String to);

View File

@ -0,0 +1,44 @@
/// Core automatically generated
/// lib/src/generated/animation/animation_state_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/layer_state_base.dart';
import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
import 'package:rive/src/rive_core/animation/layer_state.dart';
abstract class AnimationStateBase extends LayerState {
static const int typeKey = 61;
@override
int get coreType => AnimationStateBase.typeKey;
@override
Set<int> get coreTypes => {
AnimationStateBase.typeKey,
LayerStateBase.typeKey,
StateMachineLayerComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// AnimationId field with key 149.
static const int animationIdInitialValue = -1;
int _animationId = animationIdInitialValue;
static const int animationIdPropertyKey = 149;
/// Id of the animation this layer state refers to.
int get animationId => _animationId;
/// Change the [_animationId] field value.
/// [animationIdChanged] will be invoked only if the field's value has
/// changed.
set animationId(int value) {
if (_animationId == value) {
return;
}
int from = _animationId;
_animationId = value;
if (hasValidated) {
animationIdChanged(from, value);
}
}
void animationIdChanged(int from, int to);
}

View File

@ -0,0 +1,19 @@
/// Core automatically generated
/// lib/src/generated/animation/any_state_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/layer_state_base.dart';
import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
import 'package:rive/src/rive_core/animation/layer_state.dart';
abstract class AnyStateBase extends LayerState {
static const int typeKey = 62;
@override
int get coreType => AnyStateBase.typeKey;
@override
Set<int> get coreTypes => {
AnyStateBase.typeKey,
LayerStateBase.typeKey,
StateMachineLayerComponentBase.typeKey
};
}

View File

@ -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;
@ -25,14 +26,17 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
}
double from = _x1;
_x1 = value;
x1Changed(from, value);
if (hasValidated) {
x1Changed(from, value);
}
}
void x1Changed(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -44,14 +48,17 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
}
double from = _y1;
_y1 = value;
y1Changed(from, value);
if (hasValidated) {
y1Changed(from, value);
}
}
void y1Changed(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -63,14 +70,17 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
}
double from = _x2;
_x2 = value;
x2Changed(from, value);
if (hasValidated) {
x2Changed(from, value);
}
}
void x2Changed(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -82,7 +92,9 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
}
double from = _y2;
_y2 = value;
y2Changed(from, value);
if (hasValidated) {
y2Changed(from, value);
}
}
void y2Changed(double from, double to);

View File

@ -0,0 +1,19 @@
/// Core automatically generated
/// lib/src/generated/animation/entry_state_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/layer_state_base.dart';
import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
import 'package:rive/src/rive_core/animation/layer_state.dart';
abstract class EntryStateBase extends LayerState {
static const int typeKey = 63;
@override
int get coreType => EntryStateBase.typeKey;
@override
Set<int> get coreTypes => {
EntryStateBase.typeKey,
LayerStateBase.typeKey,
StateMachineLayerComponentBase.typeKey
};
}

View File

@ -0,0 +1,19 @@
/// Core automatically generated
/// lib/src/generated/animation/exit_state_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/layer_state_base.dart';
import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
import 'package:rive/src/rive_core/animation/layer_state.dart';
abstract class ExitStateBase extends LayerState {
static const int typeKey = 64;
@override
int get coreType => ExitStateBase.typeKey;
@override
Set<int> get coreTypes => {
ExitStateBase.typeKey,
LayerStateBase.typeKey,
StateMachineLayerComponentBase.typeKey
};
}

View File

@ -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.
@ -27,7 +28,9 @@ abstract class KeyedObjectBase<T extends CoreContext> extends Core<T> {
}
int from = _objectId;
_objectId = value;
objectIdChanged(from, value);
if (hasValidated) {
objectIdChanged(from, value);
}
}
void objectIdChanged(int from, int to);

View File

@ -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.
@ -28,7 +29,9 @@ abstract class KeyedPropertyBase<T extends CoreContext> extends Core<T> {
}
int from = _propertyKey;
_propertyKey = value;
propertyKeyChanged(from, value);
if (hasValidated) {
propertyKeyChanged(from, value);
}
}
void propertyKeyChanged(int from, int to);

View File

@ -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
@ -27,14 +28,17 @@ abstract class KeyFrameBase<T extends CoreContext> extends Core<T> {
}
int from = _frame;
_frame = value;
frameChanged(from, value);
if (hasValidated) {
frameChanged(from, value);
}
}
void frameChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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
@ -50,14 +54,17 @@ abstract class KeyFrameBase<T extends CoreContext> extends Core<T> {
}
int from = _interpolationType;
_interpolationType = value;
interpolationTypeChanged(from, value);
if (hasValidated) {
interpolationTypeChanged(from, value);
}
}
void interpolationTypeChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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.
@ -72,7 +79,9 @@ abstract class KeyFrameBase<T extends CoreContext> extends Core<T> {
}
int from = _interpolatorId;
_interpolatorId = value;
interpolatorIdChanged(from, value);
if (hasValidated) {
interpolatorIdChanged(from, value);
}
}
void interpolatorIdChanged(int from, int to);

View File

@ -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;
@ -26,7 +27,9 @@ abstract class KeyFrameColorBase extends KeyFrame {
}
int from = _value;
_value = value;
valueChanged(from, value);
if (hasValidated) {
valueChanged(from, value);
}
}
void valueChanged(int from, int to);

View File

@ -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;
@ -26,7 +27,9 @@ abstract class KeyFrameDoubleBase extends KeyFrame {
}
double from = _value;
_value = value;
valueChanged(from, value);
if (hasValidated) {
valueChanged(from, value);
}
}
void valueChanged(double from, double to);

View File

@ -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};
}

View File

@ -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);
}

View File

@ -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;
@ -26,7 +27,9 @@ abstract class KeyFrameIdBase extends KeyFrame {
}
int from = _value;
_value = value;
valueChanged(from, value);
if (hasValidated) {
valueChanged(from, value);
}
}
void valueChanged(int from, int to);

View File

@ -0,0 +1,15 @@
/// Core automatically generated
/// lib/src/generated/animation/layer_state_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_layer_component.dart';
abstract class LayerStateBase extends StateMachineLayerComponent {
static const int typeKey = 60;
@override
int get coreType => LayerStateBase.typeKey;
@override
Set<int> get coreTypes =>
{LayerStateBase.typeKey, StateMachineLayerComponentBase.typeKey};
}

View File

@ -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
@ -30,14 +31,17 @@ abstract class LinearAnimationBase extends Animation {
}
int from = _fps;
_fps = value;
fpsChanged(from, value);
if (hasValidated) {
fpsChanged(from, value);
}
}
void fpsChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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.
@ -51,14 +55,17 @@ abstract class LinearAnimationBase extends Animation {
}
int from = _duration;
_duration = value;
durationChanged(from, value);
if (hasValidated) {
durationChanged(from, value);
}
}
void durationChanged(int from, int to);
/// --------------------------------------------------------------------------
/// Speed field with key 58.
double _speed = 1;
static const double speedInitialValue = 1;
double _speed = speedInitialValue;
static const int speedPropertyKey = 58;
/// Playback speed multiplier.
@ -72,14 +79,17 @@ abstract class LinearAnimationBase extends Animation {
}
double from = _speed;
_speed = value;
speedChanged(from, value);
if (hasValidated) {
speedChanged(from, value);
}
}
void speedChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -93,14 +103,17 @@ abstract class LinearAnimationBase extends Animation {
}
int from = _loopValue;
_loopValue = value;
loopValueChanged(from, value);
if (hasValidated) {
loopValueChanged(from, value);
}
}
void loopValueChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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.
@ -114,14 +127,17 @@ abstract class LinearAnimationBase extends Animation {
}
int from = _workStart;
_workStart = value;
workStartChanged(from, value);
if (hasValidated) {
workStartChanged(from, value);
}
}
void workStartChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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.
@ -135,14 +151,17 @@ abstract class LinearAnimationBase extends Animation {
}
int from = _workEnd;
_workEnd = value;
workEndChanged(from, value);
if (hasValidated) {
workEndChanged(from, value);
}
}
void workEndChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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.
@ -157,7 +176,9 @@ abstract class LinearAnimationBase extends Animation {
}
bool from = _enableWorkArea;
_enableWorkArea = value;
enableWorkAreaChanged(from, value);
if (hasValidated) {
enableWorkAreaChanged(from, value);
}
}
void enableWorkAreaChanged(bool from, bool to);

View File

@ -0,0 +1,14 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/animation_base.dart';
import 'package:rive/src/rive_core/animation/animation.dart';
abstract class StateMachineBase extends Animation {
static const int typeKey = 53;
@override
int get coreType => StateMachineBase.typeKey;
@override
Set<int> get coreTypes => {StateMachineBase.typeKey, AnimationBase.typeKey};
}

View File

@ -0,0 +1,41 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_bool_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/state_machine_component_base.dart';
import 'package:rive/src/generated/animation/state_machine_input_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_input.dart';
abstract class StateMachineBoolBase extends StateMachineInput {
static const int typeKey = 59;
@override
int get coreType => StateMachineBoolBase.typeKey;
@override
Set<int> get coreTypes => {
StateMachineBoolBase.typeKey,
StateMachineInputBase.typeKey,
StateMachineComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// Value field with key 141.
static const bool valueInitialValue = false;
bool _value = valueInitialValue;
static const int valuePropertyKey = 141;
bool get value => _value;
/// Change the [_value] field value.
/// [valueChanged] will be invoked only if the field's value has changed.
set value(bool value) {
if (_value == value) {
return;
}
bool from = _value;
_value = value;
if (hasValidated) {
valueChanged(from, value);
}
}
void valueChanged(bool from, bool to);
}

View File

@ -0,0 +1,39 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_component_base.dart.
/// Do not modify manually.
import 'package:rive/src/core/core.dart';
abstract class StateMachineComponentBase<T extends CoreContext>
extends Core<T> {
static const int typeKey = 54;
@override
int get coreType => StateMachineComponentBase.typeKey;
@override
Set<int> get coreTypes => {StateMachineComponentBase.typeKey};
/// --------------------------------------------------------------------------
/// Name field with key 138.
static const String nameInitialValue = '';
String _name = nameInitialValue;
static const int namePropertyKey = 138;
/// Non-unique identifier, used to give friendly names to state machine
/// components (like layers or inputs).
String get name => _name;
/// Change the [_name] field value.
/// [nameChanged] will be invoked only if the field's value has changed.
set name(String value) {
if (_name == value) {
return;
}
String from = _name;
_name = value;
if (hasValidated) {
nameChanged(from, value);
}
}
void nameChanged(String from, String to);
}

View File

@ -0,0 +1,41 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_double_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/state_machine_component_base.dart';
import 'package:rive/src/generated/animation/state_machine_input_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_input.dart';
abstract class StateMachineDoubleBase extends StateMachineInput {
static const int typeKey = 56;
@override
int get coreType => StateMachineDoubleBase.typeKey;
@override
Set<int> get coreTypes => {
StateMachineDoubleBase.typeKey,
StateMachineInputBase.typeKey,
StateMachineComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// Value field with key 140.
static const double valueInitialValue = 0;
double _value = valueInitialValue;
static const int valuePropertyKey = 140;
double get value => _value;
/// Change the [_value] field value.
/// [valueChanged] will be invoked only if the field's value has changed.
set value(double value) {
if (_value == value) {
return;
}
double from = _value;
_value = value;
if (hasValidated) {
valueChanged(from, value);
}
}
void valueChanged(double from, double to);
}

View File

@ -0,0 +1,15 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_input_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/state_machine_component_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_component.dart';
abstract class StateMachineInputBase extends StateMachineComponent {
static const int typeKey = 55;
@override
int get coreType => StateMachineInputBase.typeKey;
@override
Set<int> get coreTypes =>
{StateMachineInputBase.typeKey, StateMachineComponentBase.typeKey};
}

View File

@ -0,0 +1,15 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_layer_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/state_machine_component_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_component.dart';
abstract class StateMachineLayerBase extends StateMachineComponent {
static const int typeKey = 57;
@override
int get coreType => StateMachineLayerBase.typeKey;
@override
Set<int> get coreTypes =>
{StateMachineLayerBase.typeKey, StateMachineComponentBase.typeKey};
}

View File

@ -0,0 +1,14 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_layer_component_base.dart.
/// Do not modify manually.
import 'package:rive/src/core/core.dart';
abstract class StateMachineLayerComponentBase<T extends CoreContext>
extends Core<T> {
static const int typeKey = 66;
@override
int get coreType => StateMachineLayerComponentBase.typeKey;
@override
Set<int> get coreTypes => {StateMachineLayerComponentBase.typeKey};
}

View File

@ -0,0 +1,19 @@
/// Core automatically generated
/// lib/src/generated/animation/state_machine_trigger_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/state_machine_component_base.dart';
import 'package:rive/src/generated/animation/state_machine_input_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_input.dart';
abstract class StateMachineTriggerBase extends StateMachineInput {
static const int typeKey = 58;
@override
int get coreType => StateMachineTriggerBase.typeKey;
@override
Set<int> get coreTypes => {
StateMachineTriggerBase.typeKey,
StateMachineInputBase.typeKey,
StateMachineComponentBase.typeKey
};
}

View File

@ -0,0 +1,85 @@
/// Core automatically generated
/// lib/src/generated/animation/state_transition_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/state_machine_layer_component_base.dart';
import 'package:rive/src/rive_core/animation/state_machine_layer_component.dart';
abstract class StateTransitionBase extends StateMachineLayerComponent {
static const int typeKey = 65;
@override
int get coreType => StateTransitionBase.typeKey;
@override
Set<int> get coreTypes =>
{StateTransitionBase.typeKey, StateMachineLayerComponentBase.typeKey};
/// --------------------------------------------------------------------------
/// StateToId field with key 151.
static const int stateToIdInitialValue = -1;
int _stateToId = stateToIdInitialValue;
static const int stateToIdPropertyKey = 151;
/// Id of the state this transition originates from.
int get stateToId => _stateToId;
/// Change the [_stateToId] field value.
/// [stateToIdChanged] will be invoked only if the field's value has changed.
set stateToId(int value) {
if (_stateToId == value) {
return;
}
int from = _stateToId;
_stateToId = value;
if (hasValidated) {
stateToIdChanged(from, value);
}
}
void stateToIdChanged(int from, int to);
/// --------------------------------------------------------------------------
/// Flags field with key 152.
static const int flagsInitialValue = 0;
int _flags = flagsInitialValue;
static const int flagsPropertyKey = 152;
int get flags => _flags;
/// Change the [_flags] field value.
/// [flagsChanged] will be invoked only if the field's value has changed.
set flags(int value) {
if (_flags == value) {
return;
}
int from = _flags;
_flags = value;
if (hasValidated) {
flagsChanged(from, value);
}
}
void flagsChanged(int from, int to);
/// --------------------------------------------------------------------------
/// Duration field with key 158.
static const int durationInitialValue = 0;
int _duration = durationInitialValue;
static const int durationPropertyKey = 158;
/// Duration of the trasition (mix time) in milliseconds.
int get duration => _duration;
/// Change the [_duration] field value.
/// [durationChanged] will be invoked only if the field's value has changed.
set duration(int value) {
if (_duration == value) {
return;
}
int from = _duration;
_duration = value;
if (hasValidated) {
durationChanged(from, value);
}
}
void durationChanged(int from, int to);
}

View File

@ -0,0 +1,19 @@
/// Core automatically generated
/// lib/src/generated/animation/transition_bool_condition_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/transition_condition_base.dart';
import 'package:rive/src/generated/animation/transition_value_condition_base.dart';
import 'package:rive/src/rive_core/animation/transition_value_condition.dart';
abstract class TransitionBoolConditionBase extends TransitionValueCondition {
static const int typeKey = 71;
@override
int get coreType => TransitionBoolConditionBase.typeKey;
@override
Set<int> get coreTypes => {
TransitionBoolConditionBase.typeKey,
TransitionValueConditionBase.typeKey,
TransitionConditionBase.typeKey
};
}

View File

@ -0,0 +1,37 @@
/// Core automatically generated
/// lib/src/generated/animation/transition_condition_base.dart.
/// Do not modify manually.
import 'package:rive/src/core/core.dart';
abstract class TransitionConditionBase<T extends CoreContext> extends Core<T> {
static const int typeKey = 67;
@override
int get coreType => TransitionConditionBase.typeKey;
@override
Set<int> get coreTypes => {TransitionConditionBase.typeKey};
/// --------------------------------------------------------------------------
/// InputId field with key 155.
static const int inputIdInitialValue = -1;
int _inputId = inputIdInitialValue;
static const int inputIdPropertyKey = 155;
/// Id of the StateMachineInput referenced.
int get inputId => _inputId;
/// Change the [_inputId] field value.
/// [inputIdChanged] will be invoked only if the field's value has changed.
set inputId(int value) {
if (_inputId == value) {
return;
}
int from = _inputId;
_inputId = value;
if (hasValidated) {
inputIdChanged(from, value);
}
}
void inputIdChanged(int from, int to);
}

View File

@ -0,0 +1,41 @@
/// Core automatically generated
/// lib/src/generated/animation/transition_double_condition_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/transition_condition_base.dart';
import 'package:rive/src/generated/animation/transition_value_condition_base.dart';
import 'package:rive/src/rive_core/animation/transition_value_condition.dart';
abstract class TransitionDoubleConditionBase extends TransitionValueCondition {
static const int typeKey = 70;
@override
int get coreType => TransitionDoubleConditionBase.typeKey;
@override
Set<int> get coreTypes => {
TransitionDoubleConditionBase.typeKey,
TransitionValueConditionBase.typeKey,
TransitionConditionBase.typeKey
};
/// --------------------------------------------------------------------------
/// Value field with key 157.
static const double valueInitialValue = 0;
double _value = valueInitialValue;
static const int valuePropertyKey = 157;
double get value => _value;
/// Change the [_value] field value.
/// [valueChanged] will be invoked only if the field's value has changed.
set value(double value) {
if (_value == value) {
return;
}
double from = _value;
_value = value;
if (hasValidated) {
valueChanged(from, value);
}
}
void valueChanged(double from, double to);
}

View File

@ -0,0 +1,15 @@
/// Core automatically generated
/// lib/src/generated/animation/transition_trigger_condition_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/transition_condition_base.dart';
import 'package:rive/src/rive_core/animation/transition_condition.dart';
abstract class TransitionTriggerConditionBase extends TransitionCondition {
static const int typeKey = 68;
@override
int get coreType => TransitionTriggerConditionBase.typeKey;
@override
Set<int> get coreTypes =>
{TransitionTriggerConditionBase.typeKey, TransitionConditionBase.typeKey};
}

View File

@ -0,0 +1,39 @@
/// Core automatically generated
/// lib/src/generated/animation/transition_value_condition_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/transition_condition_base.dart';
import 'package:rive/src/rive_core/animation/transition_condition.dart';
abstract class TransitionValueConditionBase extends TransitionCondition {
static const int typeKey = 69;
@override
int get coreType => TransitionValueConditionBase.typeKey;
@override
Set<int> get coreTypes =>
{TransitionValueConditionBase.typeKey, TransitionConditionBase.typeKey};
/// --------------------------------------------------------------------------
/// OpValue field with key 156.
static const int opValueInitialValue = 0;
int _opValue = opValueInitialValue;
static const int opValuePropertyKey = 156;
/// Integer representation of the StateMachineOp enum.
int get opValue => _opValue;
/// Change the [_opValue] field value.
/// [opValueChanged] will be invoked only if the field's value has changed.
set opValue(int value) {
if (_opValue == value) {
return;
}
int from = _opValue;
_opValue = value;
if (hasValidated) {
opValueChanged(from, value);
}
}
void opValueChanged(int from, int to);
}

View File

@ -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.
@ -32,14 +33,17 @@ abstract class ArtboardBase extends ContainerComponent {
}
double from = _width;
_width = value;
widthChanged(from, value);
if (hasValidated) {
widthChanged(from, value);
}
}
void widthChanged(double from, double to);
/// --------------------------------------------------------------------------
/// Height field with key 8.
double _height;
static const double heightInitialValue = 0;
double _height = heightInitialValue;
static const int heightPropertyKey = 8;
/// Height of the artboard.
@ -53,14 +57,17 @@ abstract class ArtboardBase extends ContainerComponent {
}
double from = _height;
_height = value;
heightChanged(from, value);
if (hasValidated) {
heightChanged(from, value);
}
}
void heightChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -74,14 +81,17 @@ abstract class ArtboardBase extends ContainerComponent {
}
double from = _x;
_x = value;
xChanged(from, value);
if (hasValidated) {
xChanged(from, value);
}
}
void xChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -95,14 +105,17 @@ abstract class ArtboardBase extends ContainerComponent {
}
double from = _y;
_y = value;
yChanged(from, value);
if (hasValidated) {
yChanged(from, value);
}
}
void yChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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).
@ -116,14 +129,17 @@ abstract class ArtboardBase extends ContainerComponent {
}
double from = _originX;
_originX = value;
originXChanged(from, value);
if (hasValidated) {
originXChanged(from, value);
}
}
void originXChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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).
@ -137,7 +153,9 @@ abstract class ArtboardBase extends ContainerComponent {
}
double from = _originY;
_originY = value;
originYChanged(from, value);
if (hasValidated) {
originYChanged(from, value);
}
}
void originYChanged(double from, double to);

View File

@ -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;
@ -34,7 +35,9 @@ abstract class BoneBase extends SkeletalComponent {
}
double from = _length;
_length = value;
lengthChanged(from, value);
if (hasValidated) {
lengthChanged(from, value);
}
}
void lengthChanged(double from, double to);

View File

@ -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;
@ -27,14 +28,17 @@ abstract class CubicWeightBase extends Weight {
}
int from = _inValues;
_inValues = value;
inValuesChanged(from, value);
if (hasValidated) {
inValuesChanged(from, value);
}
}
void inValuesChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -46,14 +50,17 @@ abstract class CubicWeightBase extends Weight {
}
int from = _inIndices;
_inIndices = value;
inIndicesChanged(from, value);
if (hasValidated) {
inIndicesChanged(from, value);
}
}
void inIndicesChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -65,14 +72,17 @@ abstract class CubicWeightBase extends Weight {
}
int from = _outValues;
_outValues = value;
outValuesChanged(from, value);
if (hasValidated) {
outValuesChanged(from, value);
}
}
void outValuesChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -84,7 +94,9 @@ abstract class CubicWeightBase extends Weight {
}
int from = _outIndices;
_outIndices = value;
outIndicesChanged(from, value);
if (hasValidated) {
outIndicesChanged(from, value);
}
}
void outIndicesChanged(int from, int to);

View File

@ -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;
@ -38,14 +39,17 @@ abstract class RootBoneBase extends Bone {
}
double from = _x;
_x = value;
xChanged(from, value);
if (hasValidated) {
xChanged(from, value);
}
}
void xChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -59,7 +63,9 @@ abstract class RootBoneBase extends Bone {
}
double from = _y;
_y = value;
yChanged(from, value);
if (hasValidated) {
yChanged(from, value);
}
}
void yChanged(double from, double to);

View File

@ -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
@ -29,14 +30,17 @@ abstract class SkinBase extends ContainerComponent {
}
double from = _xx;
_xx = value;
xxChanged(from, value);
if (hasValidated) {
xxChanged(from, value);
}
}
void xxChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -50,14 +54,17 @@ abstract class SkinBase extends ContainerComponent {
}
double from = _yx;
_yx = value;
yxChanged(from, value);
if (hasValidated) {
yxChanged(from, value);
}
}
void yxChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -71,14 +78,17 @@ abstract class SkinBase extends ContainerComponent {
}
double from = _xy;
_xy = value;
xyChanged(from, value);
if (hasValidated) {
xyChanged(from, value);
}
}
void xyChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -92,14 +102,17 @@ abstract class SkinBase extends ContainerComponent {
}
double from = _yy;
_yy = value;
yyChanged(from, value);
if (hasValidated) {
yyChanged(from, value);
}
}
void yyChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -113,14 +126,17 @@ abstract class SkinBase extends ContainerComponent {
}
double from = _tx;
_tx = value;
txChanged(from, value);
if (hasValidated) {
txChanged(from, value);
}
}
void txChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -134,7 +150,9 @@ abstract class SkinBase extends ContainerComponent {
}
double from = _ty;
_ty = value;
tyChanged(from, value);
if (hasValidated) {
tyChanged(from, value);
}
}
void tyChanged(double from, double to);

View File

@ -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.
@ -27,14 +28,17 @@ abstract class TendonBase extends Component {
}
int from = _boneId;
_boneId = value;
boneIdChanged(from, value);
if (hasValidated) {
boneIdChanged(from, value);
}
}
void boneIdChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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
@ -48,14 +52,17 @@ abstract class TendonBase extends Component {
}
double from = _xx;
_xx = value;
xxChanged(from, value);
if (hasValidated) {
xxChanged(from, value);
}
}
void xxChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -69,14 +76,17 @@ abstract class TendonBase extends Component {
}
double from = _yx;
_yx = value;
yxChanged(from, value);
if (hasValidated) {
yxChanged(from, value);
}
}
void yxChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -90,14 +100,17 @@ abstract class TendonBase extends Component {
}
double from = _xy;
_xy = value;
xyChanged(from, value);
if (hasValidated) {
xyChanged(from, value);
}
}
void xyChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -111,14 +124,17 @@ abstract class TendonBase extends Component {
}
double from = _yy;
_yy = value;
yyChanged(from, value);
if (hasValidated) {
yyChanged(from, value);
}
}
void yyChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -132,14 +148,17 @@ abstract class TendonBase extends Component {
}
double from = _tx;
_tx = value;
txChanged(from, value);
if (hasValidated) {
txChanged(from, value);
}
}
void txChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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
@ -153,7 +172,9 @@ abstract class TendonBase extends Component {
}
double from = _ty;
_ty = value;
tyChanged(from, value);
if (hasValidated) {
tyChanged(from, value);
}
}
void tyChanged(double from, double to);

View File

@ -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;
@ -25,14 +26,17 @@ abstract class WeightBase extends Component {
}
int from = _values;
_values = value;
valuesChanged(from, value);
if (hasValidated) {
valuesChanged(from, value);
}
}
void valuesChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -44,7 +48,9 @@ abstract class WeightBase extends Component {
}
int from = _indices;
_indices = value;
indicesChanged(from, value);
if (hasValidated) {
indicesChanged(from, value);
}
}
void indicesChanged(int from, int to);

View File

@ -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
@ -27,14 +28,17 @@ abstract class ComponentBase<T extends CoreContext> extends Core<T> {
}
String from = _name;
_name = value;
nameChanged(from, value);
if (hasValidated) {
nameChanged(from, value);
}
}
void nameChanged(String from, String to);
/// --------------------------------------------------------------------------
/// 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.
@ -48,7 +52,9 @@ abstract class ComponentBase<T extends CoreContext> extends Core<T> {
}
int from = _parentId;
_parentId = value;
parentIdChanged(from, value);
if (hasValidated) {
parentIdChanged(from, value);
}
}
void parentIdChanged(int from, int to);

View File

@ -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.
@ -33,7 +34,9 @@ abstract class DrawRulesBase extends ContainerComponent {
}
int from = _drawTargetId;
_drawTargetId = value;
drawTargetIdChanged(from, value);
if (hasValidated) {
drawTargetIdChanged(from, value);
}
}
void drawTargetIdChanged(int from, int to);

View File

@ -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.
@ -27,14 +28,17 @@ abstract class DrawTargetBase extends Component {
}
int from = _drawableId;
_drawableId = value;
drawableIdChanged(from, value);
if (hasValidated) {
drawableIdChanged(from, value);
}
}
void drawableIdChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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.
@ -49,7 +53,9 @@ abstract class DrawTargetBase extends Component {
}
int from = _placementValue;
_placementValue = value;
placementValueChanged(from, value);
if (hasValidated) {
placementValueChanged(from, value);
}
}
void placementValueChanged(int from, int to);

View File

@ -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;
@ -35,14 +36,17 @@ abstract class DrawableBase extends Node {
}
int from = _blendModeValue;
_blendModeValue = value;
blendModeValueChanged(from, value);
if (hasValidated) {
blendModeValueChanged(from, value);
}
}
void blendModeValueChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -55,7 +59,9 @@ abstract class DrawableBase extends Node {
}
int from = _drawableFlags;
_drawableFlags = value;
drawableFlagsChanged(from, value);
if (hasValidated) {
drawableFlagsChanged(from, value);
}
}
void drawableFlagsChanged(int from, int to);

View File

@ -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;
@ -34,14 +35,17 @@ abstract class NodeBase extends TransformComponent {
}
double from = _x;
_x = value;
xChanged(from, value);
if (hasValidated) {
xChanged(from, value);
}
}
void xChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -55,7 +59,9 @@ abstract class NodeBase extends TransformComponent {
}
double from = _y;
_y = value;
yChanged(from, value);
if (hasValidated) {
yChanged(from, value);
}
}
void yChanged(double from, double to);

View File

@ -6,7 +6,11 @@ import 'package:rive/src/core/field_types/core_field_type.dart';
import 'package:rive/src/core/field_types/core_string_type.dart';
import 'package:rive/src/core/field_types/core_uint_type.dart';
import 'package:rive/src/generated/animation/animation_base.dart';
import 'package:rive/src/generated/animation/animation_state_base.dart';
import 'package:rive/src/generated/animation/any_state_base.dart';
import 'package:rive/src/generated/animation/cubic_interpolator_base.dart';
import 'package:rive/src/generated/animation/entry_state_base.dart';
import 'package:rive/src/generated/animation/exit_state_base.dart';
import 'package:rive/src/generated/animation/keyed_object_base.dart';
import 'package:rive/src/generated/animation/keyed_property_base.dart';
import 'package:rive/src/generated/animation/keyframe_base.dart';
@ -14,6 +18,18 @@ import 'package:rive/src/generated/animation/keyframe_color_base.dart';
import 'package:rive/src/generated/animation/keyframe_double_base.dart';
import 'package:rive/src/generated/animation/keyframe_id_base.dart';
import 'package:rive/src/generated/animation/linear_animation_base.dart';
import 'package:rive/src/generated/animation/state_machine_base.dart';
import 'package:rive/src/generated/animation/state_machine_bool_base.dart';
import 'package:rive/src/generated/animation/state_machine_component_base.dart';
import 'package:rive/src/generated/animation/state_machine_double_base.dart';
import 'package:rive/src/generated/animation/state_machine_layer_base.dart';
import 'package:rive/src/generated/animation/state_machine_trigger_base.dart';
import 'package:rive/src/generated/animation/state_transition_base.dart';
import 'package:rive/src/generated/animation/transition_bool_condition_base.dart';
import 'package:rive/src/generated/animation/transition_condition_base.dart';
import 'package:rive/src/generated/animation/transition_double_condition_base.dart';
import 'package:rive/src/generated/animation/transition_trigger_condition_base.dart';
import 'package:rive/src/generated/animation/transition_value_condition_base.dart';
import 'package:rive/src/generated/artboard_base.dart';
import 'package:rive/src/generated/backboard_base.dart';
import 'package:rive/src/generated/bones/bone_base.dart';
@ -42,7 +58,6 @@ import 'package:rive/src/generated/shapes/paint/stroke_base.dart';
import 'package:rive/src/generated/shapes/paint/trim_path_base.dart';
import 'package:rive/src/generated/shapes/parametric_path_base.dart';
import 'package:rive/src/generated/shapes/path_base.dart';
import 'package:rive/src/generated/shapes/path_composer_base.dart';
import 'package:rive/src/generated/shapes/path_vertex_base.dart';
import 'package:rive/src/generated/shapes/points_path_base.dart';
import 'package:rive/src/generated/shapes/polygon_base.dart';
@ -53,13 +68,26 @@ import 'package:rive/src/generated/shapes/straight_vertex_base.dart';
import 'package:rive/src/generated/shapes/triangle_base.dart';
import 'package:rive/src/generated/transform_component_base.dart';
import 'package:rive/src/rive_core/animation/animation.dart';
import 'package:rive/src/rive_core/animation/animation_state.dart';
import 'package:rive/src/rive_core/animation/any_state.dart';
import 'package:rive/src/rive_core/animation/cubic_interpolator.dart';
import 'package:rive/src/rive_core/animation/entry_state.dart';
import 'package:rive/src/rive_core/animation/exit_state.dart';
import 'package:rive/src/rive_core/animation/keyed_object.dart';
import 'package:rive/src/rive_core/animation/keyed_property.dart';
import 'package:rive/src/rive_core/animation/keyframe_color.dart';
import 'package:rive/src/rive_core/animation/keyframe_double.dart';
import 'package:rive/src/rive_core/animation/keyframe_id.dart';
import 'package:rive/src/rive_core/animation/linear_animation.dart';
import 'package:rive/src/rive_core/animation/state_machine.dart';
import 'package:rive/src/rive_core/animation/state_machine_bool.dart';
import 'package:rive/src/rive_core/animation/state_machine_double.dart';
import 'package:rive/src/rive_core/animation/state_machine_layer.dart';
import 'package:rive/src/rive_core/animation/state_machine_trigger.dart';
import 'package:rive/src/rive_core/animation/state_transition.dart';
import 'package:rive/src/rive_core/animation/transition_bool_condition.dart';
import 'package:rive/src/rive_core/animation/transition_double_condition.dart';
import 'package:rive/src/rive_core/animation/transition_trigger_condition.dart';
import 'package:rive/src/rive_core/artboard.dart';
import 'package:rive/src/rive_core/backboard.dart';
import 'package:rive/src/rive_core/bones/bone.dart';
@ -83,7 +111,6 @@ import 'package:rive/src/rive_core/shapes/paint/radial_gradient.dart';
import 'package:rive/src/rive_core/shapes/paint/solid_color.dart';
import 'package:rive/src/rive_core/shapes/paint/stroke.dart';
import 'package:rive/src/rive_core/shapes/paint/trim_path.dart';
import 'package:rive/src/rive_core/shapes/path_composer.dart';
import 'package:rive/src/rive_core/shapes/points_path.dart';
import 'package:rive/src/rive_core/shapes/polygon.dart';
import 'package:rive/src/rive_core/shapes/rectangle.dart';
@ -94,26 +121,52 @@ 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();
case AnimationStateBase.typeKey:
return AnimationState();
case KeyedObjectBase.typeKey:
return KeyedObject();
case TransitionTriggerConditionBase.typeKey:
return TransitionTriggerCondition();
case KeyedPropertyBase.typeKey:
return KeyedProperty();
case StateMachineDoubleBase.typeKey:
return StateMachineDouble();
case KeyFrameIdBase.typeKey:
return KeyFrameId();
case AnyStateBase.typeKey:
return AnyState();
case StateMachineLayerBase.typeKey:
return StateMachineLayer();
case AnimationBase.typeKey:
return Animation();
case CubicInterpolatorBase.typeKey:
return CubicInterpolator();
case TransitionDoubleConditionBase.typeKey:
return TransitionDoubleCondition();
case StateTransitionBase.typeKey:
return StateTransition();
case KeyFrameDoubleBase.typeKey:
return KeyFrameDouble();
case KeyFrameColorBase.typeKey:
return KeyFrameColor();
case StateMachineBase.typeKey:
return StateMachine();
case EntryStateBase.typeKey:
return EntryState();
case LinearAnimationBase.typeKey:
return LinearAnimation();
case StateMachineTriggerBase.typeKey:
return StateMachineTrigger();
case ExitStateBase.typeKey:
return ExitState();
case TransitionBoolConditionBase.typeKey:
return TransitionBoolCondition();
case StateMachineBoolBase.typeKey:
return StateMachineBool();
case LinearGradientBase.typeKey:
return LinearGradient();
case RadialGradientBase.typeKey:
@ -156,8 +209,6 @@ class RiveCoreContext {
return Polygon();
case StarBase.typeKey:
return Star();
case PathComposerBase.typeKey:
return PathComposer();
case CubicDetachedVertexBase.typeKey:
return CubicDetachedVertex();
case DrawRulesBase.typeKey:
@ -182,12 +233,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:
@ -205,16 +252,36 @@ class RiveCoreContext {
object.placementValue = value;
}
break;
case AnimationStateBase.animationIdPropertyKey:
if (object is AnimationStateBase && value is int) {
object.animationId = value;
}
break;
case KeyedObjectBase.objectIdPropertyKey:
if (object is KeyedObjectBase && value is int) {
object.objectId = value;
}
break;
case TransitionConditionBase.inputIdPropertyKey:
if (object is TransitionConditionBase && value is int) {
object.inputId = value;
}
break;
case StateMachineComponentBase.namePropertyKey:
if (object is StateMachineComponentBase && value is String) {
object.name = value;
}
break;
case KeyedPropertyBase.propertyKeyPropertyKey:
if (object is KeyedPropertyBase && value is int) {
object.propertyKey = value;
}
break;
case StateMachineDoubleBase.valuePropertyKey:
if (object is StateMachineDoubleBase && value is double) {
object.value = value;
}
break;
case KeyFrameBase.framePropertyKey:
if (object is KeyFrameBase && value is int) {
object.frame = value;
@ -226,12 +293,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:
@ -264,6 +327,31 @@ class RiveCoreContext {
object.y2 = value;
}
break;
case TransitionValueConditionBase.opValuePropertyKey:
if (object is TransitionValueConditionBase && value is int) {
object.opValue = value;
}
break;
case TransitionDoubleConditionBase.valuePropertyKey:
if (object is TransitionDoubleConditionBase && value is double) {
object.value = value;
}
break;
case StateTransitionBase.stateToIdPropertyKey:
if (object is StateTransitionBase && value is int) {
object.stateToId = value;
}
break;
case StateTransitionBase.flagsPropertyKey:
if (object is StateTransitionBase && value is int) {
object.flags = value;
}
break;
case StateTransitionBase.durationPropertyKey:
if (object is StateTransitionBase && value is int) {
object.duration = value;
}
break;
case KeyFrameDoubleBase.valuePropertyKey:
if (object is KeyFrameDoubleBase && value is double) {
object.value = value;
@ -309,6 +397,11 @@ class RiveCoreContext {
object.enableWorkArea = value;
}
break;
case StateMachineBoolBase.valuePropertyKey:
if (object is StateMachineBoolBase && value is bool) {
object.value = value;
}
break;
case ShapePaintBase.isVisiblePropertyKey:
if (object is ShapePaintBase && value is bool) {
object.isVisible = value;
@ -717,20 +810,27 @@ 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:
case AnimationBase.namePropertyKey:
return stringType;
case ComponentBase.parentIdPropertyKey:
case DrawTargetBase.drawableIdPropertyKey:
case DrawTargetBase.placementValuePropertyKey:
case AnimationStateBase.animationIdPropertyKey:
case KeyedObjectBase.objectIdPropertyKey:
case TransitionConditionBase.inputIdPropertyKey:
case KeyedPropertyBase.propertyKeyPropertyKey:
case KeyFrameBase.framePropertyKey:
case KeyFrameBase.interpolationTypePropertyKey:
case KeyFrameBase.interpolatorIdPropertyKey:
case KeyFrameIdBase.valuePropertyKey:
case TransitionValueConditionBase.opValuePropertyKey:
case StateTransitionBase.stateToIdPropertyKey:
case StateTransitionBase.flagsPropertyKey:
case StateTransitionBase.durationPropertyKey:
case LinearAnimationBase.fpsPropertyKey:
case LinearAnimationBase.durationPropertyKey:
case LinearAnimationBase.loopValuePropertyKey:
@ -755,10 +855,12 @@ class RiveCoreContext {
case DrawRulesBase.drawTargetIdPropertyKey:
case TendonBase.boneIdPropertyKey:
return uintType;
case StateMachineDoubleBase.valuePropertyKey:
case CubicInterpolatorBase.x1PropertyKey:
case CubicInterpolatorBase.y1PropertyKey:
case CubicInterpolatorBase.x2PropertyKey:
case CubicInterpolatorBase.y2PropertyKey:
case TransitionDoubleConditionBase.valuePropertyKey:
case KeyFrameDoubleBase.valuePropertyKey:
case LinearAnimationBase.speedPropertyKey:
case LinearGradientBase.startXPropertyKey:
@ -823,6 +925,7 @@ class RiveCoreContext {
case GradientStopBase.colorValuePropertyKey:
return colorType;
case LinearAnimationBase.enableWorkAreaPropertyKey:
case StateMachineBoolBase.valuePropertyKey:
case ShapePaintBase.isVisiblePropertyKey:
case StrokeBase.transformAffectsStrokePropertyKey:
case PointsPathBase.isClosedPropertyKey:
@ -837,10 +940,12 @@ class RiveCoreContext {
switch (propertyKey) {
case ComponentBase.namePropertyKey:
return (object as ComponentBase).name;
case StateMachineComponentBase.namePropertyKey:
return (object as StateMachineComponentBase).name;
case AnimationBase.namePropertyKey:
return (object as AnimationBase).name;
}
return null;
return '';
}
static int getUint(Core object, int propertyKey) {
@ -851,8 +956,12 @@ class RiveCoreContext {
return (object as DrawTargetBase).drawableId;
case DrawTargetBase.placementValuePropertyKey:
return (object as DrawTargetBase).placementValue;
case AnimationStateBase.animationIdPropertyKey:
return (object as AnimationStateBase).animationId;
case KeyedObjectBase.objectIdPropertyKey:
return (object as KeyedObjectBase).objectId;
case TransitionConditionBase.inputIdPropertyKey:
return (object as TransitionConditionBase).inputId;
case KeyedPropertyBase.propertyKeyPropertyKey:
return (object as KeyedPropertyBase).propertyKey;
case KeyFrameBase.framePropertyKey:
@ -863,6 +972,14 @@ class RiveCoreContext {
return (object as KeyFrameBase).interpolatorId;
case KeyFrameIdBase.valuePropertyKey:
return (object as KeyFrameIdBase).value;
case TransitionValueConditionBase.opValuePropertyKey:
return (object as TransitionValueConditionBase).opValue;
case StateTransitionBase.stateToIdPropertyKey:
return (object as StateTransitionBase).stateToId;
case StateTransitionBase.flagsPropertyKey:
return (object as StateTransitionBase).flags;
case StateTransitionBase.durationPropertyKey:
return (object as StateTransitionBase).duration;
case LinearAnimationBase.fpsPropertyKey:
return (object as LinearAnimationBase).fps;
case LinearAnimationBase.durationPropertyKey:
@ -915,6 +1032,8 @@ class RiveCoreContext {
static double getDouble(Core object, int propertyKey) {
switch (propertyKey) {
case StateMachineDoubleBase.valuePropertyKey:
return (object as StateMachineDoubleBase).value;
case CubicInterpolatorBase.x1PropertyKey:
return (object as CubicInterpolatorBase).x1;
case CubicInterpolatorBase.y1PropertyKey:
@ -923,6 +1042,8 @@ class RiveCoreContext {
return (object as CubicInterpolatorBase).x2;
case CubicInterpolatorBase.y2PropertyKey:
return (object as CubicInterpolatorBase).y2;
case TransitionDoubleConditionBase.valuePropertyKey:
return (object as TransitionDoubleConditionBase).value;
case KeyFrameDoubleBase.valuePropertyKey:
return (object as KeyFrameDoubleBase).value;
case LinearAnimationBase.speedPropertyKey:
@ -1059,6 +1180,8 @@ class RiveCoreContext {
switch (propertyKey) {
case LinearAnimationBase.enableWorkAreaPropertyKey:
return (object as LinearAnimationBase).enableWorkArea;
case StateMachineBoolBase.valuePropertyKey:
return (object as StateMachineBoolBase).value;
case ShapePaintBase.isVisiblePropertyKey:
return (object as ShapePaintBase).isVisible;
case StrokeBase.transformAffectsStrokePropertyKey:
@ -1076,6 +1199,9 @@ class RiveCoreContext {
case ComponentBase.namePropertyKey:
(object as ComponentBase).name = value;
break;
case StateMachineComponentBase.namePropertyKey:
(object as StateMachineComponentBase).name = value;
break;
case AnimationBase.namePropertyKey:
(object as AnimationBase).name = value;
break;
@ -1093,9 +1219,15 @@ class RiveCoreContext {
case DrawTargetBase.placementValuePropertyKey:
(object as DrawTargetBase).placementValue = value;
break;
case AnimationStateBase.animationIdPropertyKey:
(object as AnimationStateBase).animationId = value;
break;
case KeyedObjectBase.objectIdPropertyKey:
(object as KeyedObjectBase).objectId = value;
break;
case TransitionConditionBase.inputIdPropertyKey:
(object as TransitionConditionBase).inputId = value;
break;
case KeyedPropertyBase.propertyKeyPropertyKey:
(object as KeyedPropertyBase).propertyKey = value;
break;
@ -1111,6 +1243,18 @@ class RiveCoreContext {
case KeyFrameIdBase.valuePropertyKey:
(object as KeyFrameIdBase).value = value;
break;
case TransitionValueConditionBase.opValuePropertyKey:
(object as TransitionValueConditionBase).opValue = value;
break;
case StateTransitionBase.stateToIdPropertyKey:
(object as StateTransitionBase).stateToId = value;
break;
case StateTransitionBase.flagsPropertyKey:
(object as StateTransitionBase).flags = value;
break;
case StateTransitionBase.durationPropertyKey:
(object as StateTransitionBase).duration = value;
break;
case LinearAnimationBase.fpsPropertyKey:
(object as LinearAnimationBase).fps = value;
break;
@ -1185,6 +1329,9 @@ class RiveCoreContext {
static void setDouble(Core object, int propertyKey, double value) {
switch (propertyKey) {
case StateMachineDoubleBase.valuePropertyKey:
(object as StateMachineDoubleBase).value = value;
break;
case CubicInterpolatorBase.x1PropertyKey:
(object as CubicInterpolatorBase).x1 = value;
break;
@ -1197,6 +1344,9 @@ class RiveCoreContext {
case CubicInterpolatorBase.y2PropertyKey:
(object as CubicInterpolatorBase).y2 = value;
break;
case TransitionDoubleConditionBase.valuePropertyKey:
(object as TransitionDoubleConditionBase).value = value;
break;
case KeyFrameDoubleBase.valuePropertyKey:
(object as KeyFrameDoubleBase).value = value;
break;
@ -1393,6 +1543,9 @@ class RiveCoreContext {
case LinearAnimationBase.enableWorkAreaPropertyKey:
(object as LinearAnimationBase).enableWorkArea = value;
break;
case StateMachineBoolBase.valuePropertyKey:
(object as StateMachineBoolBase).value = value;
break;
case ShapePaintBase.isVisiblePropertyKey:
(object as ShapePaintBase).isVisible = value;
break;

View File

@ -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.
@ -28,14 +29,17 @@ abstract class ClippingShapeBase extends Component {
}
int from = _sourceId;
_sourceId = value;
sourceIdChanged(from, value);
if (hasValidated) {
sourceIdChanged(from, value);
}
}
void sourceIdChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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).
@ -49,14 +53,17 @@ abstract class ClippingShapeBase extends Component {
}
int from = _fillRule;
_fillRule = value;
fillRuleChanged(from, value);
if (hasValidated) {
fillRuleChanged(from, value);
}
}
void fillRuleChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -68,7 +75,9 @@ abstract class ClippingShapeBase extends Component {
}
bool from = _isVisible;
_isVisible = value;
isVisibleChanged(from, value);
if (hasValidated) {
isVisibleChanged(from, value);
}
}
void isVisibleChanged(bool from, bool to);

View File

@ -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.
@ -37,14 +38,17 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex {
}
double from = _rotation;
_rotation = value;
rotationChanged(from, value);
if (hasValidated) {
rotationChanged(from, value);
}
}
void rotationChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -58,14 +62,17 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex {
}
double from = _inDistance;
_inDistance = value;
inDistanceChanged(from, value);
if (hasValidated) {
inDistanceChanged(from, value);
}
}
void inDistanceChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -80,7 +87,9 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex {
}
double from = _outDistance;
_outDistance = value;
outDistanceChanged(from, value);
if (hasValidated) {
outDistanceChanged(from, value);
}
}
void outDistanceChanged(double from, double to);

View File

@ -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.
@ -37,14 +38,17 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
}
double from = _inRotation;
_inRotation = value;
inRotationChanged(from, value);
if (hasValidated) {
inRotationChanged(from, value);
}
}
void inRotationChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -58,14 +62,17 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
}
double from = _inDistance;
_inDistance = value;
inDistanceChanged(from, value);
if (hasValidated) {
inDistanceChanged(from, value);
}
}
void inDistanceChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -80,14 +87,17 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
}
double from = _outRotation;
_outRotation = value;
outRotationChanged(from, value);
if (hasValidated) {
outRotationChanged(from, value);
}
}
void outRotationChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -102,7 +112,9 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
}
double from = _outDistance;
_outDistance = value;
outDistanceChanged(from, value);
if (hasValidated) {
outDistanceChanged(from, value);
}
}
void outDistanceChanged(double from, double to);

View File

@ -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.
@ -37,14 +38,17 @@ abstract class CubicMirroredVertexBase extends CubicVertex {
}
double from = _rotation;
_rotation = value;
rotationChanged(from, value);
if (hasValidated) {
rotationChanged(from, value);
}
}
void rotationChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -58,7 +62,9 @@ abstract class CubicMirroredVertexBase extends CubicVertex {
}
double from = _distance;
_distance = value;
distanceChanged(from, value);
if (hasValidated) {
distanceChanged(from, value);
}
}
void distanceChanged(double from, double to);

View File

@ -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;
@ -32,7 +33,9 @@ abstract class FillBase extends ShapePaint {
}
int from = _fillRule;
_fillRule = value;
fillRuleChanged(from, value);
if (hasValidated) {
fillRuleChanged(from, value);
}
}
void fillRuleChanged(int from, int to);

View File

@ -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;
@ -26,14 +27,17 @@ abstract class GradientStopBase extends Component {
}
int from = _colorValue;
_colorValue = value;
colorValueChanged(from, value);
if (hasValidated) {
colorValueChanged(from, value);
}
}
void colorValueChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -45,7 +49,9 @@ abstract class GradientStopBase extends Component {
}
double from = _position;
_position = value;
positionChanged(from, value);
if (hasValidated) {
positionChanged(from, value);
}
}
void positionChanged(double from, double to);

View File

@ -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;
@ -31,14 +32,17 @@ abstract class LinearGradientBase extends ContainerComponent {
}
double from = _startX;
_startX = value;
startXChanged(from, value);
if (hasValidated) {
startXChanged(from, value);
}
}
void startXChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -50,14 +54,17 @@ abstract class LinearGradientBase extends ContainerComponent {
}
double from = _startY;
_startY = value;
startYChanged(from, value);
if (hasValidated) {
startYChanged(from, value);
}
}
void startYChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -69,14 +76,17 @@ abstract class LinearGradientBase extends ContainerComponent {
}
double from = _endX;
_endX = value;
endXChanged(from, value);
if (hasValidated) {
endXChanged(from, value);
}
}
void endXChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -88,14 +98,17 @@ abstract class LinearGradientBase extends ContainerComponent {
}
double from = _endY;
_endY = value;
endYChanged(from, value);
if (hasValidated) {
endYChanged(from, value);
}
}
void endYChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -107,7 +120,9 @@ abstract class LinearGradientBase extends ContainerComponent {
}
double from = _opacity;
_opacity = value;
opacityChanged(from, value);
if (hasValidated) {
opacityChanged(from, value);
}
}
void opacityChanged(double from, double to);

View File

@ -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;
@ -31,7 +32,9 @@ abstract class ShapePaintBase extends ContainerComponent {
}
bool from = _isVisible;
_isVisible = value;
isVisibleChanged(from, value);
if (hasValidated) {
isVisibleChanged(from, value);
}
}
void isVisibleChanged(bool from, bool to);

View File

@ -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;
@ -26,7 +27,9 @@ abstract class SolidColorBase extends Component {
}
int from = _colorValue;
_colorValue = value;
colorValueChanged(from, value);
if (hasValidated) {
colorValueChanged(from, value);
}
}
void colorValueChanged(int from, int to);

View File

@ -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;
@ -33,14 +34,17 @@ abstract class StrokeBase extends ShapePaint {
}
double from = _thickness;
_thickness = value;
thicknessChanged(from, value);
if (hasValidated) {
thicknessChanged(from, value);
}
}
void thicknessChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -52,14 +56,17 @@ abstract class StrokeBase extends ShapePaint {
}
int from = _cap;
_cap = value;
capChanged(from, value);
if (hasValidated) {
capChanged(from, value);
}
}
void capChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -71,14 +78,17 @@ abstract class StrokeBase extends ShapePaint {
}
int from = _join;
_join = value;
joinChanged(from, value);
if (hasValidated) {
joinChanged(from, value);
}
}
void joinChanged(int from, int to);
/// --------------------------------------------------------------------------
/// 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;
@ -91,7 +101,9 @@ abstract class StrokeBase extends ShapePaint {
}
bool from = _transformAffectsStroke;
_transformAffectsStroke = value;
transformAffectsStrokeChanged(from, value);
if (hasValidated) {
transformAffectsStrokeChanged(from, value);
}
}
void transformAffectsStrokeChanged(bool from, bool to);

View File

@ -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;
@ -26,14 +27,17 @@ abstract class TrimPathBase extends Component {
}
double from = _start;
_start = value;
startChanged(from, value);
if (hasValidated) {
startChanged(from, value);
}
}
void startChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -45,14 +49,17 @@ abstract class TrimPathBase extends Component {
}
double from = _end;
_end = value;
endChanged(from, value);
if (hasValidated) {
endChanged(from, value);
}
}
void endChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -64,14 +71,17 @@ abstract class TrimPathBase extends Component {
}
double from = _offset;
_offset = value;
offsetChanged(from, value);
if (hasValidated) {
offsetChanged(from, value);
}
}
void offsetChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -83,7 +93,9 @@ abstract class TrimPathBase extends Component {
}
int from = _modeValue;
_modeValue = value;
modeValueChanged(from, value);
if (hasValidated) {
modeValueChanged(from, value);
}
}
void modeValueChanged(int from, int to);

View File

@ -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.
@ -39,14 +40,17 @@ abstract class ParametricPathBase extends Path {
}
double from = _width;
_width = value;
widthChanged(from, value);
if (hasValidated) {
widthChanged(from, value);
}
}
void widthChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -60,14 +64,17 @@ abstract class ParametricPathBase extends Path {
}
double from = _height;
_height = value;
heightChanged(from, value);
if (hasValidated) {
heightChanged(from, value);
}
}
void heightChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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).
@ -81,14 +88,17 @@ abstract class ParametricPathBase extends Path {
}
double from = _originX;
_originX = value;
originXChanged(from, value);
if (hasValidated) {
originXChanged(from, value);
}
}
void originXChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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).
@ -102,7 +112,9 @@ abstract class ParametricPathBase extends Path {
}
double from = _originY;
_originY = value;
originYChanged(from, value);
if (hasValidated) {
originYChanged(from, value);
}
}
void originYChanged(double from, double to);

View File

@ -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;
@ -34,7 +35,9 @@ abstract class PathBase extends Node {
}
int from = _pathFlags;
_pathFlags = value;
pathFlagsChanged(from, value);
if (hasValidated) {
pathFlagsChanged(from, value);
}
}
void pathFlagsChanged(int from, int to);

View File

@ -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.
@ -32,14 +33,17 @@ abstract class PathVertexBase extends ContainerComponent {
}
double from = _x;
_x = value;
xChanged(from, value);
if (hasValidated) {
xChanged(from, value);
}
}
void xChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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.
@ -53,7 +57,9 @@ abstract class PathVertexBase extends ContainerComponent {
}
double from = _y;
_y = value;
yChanged(from, value);
if (hasValidated) {
yChanged(from, value);
}
}
void yChanged(double from, double to);

View File

@ -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.
@ -39,7 +40,9 @@ abstract class PointsPathBase extends Path {
}
bool from = _isClosed;
_isClosed = value;
isClosedChanged(from, value);
if (hasValidated) {
isClosedChanged(from, value);
}
}
void isClosedChanged(bool from, bool to);

View File

@ -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.
@ -40,14 +41,17 @@ abstract class PolygonBase extends ParametricPath {
}
int from = _points;
_points = value;
pointsChanged(from, value);
if (hasValidated) {
pointsChanged(from, value);
}
}
void pointsChanged(int from, int to);
/// --------------------------------------------------------------------------
/// CornerRadius field with key 126.
double _cornerRadius = 0;
static const double cornerRadiusInitialValue = 0;
double _cornerRadius = cornerRadiusInitialValue;
static const int cornerRadiusPropertyKey = 126;
/// The corner radius.
@ -62,7 +66,9 @@ abstract class PolygonBase extends ParametricPath {
}
double from = _cornerRadius;
_cornerRadius = value;
cornerRadiusChanged(from, value);
if (hasValidated) {
cornerRadiusChanged(from, value);
}
}
void cornerRadiusChanged(double from, double to);

View File

@ -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
@ -41,7 +42,9 @@ abstract class RectangleBase extends ParametricPath {
}
double from = _cornerRadius;
_cornerRadius = value;
cornerRadiusChanged(from, value);
if (hasValidated) {
cornerRadiusChanged(from, value);
}
}
void cornerRadiusChanged(double from, double to);

View File

@ -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.
@ -43,7 +44,9 @@ abstract class StarBase extends Polygon {
}
double from = _innerRadius;
_innerRadius = value;
innerRadiusChanged(from, value);
if (hasValidated) {
innerRadiusChanged(from, value);
}
}
void innerRadiusChanged(double from, double to);

View File

@ -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
@ -36,7 +37,9 @@ abstract class StraightVertexBase extends PathVertex<Weight> {
}
double from = _radius;
_radius = value;
radiusChanged(from, value);
if (hasValidated) {
radiusChanged(from, value);
}
}
void radiusChanged(double from, double to);

View File

@ -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;
@ -31,14 +32,17 @@ abstract class TransformComponentBase extends ContainerComponent {
}
double from = _rotation;
_rotation = value;
rotationChanged(from, value);
if (hasValidated) {
rotationChanged(from, value);
}
}
void rotationChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -50,14 +54,17 @@ abstract class TransformComponentBase extends ContainerComponent {
}
double from = _scaleX;
_scaleX = value;
scaleXChanged(from, value);
if (hasValidated) {
scaleXChanged(from, value);
}
}
void scaleXChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -69,14 +76,17 @@ abstract class TransformComponentBase extends ContainerComponent {
}
double from = _scaleY;
_scaleY = value;
scaleYChanged(from, value);
if (hasValidated) {
scaleYChanged(from, value);
}
}
void scaleYChanged(double from, double to);
/// --------------------------------------------------------------------------
/// 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;
@ -88,7 +98,9 @@ abstract class TransformComponentBase extends ContainerComponent {
}
double from = _opacity;
_opacity = value;
opacityChanged(from, value);
if (hasValidated) {
opacityChanged(from, value);
}
}
void opacityChanged(double from, double to);

View File

@ -31,25 +31,18 @@ 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) {
return RiveRenderObject()
..artboard = artboard
return RiveRenderObject(artboard as RuntimeArtboard)
..fit = fit
..alignment = alignment
..artboardSize =
artboard == null ? Size.zero : Size(artboard.width, artboard.height)
..artboardSize = Size(artboard.width, artboard.height)
..useArtboardSize = useArtboardSize;
}
@ -60,8 +53,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;
}
@ -73,6 +65,9 @@ class Rive extends LeafRenderObjectWidget {
class RiveRenderObject extends RiveRenderBox {
RuntimeArtboard _artboard;
RiveRenderObject(this._artboard) {
_artboard.redraw.addListener(scheduleRepaint);
}
RuntimeArtboard get artboard => _artboard;
@ -80,15 +75,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 {

View File

@ -4,9 +4,9 @@ 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;
Artboard get artboard => _artboard;
set artboard(Artboard value) {
Artboard? _artboard;
Artboard? get artboard => _artboard;
set artboard(Artboard? value) {
if (_artboard == value) {
return;
}
@ -15,15 +15,12 @@ class Animation extends AnimationBase<RuntimeArtboard> {
_artboard?.internalAddAnimation(this);
}
@override
void onAdded() {}
@override
void onAddedDirty() {}
@override
void onRemoved() {
artboard = null;
}
void onAdded() {}
@override
bool validate() => super.validate() && _artboard != null;
@override
void nameChanged(String from, String to) {}
}

View File

@ -0,0 +1,26 @@
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';
class AnimationState extends AnimationStateBase {
@override
String toString() {
return '${super.toString()} ($id) -> ${_animation?.name}';
}
LinearAnimation? _animation;
LinearAnimation? get animation => _animation;
set animation(LinearAnimation? value) {
if (_animation == value) {
return;
}
_animation = value;
animationId = value?.id ?? Core.missingId;
}
@override
void animationIdChanged(int from, int to) {
animation = id == Core.missingId ? null : context.resolve(to);
}
}

View File

@ -0,0 +1,4 @@
import 'package:rive/src/generated/animation/any_state_base.dart';
export 'package:rive/src/generated/animation/any_state_base.dart';
class AnyState extends AnyStateBase {}

View File

@ -1,5 +1,7 @@
import 'dart:typed_data';
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/interpolator.dart';
import 'package:rive/src/rive_core/artboard.dart';
import 'package:rive/src/generated/animation/cubic_interpolator_base.dart';
const int newtonIterations = 4;
@ -21,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) {
@ -34,15 +36,10 @@ class CubicInterpolator extends CubicInterpolatorBase implements Interpolator {
}
@override
void onAdded() {
_updateStoredCubic();
}
void onAdded() => _updateStoredCubic();
@override
void onAddedDirty() {}
@override
void onRemoved() {}
@override
double transform(double value) => _ease.transform(value);
@override
void x1Changed(double from, double to) => _updateStoredCubic();
@ -55,13 +52,22 @@ class CubicInterpolator extends CubicInterpolatorBase implements Interpolator {
void _updateStoredCubic() {
_ease = _CubicEase.make(x1, y1, x2, y2);
}
@override
bool import(ImportStack stack) {
var artboardHelper = stack.latest<ArtboardImporter>(ArtboardBase.typeKey);
if (artboardHelper == null) {
return false;
}
artboardHelper.addComponent(this);
return super.import(stack);
}
}
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);
}

View File

@ -0,0 +1,4 @@
import 'package:rive/src/generated/animation/entry_state_base.dart';
export 'package:rive/src/generated/animation/entry_state_base.dart';
class EntryState extends EntryStateBase {}

View File

@ -0,0 +1,4 @@
import 'package:rive/src/generated/animation/exit_state_base.dart';
export 'package:rive/src/generated/animation/exit_state_base.dart';
class ExitState extends ExitStateBase {}

View File

@ -1,7 +1,9 @@
import 'dart:collection';
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/keyed_property.dart';
import 'package:rive/src/rive_core/component.dart';
import 'package:rive/src/generated/animation/keyed_object_base.dart';
import 'linear_animation.dart';
export 'package:rive/src/generated/animation/keyed_object_base.dart';
class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
@ -9,11 +11,34 @@ class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
HashMap<int, KeyedProperty>();
Iterable<KeyedProperty> get keyedProperties => _keyedProperties.values;
@override
void onAdded() {}
@override
void onAddedDirty() {}
@override
void onRemoved() {}
void onAdded() {}
@override
bool validate() {
if (!super.validate()) {
return false;
}
var component = context.resolve<Component>(objectId);
if (component == null) {
return false;
}
return true;
}
@override
void onRemoved() {
super.onRemoved();
}
bool isValidKeyedProperty(KeyedProperty property) {
var value = _keyedProperties[property.propertyKey];
if (value != null && value != property) {
return false;
}
return true;
}
bool internalAddKeyedProperty(KeyedProperty property) {
var value = _keyedProperties[property.propertyKey];
if (value != null && value != property) {
@ -32,7 +57,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;
}
@ -43,4 +68,14 @@ class KeyedObject extends KeyedObjectBase<RuntimeArtboard> {
@override
void objectIdChanged(int from, int to) {}
@override
bool import(ImportStack stack) {
var animationHelper =
stack.latest<LinearAnimationImporter>(LinearAnimationBase.typeKey);
if (animationHelper == null) {
return false;
}
animationHelper.addKeyedObject(this);
return super.import(stack);
}
}

View File

@ -1,4 +1,5 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/animation/keyed_object.dart';
import 'package:rive/src/rive_core/animation/keyframe.dart';
import 'package:rive/src/generated/animation/keyed_property_base.dart';
export 'package:rive/src/generated/animation/keyed_property_base.dart';
@ -11,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];
@ -51,7 +52,10 @@ class KeyedProperty extends KeyedPropertyBase<RuntimeArtboard>
@override
void onAddedDirty() {}
@override
void onRemoved() {}
void onRemoved() {
super.onRemoved();
}
bool internalAddKeyFrame(KeyFrame frame) {
if (_keyframes.contains(frame)) {
return false;
@ -64,19 +68,19 @@ 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() {
@ -146,4 +150,13 @@ class KeyedProperty extends KeyedPropertyBase<RuntimeArtboard>
@override
void propertyKeyChanged(int from, int to) {}
@override
bool import(ImportStack stack) {
var importer = stack.latest<KeyedObjectImporter>(KeyedObjectBase.typeKey);
if (importer == null) {
return false;
}
importer.addKeyedProperty(this);
return super.import(stack);
}
}

View File

@ -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,25 +32,39 @@ abstract class KeyFrame extends KeyFrameBase<RuntimeArtboard>
@override
void onAddedDirty() {
if (interpolatorId != null) {
interpolator = context?.resolve(interpolatorId);
if (interpolatorId != Core.missingId) {
interpolator = context.resolve(interpolatorId);
}
}
@override
void onRemoved() {}
void onRemoved() {
super.onRemoved();
}
@override
void frameChanged(int from, int to) {}
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
bool import(ImportStack importStack) {
var keyedPropertyHelper =
importStack.latest<KeyedPropertyImporter>(KeyedPropertyBase.typeKey);
if (keyedPropertyHelper == null) {
return false;
}
keyedPropertyHelper.addKeyFrame(this);
return super.import(importStack);
}
}

View File

@ -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

View File

@ -4,6 +4,10 @@ import 'package:rive/src/generated/animation/keyframe_double_base.dart';
import 'package:rive/src/generated/rive_core_context.dart';
export 'package:rive/src/generated/animation/keyframe_double_base.dart';
double toDegrees(double rad) {
return rad / 3.14 * 180;
}
void _apply(
Core<CoreContext> object, int propertyKey, double mix, double value) {
if (mix == 1) {
@ -19,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);
}

View File

@ -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) {

Some files were not shown because too many files have changed in this diff Show More