-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nested linear animations report events up to parent artboards
Previously, only nested state machines could report events so that listeners in parent artboards could listen for them. This PR adds event reporting for nested simple animations. Had to refactor some stuff to genericize in order for both state machines and linear animations to have similar functionality. I'm not sure if its possible, or desirable, for nested remap animations to have the same functionality, but that is not included in this PR. Diffs= 097b68f56 Nested linear animations report events up to parent artboards (#7310) 34e186b32 more renames for harfbuzz (#7398) b88272290 mark shape as dirty after flagged as target (#7396) a10b1e61e don’t defer updates when a shape/path is used for hit detect (#7392) Co-authored-by: Philip Chung <[email protected]>
- Loading branch information
Showing
9 changed files
with
102 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
9abd6ee16ca1290488f2bd950844e7730ee92c6e | ||
097b68f5616951d83b0c5b28345e6bfc9f0b1a5b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:rive/src/core/core.dart'; | ||
import 'package:rive/src/rive_core/animation/keyed_object.dart'; | ||
import 'package:rive/src/rive_core/animation/linear_animation_instance.dart' | ||
as core; | ||
import 'package:rive/src/rive_core/event.dart'; | ||
import 'package:rive/src/runtime_mounted_artboard.dart'; | ||
export 'package:rive/src/runtime_mounted_artboard.dart'; | ||
|
||
/// An AnimationController which controls a StateMachine and provides access to | ||
/// the inputs of the StateMachine. | ||
class LinearAnimationInstance extends core.LinearAnimationInstance | ||
with RuntimeEventReporter, KeyedCallbackReporter { | ||
final _runtimeEventListeners = <OnRuntimeEvent>{}; | ||
late CoreContext? context; | ||
|
||
LinearAnimationInstance(animation, | ||
{double speedMultiplier = 1.0, this.context}) | ||
: super(animation, speedMultiplier: speedMultiplier); | ||
|
||
@override | ||
void addRuntimeEventListener(OnRuntimeEvent callback) => | ||
_runtimeEventListeners.add(callback); | ||
|
||
@override | ||
void removeRuntimeEventListener(OnRuntimeEvent callback) => | ||
_runtimeEventListeners.remove(callback); | ||
|
||
@override | ||
void reportEvent(Event event) { | ||
_runtimeEventListeners.toList().forEach((callback) { | ||
callback(event); | ||
}); | ||
} | ||
|
||
@override | ||
void reportKeyedCallback( | ||
int objectId, int propertyKey, double elapsedSeconds) { | ||
var coreObject = context?.resolve(objectId); | ||
if (coreObject != null) { | ||
RiveCoreContext.setCallback( | ||
coreObject, | ||
propertyKey, | ||
CallbackData(this, delay: elapsedSeconds), | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters