Skip to content

Commit

Permalink
Timeline Events for runtime
Browse files Browse the repository at this point in the history
Follow on to https://github.com/rive-app/rive/pull/5877! Does similar work for the C++ runtime and reconsiders some naming, will likely need to fix some higher level runtimes @zplata.

I renamed the fired to reportedEvent and added in the time delay too.

Diffs=
f96c86fcc Timeline Events for runtime (#5951)

Co-authored-by: Luigi Rosso <[email protected]>
  • Loading branch information
luigi-rosso and luigi-rosso committed Sep 8, 2023
1 parent 4e6e933 commit 019d8a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
df9c651a1cf45ef795de0b7242156e290a4cf499
f96c86fcc800a1fa2bec3e97be00cab395ea838d
12 changes: 7 additions & 5 deletions wasm/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ EMSCRIPTEN_BINDINGS(RiveWASM)
select_overload<float() const>(&rive::LinearAnimationInstance::time),
select_overload<void(float)>(&rive::LinearAnimationInstance::time))
.property("didLoop", &rive::LinearAnimationInstance::didLoop)
.function("advance", &rive::LinearAnimationInstance::advance)
.function("advance", select_overload<bool(float)>(&rive::LinearAnimationInstance::advance))
.function("apply", &rive::LinearAnimationInstance::apply, allow_raw_pointers());

class_<rive::StateMachine, base<rive::Animation>>("StateMachine");
Expand All @@ -447,18 +447,20 @@ EMSCRIPTEN_BINDINGS(RiveWASM)
optional_override([](rive::StateMachineInstance& self, double x, double y) {
self.pointerUp(rive::Vec2D((float)x, (float)y));
}))
.function("firedEventCount", &rive::StateMachineInstance::firedEventCount)
.function("reportedEventCount", &rive::StateMachineInstance::reportedEventCount)
.function(
"firedEventAt",
"reportedEventAt",
optional_override([](rive::StateMachineInstance& self,
size_t index) -> emscripten::val {
const rive::Event* event = self.firedEventAt(index);
if (event == nullptr)
const rive::EventReport report = self.reportedEventAt(index);
if (report.event() == nullptr)
{
return emscripten::val::undefined();
}
rive::Event* event = report.event();
emscripten::val eventObject = emscripten::val::object();
eventObject.set("name", event->name());
eventObject.set("delay", report.secondsDelay());
if (event->is<rive::OpenUrlEvent>())
{
auto urlEvent = event->as<rive::OpenUrlEvent>();
Expand Down
2 changes: 1 addition & 1 deletion wasm/submodules/rive-cpp

0 comments on commit 019d8a7

Please sign in to comment.