-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explores an API for triggering events and querying them at runtime. For Flutter we expose an onEvent callback that you can add a callback to on the StateMachineController: ```dart final controller = StateMachineController.fromArtboard(artboard, 'bumpy', onEvent: {); controller.onEvent = (event) { // Do something with event. Like: if(event is OpenURLEvent) { launchUrl(event.url); } }; artboard.addController(controller!); ``` Note that I haven't piped onEvent to the Flutter runtime yet but you'll see it in the StateMachineController in core. In C++: ```c++ auto count = stateMachineInstance->firedEventCount(); for(auto i = 0; i < count; i++) { auto event = stateMachineInstance->firedEventAt(i); if(event->is<OpenURLEvent>()) { // Do something with the url. auto url = event->as<OpenURLEvent>()->url(); } } ``` You can see some of this in action in the state_machine_event_test.cpp. You can also see the events in the console in the editor: <img width="717" alt="CleanShot 2023-08-10 at 18 03 22@2x" src="https://github.com/rive-app/rive/assets/454182/af21902a-424d-435b-b5b0-2a43701fe186"> In a follow up PR: - Ability to trigger events from State (in/out) and Transition (start/end). - Add custom properties to Events C++ API (currently they are loaded but not tracked against their respective events). Diffs= 8caa7d377 Event triggering (#5793) Co-authored-by: Luigi Rosso <[email protected]>
- Loading branch information
1 parent
00866e5
commit 7a06c74
Showing
48 changed files
with
1,292 additions
and
38 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 @@ | ||
e71ae68ba09767f246bf3d779f38bb731cf7da9a | ||
8caa7d377f368af8c667ca209a2ce7aef8679be2 |
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,21 @@ | ||
{ | ||
"name": "ListenerFireEvent", | ||
"key": { | ||
"int": 168, | ||
"string": "listenerfireevent" | ||
}, | ||
"extends": "animation/listener_action.json", | ||
"properties": { | ||
"eventId": { | ||
"type": "Id", | ||
"typeRuntime": "uint", | ||
"initialValue": "Core.missingId", | ||
"initialValueRuntime": "-1", | ||
"key": { | ||
"int": 389, | ||
"string": "eventid" | ||
}, | ||
"description": "Id of the Event referenced." | ||
} | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"name": "StateMachineComponentFolder", | ||
"key": { | ||
"int": 151, | ||
"string": "statemachinecomponentfolder" | ||
}, | ||
"extends": "animation/state_machine_component.json", | ||
"runtime": false | ||
} |
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,9 @@ | ||
{ | ||
"name": "StateMachineInputFolder", | ||
"key": { | ||
"int": 149, | ||
"string": "statemachineinputfolder" | ||
}, | ||
"extends": "animation/state_machine_component_folder.json", | ||
"runtime": false | ||
} |
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,9 @@ | ||
{ | ||
"name": "StateMachineListenerFolder", | ||
"key": { | ||
"int": 150, | ||
"string": "statemachinelistenerfolder" | ||
}, | ||
"extends": "animation/state_machine_component_folder.json", | ||
"runtime": false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "ClipboardHeader", | ||
"key": { | ||
"int": 146, | ||
"string": "clipboardheader" | ||
}, | ||
"runtime": false, | ||
"properties": { | ||
"fileId": { | ||
"type": "uint", | ||
"initialValue": "0", | ||
"key": { | ||
"int": 293, | ||
"string": "fileid" | ||
}, | ||
"description": "File clipboard contents has come from.", | ||
"runtime": false | ||
}, | ||
"projectId": { | ||
"type": "uint", | ||
"initialValue": "0", | ||
"key": { | ||
"int": 294, | ||
"string": "projectid" | ||
}, | ||
"description": "Project clipboard contents has come from.", | ||
"runtime": false | ||
}, | ||
"clipboardTypeValue": { | ||
"type": "uint", | ||
"initialValue": "0", | ||
"key": { | ||
"int": 295, | ||
"string": "clipboardtypevalue" | ||
}, | ||
"description": "Type of clipboard used to read these bytes", | ||
"runtime": false | ||
} | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"name": "CustomProperty", | ||
"key": { | ||
"int": 167, | ||
"string": "customproperty" | ||
}, | ||
"abstract": true, | ||
"extends": "component.json" | ||
} |
Oops, something went wrong.