This PR brings in a community fix: https://github.com/rive-app/rive-flutter/pull/380
This was working previously. I don't know what changed to cause this to break. Either way, having these conditional checks is sensible. This PR adds golden test with various ticker mode states to ensure this does not regress again.
Diffs=
78c081bce Flutter fix ticker mode (#7182)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
Co-authored-by: Paweł Polański <jaggernod@gmail.com>
Pubspec is already updated updated to the correct version, but we've not pushed to Pub yet (probably a mistake).
- Changelog is updated with latest changes
- This PR just fixes some analyzer warnings and is a bit of a formality to make it clear we are releasing to pub
Diffs=
fdd52090d chore: release flutter v0.13.2 (#7100)
89053041a add out of band audio support ios - abstracted audio! (#7079)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
Our current API is quite verbose and requires casting to the relevant class types when using the current find API. These methods simplify the process.
Diffs=
1460f5366 Expose methods to easily get Rive state machine inputs (#7085)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
An oversight from our side. We've previously recommended setting `isActive` to false on the StateMachine or Animation. But this will not propagate down to nested artboards.
Diffs=
e64daefff feat: adds play and pause to artboard (#7078)
2828b7b01 propagate volume to nested artboards (#7067)
4a9947630 Stop audio in iOS when backgrounded. (#7055)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
Run --update-goldens to regenerate golden images since at least some of these appear to be failing in rive_flutter. Its possible Flutter upgrades is causing slight discrepancies. Did a visual side by side and the images appear identical. Want to get this in before publishing rive_flutter.
Diffs=
072f8ffb5 Update flutter golden images (#6768)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
Co-authored-by: Philip Chung <philterdesign@gmail.com>
This PR adds hit testing to Flutter by overriding `hitTestSelf` on the Rive RenderObject.
Currently, the hit area is the entire bounding box of the canvas. This means that when a Rive animation is rendered above any other Flutter content (for example, a Stack) all hits are absorbed by Rive and do not pass through.
With this change, Rive will only absorb hits if the pointer comes in contact with a hittable Rive element.
With this change, `handleEvent` will only be called if `hitTestSelf` returns true. There is some duplicate work here as `_processEvent` already performs similar hit test logic, which we can look at optimizing. But `hitTest` needed to be separate method call, as `hitTestSelf` is called before `handleEvent` and `handleEvent` sends additional information (whether it's a pointer down/up etc.).
Diffs=
95beaa4f5 feat: add flutter hit test self on rive render object (#6341)
bd71143bc chore: fix broken docs link (#6360)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
fixes#6070
thank you @philter for sorting out the path mess, i got myself extra confused with `addToRawPath` (i thought we were simply passing the variables along and one of them got corrupted, i didnt notice that it was just down to a bad static cast when we were a path!)
vid of this behaving in dart & cpp
Added a rive-flutter test to this.
one interesting thing, essentially follow path currently follows the "first" path in a shape.
https://github.com/rive-app/rive/assets/1216025/d59026f6-c901-439c-aff2-2214a021ee75
Diffs=
ef8a4e7f7 Fix follow path 6070 (#6182)
3927ea695 add support for rendering static scene (#6192)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
Co-authored-by: Phil Chung <philterdesign@gmail.com>
basically does what it says, i'm also removing an example i used to check on things being garbage collected
Diffs=
c0411df0a bring flutter asset loading inline with cpp (#6135)
Co-authored-by: Gordon Hayes <pggordonhayes@gmail.com>
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
Bascially add tracking of fileAssetReferencers from file assets, so that when file assets update, they can tell things that reference them to update also.
its worth looking at the rive-flutter & runtime implementations
in cpp it looks like we can hook into the delete hooks nicely to clean up after ourselves (so that when artboards get collected we are not holding references to them from file assets)
in dart this is more of a problem, however using weakReferences we do end up seeing artboards go out of scope
but weakReferences requires us to bump to a min dart of 2.17 (we are 2.14 in flutter & 2.12 in our editor atm)
the update here also uses the referencers to mark fonts dirty when fonts are set, which causes them to be updated on the next draw cycle
(video showing font updates working properly now in dart)
https://github.com/rive-app/rive/assets/1216025/d65ea2cf-95d6-4412-b8f5-368cda609d0b
(video showing how referencers get collected and trashed in dart, it looks like we hold onto about 10 of them at a time.. but they do drop off over time. also we start with 2 references, the main artboard and the artboard instance)
https://github.com/rive-app/rive/assets/1216025/b11b7b46-aa9d-4dcc-bc11-f745d8449575
Diffs=
7bc216b03 add ability to attach callbacks when resolving file asset listeners (#6068)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
The goal of this PR is to improve the usability of events for the Flutter runtime and to hide unnecessary editor implementation detail. This also ensures that an event is not modifiable after it has been reported (from the runtime's perspective)
This is achieved by exposing runtime specific classes `RiveEvent`, `RiveOpenURLEvent` and `RiveGeneralEvent` (similar to the other runtimes), and mapping the current `Event` to these classes as an immutable object. It also maps the list of events to a Map called `properties`.
This PR also:
- Adds more event examples and fixes the audio example (`.stop` resulted in issues, and calling dispose, etc.)
- Adds tests for events
TODO:
- Will need to potentially change things (and expose the `delay`) when this lands: https://github.com/rive-app/rive/pull/5951
Diffs=
eae01824d feat: expose wrapper event class to runtime (#5956)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
Diffs=
ab5745943 Update files to use git lfs (#5883)
2719b1463 early out of advance if we are not going to keep goign (#5849)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
Co-authored-by: Philip Chung <philterdesign@gmail.com>
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>
Any riv added to `test/assets/batch_rive` will automatically be tested. The test includes:
1. Setting up the animation to play the default state machine
2. Render first frame
3. Advance by three quarters of a second
4. Advance by two seconds
Diffs=
7c3f77dd6 test: automated golden tests (#5785)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
Removing the default font logic from the runtime, because:
- Flutter Web will console log an error trying to load the default font from a URL
- `rootBundle` prevents tests as it cannot be spoofed.
Diffs=
b905380c9 fix: remove default font from flutter runtime (#5783)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
…nge in rive_flutter to push downstream
tested this on a couple of private repos.
this also ran a linter on mono.sh 🙈 i guess that should be fine though
Diffs=
96a0f0b96 update mono to apply .gitattribute changes first & made a trivial cha… (#5781)
cbc6ba291 Add rive::math::msb() (#5777)
58cc49580 Add a Bitmap::detachBytes method (#5763)
30351d475 Letter spacing! (#5774)
e6941215f refactor: use ticker instead of stopwatch (#5761)
3ab062dd2 Run editor tests on hosted runner. (#5760)
Co-authored-by: Alex Gibson <agibson.uk@gmail.com>
Co-authored-by: Gordon <pggordonhayes@gmail.com>
Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
[Archive.zip](https://github.com/rive-app/rive/files/12175519/Archive.zip)
re-adds the width height stuff, so that we do not remove parameters from files, as the "old" runtimes still need these to layout assets properly
included the same .riv once broken and once "fixed" @luigi-rosso i got a question about this "widthChanged/heightChanged"
Diffs=
a1b1c1ec3 Keep width height in rivs (#5672)
be33bd1b1 update thumbnailer for text (#5667)
Co-authored-by: Luigi Rosso <luigi.rosso@gmail.com>
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
Some updates to clean up warnings and info reported from flutter analyze.
Diffs=
83e539cff Updates for publishing Rive Flutter (#5666)
Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
…sset
ok just "fixing" how we export .riv files, and no-longer rely on width and height form image assets, but take them from the image instead.
its not "huge" difference, but basically it means that if we replace an existing image with an image of different dimensions we end up drawing the image from the centre of where the original image was, rather than the top left, which is a bit mroe forgiving
example:
got a few images in here, (they're all like 5k x 3k pixels, so all quite large)
<img width="1086" alt="CleanShot 2023-07-03 at 16 28 34@2x" src="https://github.com/rive-app/rive/assets/1216025/625e0d34-ac0c-4eb6-ad75-cb839aca92ac">
before this change this would look like:
<img width="1135" alt="CleanShot 2023-07-03 at 16 28 46@2x" src="https://github.com/rive-app/rive/assets/1216025/8ba848da-5938-4897-a664-eaae39c86806">
with this change we get
<img width="1113" alt="CleanShot 2023-07-03 at 16 29 17@2x" src="https://github.com/rive-app/rive/assets/1216025/c5f30eb6-21bd-419e-802d-9c98c00399e7">
(the mesh is kinda interesting here)
*note* i'm not touching the cpp runtime just yet, so this & other changes still need to make it down there
Diffs=
235908221 use the dimensions of the image at runtime, rather than of the ImageA… (#5519)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
Adds some cleanup to this previous PR: https://github.com/rive-app/rive/pull/5411/files
- Brings back some classes and parameters and mark them as deprecated.
- Changed the naming for parameters
- Removed asset resolving from the high level `RiveAnimation` widget, prefer to manage this by loading in your own `RiveFile`. This is to avoid introducing too many changes that we may revert down the line
- Removed code comments that were intended as questions, marked some as TODOs
- Improved documentation and cleaned up example
The cached asset example now has a button to hot swap out assets at runtime by keeping a reference to the asset. This works for images, but not for Fonts.
- We can either remove this example for the time being
- Or investigate why it does not swap out (I would expect it to)
Diffs=
94e3490ae refactor: asset resolving (#5563)
bae069339 Stop automatically pruning empty segments in RawPath (#5557)
2d2d8c413 Line Height & Paragraph Spacing (#5552)
Co-authored-by: Gordon <pggordonhayes@gmail.com>
allowing the cdn to be set per asset, defaults to our public production cdn.
its a "little" wasteful, but should only find usage when we are exporting .riv's from uat (which will be a little bit bigger as a result of this)
We could put the cdn base url onto the rivefile as a whole, i don't think it buys us much & this is simpler.
also considered putting the default string into the runtime (where it was priori to this) but i think its better of in the defs (as the defs would default to an empty string otherwise, which makes the code ever so slightly messier to read). I think this comes out just a crappy if we ever change the default cdn url.
Diffs=
5c76c52e1 Add cdn overwrite (#5522)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
(basing this pr onto our dart runtime change for now, to limit scope)
made some small tweaks to function names, mostly to get fonts and images to "feel" more similar.
broke out "decode' into parsing the asset first.
makes it possible to cache images/fonts with our dart runtime, example included
Diffs=
40302069e Caching example (#5517)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
There are a number of questions I'd like to resolve before considering to merge this. also a few thigns to clean up no doubt
# Questions before merging
To customize loading out of band assets, we expect our users to implement
```
abstract class FileAssetLoader {
Future<bool> load(FileAsset asset);
bool isCompatible(FileAsset asset) => true;
}
```
1. is this a good interface (i've changed `loadContents`, to `load`)? (if we like this we should change this in cpp too)
2. `FileAssetLoader` is a mouth-full, would `AssetLoader` be better?
3. We are passing `FileAssets` (our core objects) to users with some slight api extensions, is that good? should we just wrap this in an Asset class (I had this before, its not a lot of work to get it back)
things sorted
- [x] cdn "loading" vs url loading
- just sticking with cdn, users can customize for url
- [x] asset class for consumers of our runtime.
- i've avoided this one for now, just extending our FileAsset
- [x] Importer/Resolver/Loader. I flipped some names around, mostly because I want our end users to provide an `AssetLoader`, not a resolver.
things to sort out down the line, i'm declaring them out of scope for this pr, fft disagree:
- Fallback font, I see we have a fallback font file hardcoded in the runtime. should investigate if we can include an asset for people like this, or if we need to have users set this if they want to use fallback fonts.
- Image Placement, we should strip width/height from runtimes on ImageAssets
- What do we want to do about asset loading / decoding errors
- TextStyle has both assetId & fontAssetId it gets assetId from the file asset referencer, its nbd,
Diffs=
06e959ad2 Font dart runtime (#5411)
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
- ran ```dev/generate_core_runtime.sh build```
- cleaned up a lot of accumulated changes from the last few months that needed to be stripped/modified for the rutnime
- removed no longer supported lining options from analysis files
- fixed up defs for some editor only features so they don't transpile
- added some more details to changelog
- bumped pubspec version
Diffs=
aa8c750bd Update flutter runtime (#4835)
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
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)
Uses it in the artboard title but also updates the flutter runtime massively to support FFI & WASM C++ Rive Text. PRing to let the tests run.
Diffs=
3be5ff0d8 Text (#4372)
90245a5e1 Fix the Android debug build
0a0f3c267 Fix for missing animation in a blend state. (#4415)
440512dca Add simd::if_then_else (#4403)
ec9fb5bfc Revert "Update SIMD booleans to use bitwise logic operators"
701d8dee2 Update SIMD booleans to use bitwise logic operators
e98b93a61 Add SIMD fallbacks for missing builtins
466f68e3a Add some more core math and SIMD functions