5 Commits

Author SHA1 Message Date
278695858d Choose events to fire on State and Transition start/end.
Allows selection of event and when to fire it per state and transition.

On a state:
![CleanShot 2023-08-16 at 22 28 32@2x](https://github.com/rive-app/rive/assets/454182/34c49212-6638-4187-91ed-d99042cc5a2a)

On a transition:
![CleanShot 2023-08-16 at 22 28 53@2x](https://github.com/rive-app/rive/assets/454182/d7bcbcbf-6719-4c5f-9a2a-cfee491ac718)

I also kept getting the annoying combo-box stuck at the bottom of the screen with these combos so low to the bottom right, so I fixed that too. Which helps the text combos too. Popups with predictable heights will try to open in the direction where they'll have most vertical space:
<img width="570" alt="CleanShot 2023-08-16 at 22 30 02@2x" src="https://github.com/rive-app/rive/assets/454182/88802e09-04df-4256-b4c1-2cc2bf490fcd">

Diffs=
ad4236501 Choose events to fire on State and Transition start/end. (#5830)
abe5aab14 Added a Vello back-end with a custom winit viewer. (#5786)
adeebb26a Implement drawImage() in PLS (#5780)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2023-08-18 19:49:16 +00:00
4780d19c3a Event triggering
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)
e71ae68ba  Fix issue with nested artboards not updating follow path constraints. (#5810)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2023-08-14 19:17:57 +00:00
82e5dc984c perf: fix didUpdateWidget and artboard config
This resolves a performance and usability issue where certain conditions would result in Rive needlessly reconfiguring/initializing the Rive artboard (as well as downloading/loading Rive files). If `onInit`, `animations`, `controllers`, or `stateMachines` were passed in as an argument to `RiveAnimation` the above issue is triggered on each widget rebuild. Under certain conditions this could result in an animation constantly restarting, bad performance, or Flutter ending up in a `setState` callback loop.

This PR also clears the list of local controllers each time init is called.

Resolves: https://github.com/rive-app/rive-flutter/issues/277

This also fixes bugs in our example app
- Play/Pause not working
- One shot animation behaving oddly

Diffs=
9af05d044 docs: update changelog
cb7fd6d14 test: add rive animation onInit tests
107ae16bc refactor: naming and call logic
6857aa691 docs: add additional code docs
f3ba4f015 perf: fix didUpdateWidget configure loop
7d0aaaff3 Adjust RiveAnimation didUpdateWidget condition (https://github.com/rive-app/rive-flutter/issues/278)
d4c6dd4ab Add more helper functions
6a8f9e249 Fix tess for C++11 and add to github action (#4571)
c8b5fdadd More SIMD features
87f079a10 RawPath::Iter improvements
2023-01-10 08:59:52 +00:00
af6e7d4c07 rive_common package
I started adding Text features to rive_core and realized that the dependency structure is going to be very difficult to manage here. Here's why:

## rive_core
 - has most of the runtime logic for things like IK, mesh, shapes, etc

## rive_flutter
 - depends on rive_core (not directly but we transpile rive_core to rive_flutter)
 - also includes the FFI/WASM text runtime

The problem is that rive_core needs the FFI/WASM text runtime. So we have a cyclic dependency. We've dealt with something similar (not quite as extreme) by abstracting things like nested artboards, but it gets very complex for a verbose API like the text one.

## rive_common
What this PR does is reworks a lot of shared logic like Math (Vec2D, Mat2D, etc), low-level text runtime (FFI/WASM), etc into a "rive_common" package. We've had shared packages before but none that have been shared by rive_flutter and rive_editor. I think it's finally time to bite the bullet here.

This will make it much easier to work through some of the obtuse abstraction patterns we've had to do to disambiguate if you're using a Vec2D from the runtime or the editor, for example.

Yes, this means we'll only have one set of math classes, one set of binary writer/readers, etc. I only did the bare minimum necessary to move text into rive_common in this first pass but we can do more as we go forward.

## TODO:
- [x] move Text WASM & FFI to rive_common
- [x] move Math used by text (Mat2D, Vec2D, TransformComponents, PathInterface, etc) to rive_common
- [x] move utilities used by text (binary reader/writer) to rive_common
- [x] fix core_generator and core_generator_runtime
- [x] fix github actions to use new paths
- [x] publish rive_common to pub.dev and unlist it

Diffs=
12c6ee130 rive_common package (#4434)
5a24e63d0 Initialize isClosed on TessRenderPath (#4431)
2022-11-19 20:19:05 +00:00
6d229dcdd9 add simple test & an example showing selection of different rive files 2022-08-26 18:16:13 +01:00