mirror of
https://github.com/rive-app/rive-flutter
synced 2025-07-05 21:55:58 +00:00
sample flutter changes for discussion
This commit is contained in:
@ -29,4 +29,12 @@ class NestedSimpleAnimation extends NestedSimpleAnimationBase {
|
||||
}
|
||||
super.advance(elapsedSeconds, mountedArtboard);
|
||||
}
|
||||
|
||||
void goTo(double time, MountedArtboard mountedArtboard) {
|
||||
if (isPlaying) {
|
||||
linearAnimationInstance?.goto(time);
|
||||
linearAnimationInstance?.apply(mountedArtboard, mix);
|
||||
linearAnimationInstance?.needsApply = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,21 +153,30 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
||||
}
|
||||
|
||||
final Set<NestedArtboard> _activeNestedArtboards = {};
|
||||
Set<NestedArtboard> get activeNestedArtboards => _activeNestedArtboards;
|
||||
|
||||
/// Update any dirty components in this artboard.
|
||||
bool advance(double elapsedSeconds, {bool nested = false}) {
|
||||
bool didUpdate = false;
|
||||
bool handleNestedArtboards = true;
|
||||
|
||||
for (final controller in _animationControllers) {
|
||||
if (controller.suppressesNestedArtboards) {
|
||||
handleNestedArtboards = false;
|
||||
}
|
||||
if (controller.isActive) {
|
||||
controller.apply(context, elapsedSeconds);
|
||||
didUpdate = true;
|
||||
}
|
||||
}
|
||||
// NOTE: i think this works out if the nested artboard should still be
|
||||
// animating...
|
||||
if (updateComponents() || didUpdate) {
|
||||
didUpdate = true;
|
||||
}
|
||||
|
||||
if (nested) {
|
||||
// TODO: talk about this.
|
||||
if (nested && handleNestedArtboards) {
|
||||
var active = _activeNestedArtboards.toList(growable: false);
|
||||
for (final activeNestedArtboard in active) {
|
||||
activeNestedArtboard.advance(elapsedSeconds);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:rive/src/core/core.dart';
|
||||
import 'package:rive/src/generated/nested_artboard_base.dart';
|
||||
import 'package:rive/src/rive_core/animation/nested_remap_animation.dart';
|
||||
@ -46,7 +47,6 @@ class NestedArtboard extends NestedArtboardBase {
|
||||
@override
|
||||
void artboardIdChanged(int from, int to) {}
|
||||
|
||||
|
||||
@override
|
||||
void childAdded(Component child) {
|
||||
super.childAdded(child);
|
||||
@ -88,6 +88,22 @@ class NestedArtboard extends NestedArtboardBase {
|
||||
mountedArtboard!.advance(elapsedSeconds);
|
||||
}
|
||||
|
||||
void goTo(double seconds) {
|
||||
if (mountedArtboard == null) {
|
||||
return;
|
||||
}
|
||||
for (final animation in _animations) {
|
||||
if (animation.isEnabled) {
|
||||
if (animation is NestedSimpleAnimation) {
|
||||
animation.goTo(seconds, mountedArtboard!);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Gotta advance the artboard to make it dirty?
|
||||
// (if we skip this no redraw)
|
||||
mountedArtboard!.advance(0.0);
|
||||
}
|
||||
|
||||
@override
|
||||
void update(int dirt) {
|
||||
super.update(dirt);
|
||||
|
@ -6,6 +6,14 @@ abstract class RiveAnimationController<T> {
|
||||
final _isActive = ValueNotifier<bool>(false);
|
||||
ValueListenable<bool> get isActiveChanged => _isActive;
|
||||
|
||||
// TODO: this is a hack.
|
||||
// Ideally nestedArtboards are not run in the Artboard.advance, but instead
|
||||
// always controlled by AnimationControllers.
|
||||
// SimpleAnimationControllers kinda throw a spanner in the works here.
|
||||
// unless we do some magic that means multiple simple animation controllers
|
||||
// won't all compete for advancing the nested artboard....
|
||||
final suppressesNestedArtboards = false;
|
||||
|
||||
bool get isActive => _isActive.value;
|
||||
set isActive(bool value) {
|
||||
if (_isActive.value != value) {
|
||||
|
Reference in New Issue
Block a user