Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: interactivity v2 #231

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5f78ace
feat: updated parser to new forma
samuelOsborne Sep 18, 2024
bfcd58b
refctor: added state machine parsing and creation (#232)
samuelOsborne Sep 23, 2024
9544047
refactor: merged json and state machine enums together (#233)
samuelOsborne Sep 23, 2024
74e43cd
feat: transition logic for triggers and events (#234)
samuelOsborne Sep 24, 2024
7caaf90
feat: added many improvements to the tui example (#235)
samuelOsborne Sep 26, 2024
b4f75d2
feat: global state (#236)
samuelOsborne Sep 30, 2024
6cbd746
fix: re-entering current state on event when not needing one
samuelOsborne Oct 1, 2024
77f1fbd
feat: actions and state entry_actions (#243)
samuelOsborne Oct 8, 2024
ea0c443
fix: fire entry_action for global and normal state
samuelOsborne Oct 8, 2024
71d7964
feat: listeners (#245)
samuelOsborne Oct 14, 2024
135aec4
feat: added triggers to work with compare_to (#251)
samuelOsborne Oct 18, 2024
a9cb18b
fix: made animationId mandatory, keys to camelCase (#252)
samuelOsborne Oct 18, 2024
b7abc66
feat: guardless transitions (#246)
samuelOsborne Oct 21, 2024
7a49143
feat: final state (#253)
samuelOsborne Oct 24, 2024
fada74d
fix: listener types
samuelOsborne Oct 29, 2024
a8a76f3
feat: updated checking pipeline (#257)
samuelOsborne Oct 29, 2024
f306f23
feat: exit actions, bindings updates (#258)
samuelOsborne Nov 8, 2024
9c5d32e
fix: types.rs
samuelOsborne Nov 12, 2024
2263761
feat: added entry/exit action feature flags (#261)
samuelOsborne Nov 19, 2024
c23ed14
feat: removed optional functionality, ran linter corrections. (#271)
samuelOsborne Dec 9, 2024
e1248ca
Merge remote-tracking branch 'origin/main' into refactor/sm-v2
samuelOsborne Dec 9, 2024
f407b60
chore: fixes from merging
samuelOsborne Dec 9, 2024
8754617
fix: build workflow
samuelOsborne Dec 9, 2024
31a5d5e
fix: build workflow
samuelOsborne Dec 9, 2024
0834a0c
fix: build workflow - removed wasm guards
samuelOsborne Dec 10, 2024
2c0bb44
fix: build workflow - removed outdated test
samuelOsborne Dec 10, 2024
e47dc6b
fix: build workflow - removed printlns
samuelOsborne Dec 10, 2024
21274ba
fix: build workflow - fixed assets
samuelOsborne Dec 10, 2024
b6befd8
fix: build workflow - fixed asserts
samuelOsborne Dec 10, 2024
4e3e4e6
fix: pointer enter / exit on pointer move working (#272)
samuelOsborne Dec 18, 2024
2e1ade9
feat: reset trigger action (#279)
samuelOsborne Jan 6, 2025
1b57aa9
Feat/custom event action (#280)
samuelOsborne Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ name: Check PR
on:
pull_request:
branches: [main]
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-pr:
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"rust-analyzer.linkedProjects": [
"./dotlottie-rs/Cargo.toml",
"./dotlottie-ffi/Cargo.toml",
"./dotlottie-fms/Cargo.toml",
"./examples/demo-player/Cargo.toml",
"./examples/demo-state-machine/Cargo.toml"
],
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ cpp_link_args = [
'-sENVIRONMENT=web',
'-sFILESYSTEM=0',
'-sDYNAMIC_EXECUTION=0',
'-sERROR_ON_UNDEFINED_SYMBOLS=0',
'--no-entry',
'--strip-all',
'--emit-tsd=${WASM_MODULE}.d.ts',
Expand Down
6 changes: 5 additions & 1 deletion dotlottie-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[package]
name = "dotlottie-ffi"
version = "0.1.34"
version = "0.1.31"
edition = "2021"
build = "build.rs"

[profile.release]
lto = true
opt-level = "z"
strip = true
codegen-units = 1
panic = "abort"

[lib]
crate-type = ["staticlib", "cdylib", "rlib"]
Expand Down
112 changes: 45 additions & 67 deletions dotlottie-ffi/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,72 +110,47 @@ typedef struct DotLottieMarker {
} DotLottieMarker;

typedef enum DotLottieEvent_Tag {
Boolean,
String,
Numeric,
OnPointerDown,
OnPointerUp,
OnPointerMove,
OnPointerEnter,
OnPointerExit,
PointerDown,
PointerUp,
PointerMove,
PointerEnter,
PointerExit,
OnComplete,
SetNumericContext,
} DotLottieEvent_Tag;

typedef struct Boolean_Body {
bool value;
} Boolean_Body;

typedef struct String_Body {
struct DotLottieString value;
} String_Body;

typedef struct Numeric_Body {
float value;
} Numeric_Body;

typedef struct OnPointerDown_Body {
typedef struct PointerDown_Body {
float x;
float y;
} OnPointerDown_Body;
} PointerDown_Body;

typedef struct OnPointerUp_Body {
typedef struct PointerUp_Body {
float x;
float y;
} OnPointerUp_Body;
} PointerUp_Body;

typedef struct OnPointerMove_Body {
typedef struct PointerMove_Body {
float x;
float y;
} OnPointerMove_Body;
} PointerMove_Body;

typedef struct OnPointerEnter_Body {
typedef struct PointerEnter_Body {
float x;
float y;
} OnPointerEnter_Body;
} PointerEnter_Body;

typedef struct OnPointerExit_Body {
typedef struct PointerExit_Body {
float x;
float y;
} OnPointerExit_Body;

typedef struct SetNumericContext_Body {
struct DotLottieString key;
float value;
} SetNumericContext_Body;
} PointerExit_Body;

typedef struct DotLottieEvent {
DotLottieEvent_Tag tag;
union {
Boolean_Body boolean;
String_Body string;
Numeric_Body numeric;
OnPointerDown_Body on_pointer_down;
OnPointerUp_Body on_pointer_up;
OnPointerMove_Body on_pointer_move;
OnPointerEnter_Body on_pointer_enter;
OnPointerExit_Body on_pointer_exit;
SetNumericContext_Body set_numeric_context;
PointerDown_Body pointer_down;
PointerUp_Body pointer_up;
PointerMove_Body pointer_move;
PointerEnter_Body pointer_enter;
PointerExit_Body pointer_exit;
};
} DotLottieEvent;

Expand Down Expand Up @@ -268,11 +243,6 @@ int32_t dotlottie_load_dotlottie_data(struct DotLottiePlayer *ptr,
uint32_t width,
uint32_t height);

int32_t dotlottie_load_state_machine(struct DotLottiePlayer *ptr, const char *state_machine_id);

int32_t dotlottie_load_state_machine_data(struct DotLottiePlayer *ptr,
const char *state_machine_definition);

int32_t dotlottie_loop_count(struct DotLottiePlayer *ptr, uint32_t *result);

int32_t dotlottie_manifest(struct DotLottiePlayer *ptr, struct DotLottieManifest *result);
Expand All @@ -299,8 +269,6 @@ int32_t dotlottie_pause(struct DotLottiePlayer *ptr);

int32_t dotlottie_play(struct DotLottiePlayer *ptr);

int32_t dotlottie_post_event(struct DotLottiePlayer *ptr, const struct DotLottieEvent *event);

int32_t dotlottie_render(struct DotLottiePlayer *ptr);

int32_t dotlottie_request_frame(struct DotLottiePlayer *ptr, float *result);
Expand All @@ -315,18 +283,6 @@ int32_t dotlottie_segment_duration(struct DotLottiePlayer *ptr, float *result);

int32_t dotlottie_set_frame(struct DotLottiePlayer *ptr, float no);

int32_t dotlottie_set_state_machine_boolean_context(struct DotLottiePlayer *ptr,
const char *key,
bool value);

int32_t dotlottie_set_state_machine_numeric_context(struct DotLottiePlayer *ptr,
const char *key,
float value);

int32_t dotlottie_set_state_machine_string_context(struct DotLottiePlayer *ptr,
const char *key,
const char *value);

int32_t dotlottie_set_theme(struct DotLottiePlayer *ptr, const char *theme_id);

int32_t dotlottie_set_theme_data(struct DotLottiePlayer *ptr, const char *theme_data);
Expand All @@ -337,10 +293,34 @@ int32_t dotlottie_set_viewport(struct DotLottiePlayer *ptr,
int32_t w,
int32_t h);

int32_t dotlottie_start_state_machine(struct DotLottiePlayer *ptr);
int32_t dotlottie_state_machine_current_state(struct DotLottiePlayer *ptr, char *result);

int32_t dotlottie_state_machine_framework_setup(struct DotLottiePlayer *ptr, uint16_t *result);

int32_t dotlottie_state_machine_load(struct DotLottiePlayer *ptr, const char *state_machine_id);

int32_t dotlottie_state_machine_load_data(struct DotLottiePlayer *ptr,
const char *state_machine_definition);

int32_t dotlottie_state_machine_post_event(struct DotLottiePlayer *ptr,
const struct DotLottieEvent *event);

int32_t dotlottie_state_machine_set_boolean_trigger(struct DotLottiePlayer *ptr,
const char *key,
bool value);

int32_t dotlottie_state_machine_set_numeric_trigger(struct DotLottiePlayer *ptr,
const char *key,
float value);

int32_t dotlottie_state_machine_set_string_trigger(struct DotLottiePlayer *ptr,
const char *key,
const char *value);

int32_t dotlottie_state_machine_start(struct DotLottiePlayer *ptr);

int32_t dotlottie_state_machine_stop(struct DotLottiePlayer *ptr);

int32_t dotlottie_state_machine_subscribe(struct DotLottiePlayer *ptr,
struct StateMachineObserver *observer);

Expand All @@ -349,8 +329,6 @@ int32_t dotlottie_state_machine_unsubscribe(struct DotLottiePlayer *ptr,

int32_t dotlottie_stop(struct DotLottiePlayer *ptr);

int32_t dotlottie_stop_state_machine(struct DotLottiePlayer *ptr);

int32_t dotlottie_subscribe(struct DotLottiePlayer *ptr, struct Observer *observer);

int32_t dotlottie_total_frames(struct DotLottiePlayer *ptr, float *result);
Expand Down
35 changes: 18 additions & 17 deletions dotlottie-ffi/emscripten_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,25 @@ EMSCRIPTEN_BINDINGS(DotLottiePlayer)
.function("segmentDuration", &DotLottiePlayer::segment_duration)
.function("animationSize", &DotLottiePlayer::animation_size)

.function("loadStateMachine", &DotLottiePlayer::load_state_machine)
.function("startStateMachine", &DotLottiePlayer::start_state_machine)
.function("stopStateMachine", &DotLottiePlayer::stop_state_machine)
.function("stateMachineLoad", &DotLottiePlayer::state_machine_load)
.function("stateMachineStart", &DotLottiePlayer::state_machine_start)
.function("stateMachineStop", &DotLottiePlayer::state_machine_stop)
.function("stateMachineFrameworkSetup", &DotLottiePlayer::state_machine_framework_setup)
.function("setStateMachineNumericContext", &DotLottiePlayer::set_state_machine_numeric_context)
.function("setStateMachineStringContext", &DotLottiePlayer::set_state_machine_string_context)
.function("setStateMachineBooleanContext", &DotLottiePlayer::set_state_machine_boolean_context)
.function("loadStateMachineData", &DotLottiePlayer::load_state_machine_data)
.function("stateMachineLoadData", &DotLottiePlayer::state_machine_load_data)
.function("stateMachineFireEvent", &DotLottiePlayer::state_machine_fire_event)
.function("stateMachineSetNumericTrigger", &DotLottiePlayer::state_machine_set_numeric_trigger)
.function("stateMachineSetStringTrigger", &DotLottiePlayer::state_machine_set_string_trigger)
.function("stateMachineSetBooleanTrigger", &DotLottiePlayer::state_machine_set_boolean_trigger)
.function("stateMachineGetNumericTrigger", &DotLottiePlayer::state_machine_get_numeric_trigger)
.function("stateMachineGetStringTrigger", &DotLottiePlayer::state_machine_get_string_trigger)
.function("stateMachineGetBooleanTrigger", &DotLottiePlayer::state_machine_get_boolean_trigger)
.function("getLayerBounds", &DotLottiePlayer::get_layer_bounds)
.function("postBoolEvent", &DotLottiePlayer::post_bool_event)
.function("postStringEvent", &DotLottiePlayer::post_string_event)
.function("postNumericEvent", &DotLottiePlayer::post_numeric_event)
.function("postPointerDownEvent", &DotLottiePlayer::post_pointer_down_event)
.function("postPointerUpEvent", &DotLottiePlayer::post_pointer_up_event)
.function("postPointerMoveEvent", &DotLottiePlayer::post_pointer_move_event)
.function("postPointerEnterEvent", &DotLottiePlayer::post_pointer_enter_event)
.function("postPointerExitEvent", &DotLottiePlayer::post_pointer_exit_event)
.function("postSetNumericContext", &DotLottiePlayer::post_set_numeric_context);
.function("stateMachineCurrentState", &DotLottiePlayer::state_machine_current_state)
.function("stateMachinePostPointerDownEvent", &DotLottiePlayer::state_machine_post_pointer_down_event)
.function("stateMachinePostPointerUpEvent", &DotLottiePlayer::state_machine_post_pointer_up_event)
.function("stateMachinePostPointerMoveEvent", &DotLottiePlayer::state_machine_post_pointer_move_event)
.function("stateMachinePostPointerEnterEvent", &DotLottiePlayer::state_machine_post_pointer_enter_event)
.function("stateMachinePostPointerExitEvent", &DotLottiePlayer::state_machine_post_pointer_exit_event);
// .function("state_machine_subscribe", &DotLottiePlayer::state_machine_subscribe)
// .function("state_machine_unsubscribe", &DotLottiePlayer::state_machine_unsubscribe)
}
}
54 changes: 25 additions & 29 deletions dotlottie-ffi/src/dotlottie_player.udl
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,12 @@ dictionary Marker {

[Enum]
interface Event {
Bool(boolean value);
String(string value);
Numeric(f32 value);
OnPointerDown(f32 x, f32 y);
OnPointerUp(f32 x, f32 y);
OnPointerMove(f32 x, f32 y);
OnPointerEnter(f32 x, f32 y);
OnPointerExit(f32 x, f32 y);
PointerDown(f32 x, f32 y);
PointerUp(f32 x, f32 y);
PointerMove(f32 x, f32 y);
PointerEnter(f32 x, f32 y);
PointerExit(f32 x, f32 y);
OnComplete();
SetNumericContext(string key, f32 value);
};

interface DotLottiePlayer {
Expand Down Expand Up @@ -153,25 +149,25 @@ interface DotLottiePlayer {
sequence<f32> animation_size();
sequence<f32> get_layer_bounds([ByRef] string layer_name);

boolean load_state_machine([ByRef] string str);
boolean start_state_machine();
boolean stop_state_machine();
i32 post_event([ByRef] Event event);
boolean state_machine_subscribe(StateMachineObserver observer);
boolean state_machine_unsubscribe(StateMachineObserver observer);
boolean set_state_machine_numeric_context([ByRef] string key, f32 value);
boolean set_state_machine_string_context([ByRef] string key, [ByRef] string value);
boolean set_state_machine_boolean_context([ByRef] string key, boolean value);
boolean state_machine_load([ByRef] string state_machine_id);
boolean state_machine_load_data([ByRef] string state_machine);
boolean state_machine_start();
boolean state_machine_stop();
sequence<string> state_machine_framework_setup();
boolean load_state_machine_data([ByRef] string state_machine);

i32 post_bool_event(boolean value);
i32 post_string_event([ByRef] string value);
i32 post_numeric_event(f32 value);
i32 post_pointer_down_event(f32 x, f32 y);
i32 post_pointer_up_event(f32 x, f32 y);
i32 post_pointer_move_event(f32 x, f32 y);
i32 post_pointer_enter_event(f32 x, f32 y);
i32 post_pointer_exit_event(f32 x, f32 y);
i32 post_set_numeric_context([ByRef] string key, f32 value);
i32 state_machine_post_event([ByRef] Event event);
i32 state_machine_post_pointer_down_event(f32 x, f32 y);
i32 state_machine_post_pointer_up_event(f32 x, f32 y);
i32 state_machine_post_pointer_move_event(f32 x, f32 y);
i32 state_machine_post_pointer_enter_event(f32 x, f32 y);
i32 state_machine_post_pointer_exit_event(f32 x, f32 y);
void state_machine_fire_event([ByRef] string event);
boolean state_machine_set_boolean_trigger([ByRef] string key, boolean value);
boolean state_machine_set_string_trigger([ByRef] string key, [ByRef] string value);
boolean state_machine_set_numeric_trigger([ByRef] string key, f32 value);
f32 state_machine_get_numeric_trigger([ByRef] string key);
string state_machine_get_string_trigger([ByRef] string key);
boolean state_machine_get_boolean_trigger([ByRef] string key);
string state_machine_current_state();
boolean state_machine_subscribe(StateMachineObserver observer);
boolean state_machine_unsubscribe([ByRef] StateMachineObserver observer);
};
33 changes: 17 additions & 16 deletions dotlottie-ffi/src/dotlottie_player_cpp.udl
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,22 @@ interface DotLottiePlayer {
sequence<f32> animation_size();
sequence<f32> get_layer_bounds([ByRef] string layer_name);

boolean load_state_machine([ByRef] string str);
boolean start_state_machine();
boolean stop_state_machine();
boolean set_state_machine_numeric_context([ByRef] string key, f32 value);
boolean set_state_machine_string_context([ByRef] string key, [ByRef] string value);
boolean set_state_machine_boolean_context([ByRef] string key, boolean value);
boolean state_machine_load([ByRef] string state_machine_id);
boolean state_machine_load_data([ByRef] string state_machine);
boolean state_machine_start();
boolean state_machine_stop();
sequence<string> state_machine_framework_setup();
boolean load_state_machine_data([ByRef] string state_machine);
i32 post_bool_event(boolean value);
i32 post_string_event([ByRef] string value);
i32 post_numeric_event(f32 value);
i32 post_pointer_down_event(f32 x, f32 y);
i32 post_pointer_up_event(f32 x, f32 y);
i32 post_pointer_move_event(f32 x, f32 y);
i32 post_pointer_enter_event(f32 x, f32 y);
i32 post_pointer_exit_event(f32 x, f32 y);
i32 post_set_numeric_context([ByRef] string key, f32 value);
i32 state_machine_post_pointer_down_event(f32 x, f32 y);
i32 state_machine_post_pointer_up_event(f32 x, f32 y);
i32 state_machine_post_pointer_move_event(f32 x, f32 y);
i32 state_machine_post_pointer_enter_event(f32 x, f32 y);
i32 state_machine_post_pointer_exit_event(f32 x, f32 y);
void state_machine_fire_event([ByRef] string event);
string state_machine_current_state();
boolean state_machine_set_boolean_trigger([ByRef] string key, boolean value);
boolean state_machine_set_string_trigger([ByRef] string key, [ByRef] string value);
boolean state_machine_set_numeric_trigger([ByRef] string key, f32 value);
f32 state_machine_get_numeric_trigger([ByRef] string key);
string state_machine_get_string_trigger([ByRef] string key);
boolean state_machine_get_boolean_trigger([ByRef] string key);
};
Loading
Loading