Packages

Native desktop GUI framework for Gleam, powered by Iced

Current section

Files

Jump to
plushie_gleam src plushie@testing@event_decoder.erl
Raw

src/plushie@testing@event_decoder.erl

-module(plushie@testing@event_decoder).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plushie/testing/event_decoder.gleam").
-export([decode_test_event/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Wire event decoder for test backends.\n"
"\n"
" Decodes wire-format event maps (as received from the renderer) into\n"
" typed Event values. Shared between all test backends that receive\n"
" wire events, keeping decoding logic in one place.\n"
).
-file("src/plushie/testing/event_decoder.gleam", 432).
-spec split_scoped_id(binary()) -> {binary(), list(binary())}.
split_scoped_id(Id) ->
case gleam@string:split(Id, <<"/"/utf8>>) of
[] ->
{Id, []};
[Single] ->
{Single, []};
Segments ->
Local@1 = case gleam@list:last(Segments) of
{ok, Local} -> Local;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"plushie/testing/event_decoder"/utf8>>,
function => <<"split_scoped_id"/utf8>>,
line => 437,
value => _assert_fail,
start => 13977,
'end' => 14019,
pattern_start => 13988,
pattern_end => 13997})
end,
Scope = gleam@list:take(Segments, erlang:length(Segments) - 1),
{Local@1, Scope}
end.
-file("src/plushie/testing/event_decoder.gleam", 500).
-spec decode_modifiers_from_dynamic(gleam@dynamic:dynamic_()) -> plushie@event:modifiers().
decode_modifiers_from_dynamic(Raw) ->
Get_field = fun(Name) ->
case gleam@dynamic@decode:run(
Raw,
gleam@dynamic@decode:at(
[Name],
{decoder, fun gleam@dynamic@decode:decode_bool/1}
)
) of
{ok, V} ->
V;
{error, _} ->
false
end
end,
Ctrl = Get_field(<<"ctrl"/utf8>>),
{modifiers,
Get_field(<<"shift"/utf8>>),
Ctrl,
Get_field(<<"alt"/utf8>>),
Get_field(<<"logo"/utf8>>),
Ctrl}.
-file("src/plushie/testing/event_decoder.gleam", 517).
-spec modifiers_none() -> plushie@event:modifiers().
modifiers_none() ->
{modifiers, false, false, false, false, false}.
-file("src/plushie/testing/event_decoder.gleam", 483).
-spec decode_modifiers(gleam@dict:dict(binary(), gleam@dynamic:dynamic_())) -> plushie@event:modifiers().
decode_modifiers(Data) ->
case gleam_stdlib:map_get(Data, <<"modifiers"/utf8>>) of
{ok, M} ->
decode_modifiers_from_dynamic(M);
{error, _} ->
case gleam_stdlib:map_get(Data, <<"data"/utf8>>) of
{ok, D} ->
case gleam@dynamic@decode:run(
D,
gleam@dynamic@decode:at(
[<<"modifiers"/utf8>>],
{decoder, fun gleam@dynamic@decode:decode_dynamic/1}
)
) of
{ok, M@1} ->
decode_modifiers_from_dynamic(M@1);
{error, _} ->
modifiers_none()
end;
{error, _} ->
modifiers_none()
end
end.
-file("src/plushie/testing/event_decoder.gleam", 522).
?DOC(" Map wire key names to canonical key strings.\n").
-spec parse_wire_key_name(binary()) -> binary().
parse_wire_key_name(Name) ->
case Name of
<<"enter"/utf8>> ->
<<"Enter"/utf8>>;
<<"escape"/utf8>> ->
<<"Escape"/utf8>>;
<<"tab"/utf8>> ->
<<"Tab"/utf8>>;
<<"backspace"/utf8>> ->
<<"Backspace"/utf8>>;
<<"space"/utf8>> ->
<<" "/utf8>>;
<<"delete"/utf8>> ->
<<"Delete"/utf8>>;
<<"up"/utf8>> ->
<<"ArrowUp"/utf8>>;
<<"down"/utf8>> ->
<<"ArrowDown"/utf8>>;
<<"left"/utf8>> ->
<<"ArrowLeft"/utf8>>;
<<"right"/utf8>> ->
<<"ArrowRight"/utf8>>;
<<"home"/utf8>> ->
<<"Home"/utf8>>;
<<"end"/utf8>> ->
<<"End"/utf8>>;
<<"page_up"/utf8>> ->
<<"PageUp"/utf8>>;
<<"page_down"/utf8>> ->
<<"PageDown"/utf8>>;
<<"f1"/utf8>> ->
<<"F1"/utf8>>;
<<"f2"/utf8>> ->
<<"F2"/utf8>>;
<<"f3"/utf8>> ->
<<"F3"/utf8>>;
<<"f4"/utf8>> ->
<<"F4"/utf8>>;
<<"f5"/utf8>> ->
<<"F5"/utf8>>;
<<"f6"/utf8>> ->
<<"F6"/utf8>>;
<<"f7"/utf8>> ->
<<"F7"/utf8>>;
<<"f8"/utf8>> ->
<<"F8"/utf8>>;
<<"f9"/utf8>> ->
<<"F9"/utf8>>;
<<"f10"/utf8>> ->
<<"F10"/utf8>>;
<<"f11"/utf8>> ->
<<"F11"/utf8>>;
<<"f12"/utf8>> ->
<<"F12"/utf8>>;
Other ->
Other
end.
-file("src/plushie/testing/event_decoder.gleam", 556).
-spec decode_mouse_button(binary()) -> plushie@event:mouse_button().
decode_mouse_button(Name) ->
case Name of
<<"left"/utf8>> ->
left_button;
<<"right"/utf8>> ->
right_button;
<<"middle"/utf8>> ->
middle_button;
<<"back"/utf8>> ->
back_button;
<<"forward"/utf8>> ->
forward_button;
Other ->
{other_button, Other}
end.
-file("src/plushie/testing/event_decoder.gleam", 569).
-spec get_string(
gleam@dict:dict(binary(), gleam@dynamic:dynamic_()),
binary(),
binary()
) -> binary().
get_string(Data, Key, Default) ->
case gleam_stdlib:map_get(Data, Key) of
{ok, Val} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_string/1}
) of
{ok, S} ->
S;
{error, _} ->
Default
end;
{error, _} ->
Default
end.
-file("src/plushie/testing/event_decoder.gleam", 446).
-spec decode_key_press(gleam@dict:dict(binary(), gleam@dynamic:dynamic_())) -> plushie@event:event().
decode_key_press(Data) ->
Key = parse_wire_key_name(get_string(Data, <<"value"/utf8>>, <<""/utf8>>)),
Modifiers = decode_modifiers(Data),
Text = case string:length(Key) =:= 1 of
true ->
{some, Key};
false ->
none
end,
{key_press, Key, Key, Modifiers, none, standard, Text, false, false}.
-file("src/plushie/testing/event_decoder.gleam", 465).
-spec decode_key_release(gleam@dict:dict(binary(), gleam@dynamic:dynamic_())) -> plushie@event:event().
decode_key_release(Data) ->
Key = parse_wire_key_name(get_string(Data, <<"value"/utf8>>, <<""/utf8>>)),
Modifiers = decode_modifiers(Data),
Text = case string:length(Key) =:= 1 of
true ->
{some, Key};
false ->
none
end,
{key_release, Key, Key, Modifiers, none, standard, Text, false}.
-file("src/plushie/testing/event_decoder.gleam", 584).
-spec get_optional_string(
gleam@dict:dict(binary(), gleam@dynamic:dynamic_()),
binary()
) -> gleam@option:option(binary()).
get_optional_string(Data, Key) ->
case gleam_stdlib:map_get(Data, Key) of
{ok, Val} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_string/1}
) of
{ok, S} ->
{some, S};
{error, _} ->
none
end;
{error, _} ->
none
end.
-file("src/plushie/testing/event_decoder.gleam", 631).
-spec get_int(
gleam@dict:dict(binary(), gleam@dynamic:dynamic_()),
binary(),
integer()
) -> integer().
get_int(Data, Key, Default) ->
case gleam_stdlib:map_get(Data, Key) of
{ok, Val} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_int/1}
) of
{ok, I} ->
I;
{error, _} ->
Default
end;
{error, _} ->
Default
end.
-file("src/plushie/testing/event_decoder.gleam", 642).
-spec get_bool(
gleam@dict:dict(binary(), gleam@dynamic:dynamic_()),
binary(),
boolean()
) -> boolean().
get_bool(Data, Key, Default) ->
case gleam_stdlib:map_get(Data, Key) of
{ok, Val} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_bool/1}
) of
{ok, B} ->
B;
{error, _} ->
Default
end;
{error, _} ->
Default
end.
-file("src/plushie/testing/event_decoder.gleam", 653).
-spec get_dynamic(gleam@dict:dict(binary(), gleam@dynamic:dynamic_()), binary()) -> gleam@dynamic:dynamic_().
get_dynamic(Data, Key) ->
case gleam_stdlib:map_get(Data, Key) of
{ok, Val} ->
Val;
{error, _} ->
gleam@dynamic:nil()
end.
-file("src/plushie/testing/event_decoder.gleam", 598).
-spec get_float(
gleam@dict:dict(binary(), gleam@dynamic:dynamic_()),
binary(),
float()
) -> float().
get_float(Data, Key, Default) ->
case gleam_stdlib:map_get(Data, Key) of
{ok, Val} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_float/1}
) of
{ok, F} ->
F;
{error, _} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_int/1}
) of
{ok, I} ->
erlang:float(I);
{error, _} ->
Default
end
end;
{error, _} ->
Default
end.
-file("src/plushie/testing/event_decoder.gleam", 613).
-spec get_optional_float(
gleam@dict:dict(binary(), gleam@dynamic:dynamic_()),
binary()
) -> gleam@option:option(float()).
get_optional_float(Data, Key) ->
case gleam_stdlib:map_get(Data, Key) of
{ok, Val} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_float/1}
) of
{ok, F} ->
{some, F};
{error, _} ->
case gleam@dynamic@decode:run(
Val,
{decoder, fun gleam@dynamic@decode:decode_int/1}
) of
{ok, I} ->
{some, erlang:float(I)};
{error, _} ->
none
end
end;
{error, _} ->
none
end.
-file("src/plushie/testing/event_decoder.gleam", 17).
?DOC(
" Decode a wire event map into a typed Event.\n"
" Returns Ok(event) or Error(Nil) for unrecognised families.\n"
).
-spec decode_test_event(
binary(),
binary(),
gleam@dict:dict(binary(), gleam@dynamic:dynamic_())
) -> {ok, plushie@event:event()} | {error, nil}.
decode_test_event(Family, Id, Data) ->
{Local, Scope} = split_scoped_id(Id),
case Family of
<<"click"/utf8>> ->
{ok, {widget_click, Local, Scope}};
<<"input"/utf8>> ->
{ok,
{widget_input,
Local,
Scope,
get_string(Data, <<"value"/utf8>>, <<""/utf8>>)}};
<<"submit"/utf8>> ->
{ok,
{widget_submit,
Local,
Scope,
get_string(Data, <<"value"/utf8>>, <<""/utf8>>)}};
<<"toggle"/utf8>> ->
{ok,
{widget_toggle,
Local,
Scope,
get_bool(Data, <<"value"/utf8>>, false)}};
<<"select"/utf8>> ->
{ok,
{widget_select,
Local,
Scope,
get_string(Data, <<"value"/utf8>>, <<""/utf8>>)}};
<<"slide"/utf8>> ->
{ok,
{widget_slide,
Local,
Scope,
get_float(Data, <<"value"/utf8>>, +0.0)}};
<<"slide_release"/utf8>> ->
{ok,
{widget_slide_release,
Local,
Scope,
get_float(Data, <<"value"/utf8>>, +0.0)}};
<<"paste"/utf8>> ->
{ok,
{widget_paste,
Local,
Scope,
get_string(Data, <<"value"/utf8>>, <<""/utf8>>)}};
<<"sort"/utf8>> ->
{ok,
{widget_sort,
Local,
Scope,
get_string(Data, <<"column"/utf8>>, <<""/utf8>>)}};
<<"open"/utf8>> ->
{ok, {widget_open, Local, Scope}};
<<"close"/utf8>> ->
{ok, {widget_close, Local, Scope}};
<<"option_hovered"/utf8>> ->
{ok,
{widget_option_hovered,
Local,
Scope,
get_string(Data, <<"value"/utf8>>, <<""/utf8>>)}};
<<"key_binding"/utf8>> ->
{ok,
{widget_key_binding,
Local,
Scope,
get_string(Data, <<"value"/utf8>>, <<""/utf8>>)}};
<<"scroll"/utf8>> ->
Scroll_data = {scroll_data,
get_float(Data, <<"absolute_x"/utf8>>, +0.0),
get_float(Data, <<"absolute_y"/utf8>>, +0.0),
get_float(Data, <<"relative_x"/utf8>>, +0.0),
get_float(Data, <<"relative_y"/utf8>>, +0.0),
get_float(Data, <<"bounds_width"/utf8>>, +0.0),
get_float(Data, <<"bounds_height"/utf8>>, +0.0),
get_float(Data, <<"content_width"/utf8>>, +0.0),
get_float(Data, <<"content_height"/utf8>>, +0.0)},
{ok, {widget_scroll, Local, Scope, Scroll_data}};
<<"key_press"/utf8>> ->
{ok, decode_key_press(Data)};
<<"key_release"/utf8>> ->
{ok, decode_key_release(Data)};
<<"cursor_moved"/utf8>> ->
{ok,
{mouse_moved,
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
false}};
<<"cursor_entered"/utf8>> ->
{ok, {mouse_entered, false}};
<<"cursor_left"/utf8>> ->
{ok, {mouse_left, false}};
<<"button_pressed"/utf8>> ->
{ok,
{mouse_button_pressed,
decode_mouse_button(
get_string(Data, <<"button"/utf8>>, <<"left"/utf8>>)
),
false}};
<<"button_released"/utf8>> ->
{ok,
{mouse_button_released,
decode_mouse_button(
get_string(Data, <<"button"/utf8>>, <<"left"/utf8>>)
),
false}};
<<"wheel_scrolled"/utf8>> ->
{ok,
{mouse_wheel_scrolled,
get_float(Data, <<"delta_x"/utf8>>, +0.0),
get_float(Data, <<"delta_y"/utf8>>, +0.0),
line,
false}};
<<"finger_pressed"/utf8>> ->
{ok,
{touch_pressed,
get_int(Data, <<"finger_id"/utf8>>, 0),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
false}};
<<"finger_moved"/utf8>> ->
{ok,
{touch_moved,
get_int(Data, <<"finger_id"/utf8>>, 0),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
false}};
<<"finger_lifted"/utf8>> ->
{ok,
{touch_lifted,
get_int(Data, <<"finger_id"/utf8>>, 0),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
false}};
<<"finger_lost"/utf8>> ->
{ok,
{touch_lost,
get_int(Data, <<"finger_id"/utf8>>, 0),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
false}};
<<"window_opened"/utf8>> ->
{ok,
{window_opened,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"width"/utf8>>, +0.0),
get_float(Data, <<"height"/utf8>>, +0.0),
get_optional_float(Data, <<"position_x"/utf8>>),
get_optional_float(Data, <<"position_y"/utf8>>),
get_float(Data, <<"scale_factor"/utf8>>, 1.0)}};
<<"window_closed"/utf8>> ->
{ok,
{window_closed,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>)}};
<<"window_close_requested"/utf8>> ->
{ok,
{window_close_requested,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>)}};
<<"window_moved"/utf8>> ->
{ok,
{window_moved,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0)}};
<<"window_resized"/utf8>> ->
{ok,
{window_resized,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"width"/utf8>>, +0.0),
get_float(Data, <<"height"/utf8>>, +0.0)}};
<<"window_focused"/utf8>> ->
{ok,
{window_focused,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>)}};
<<"window_unfocused"/utf8>> ->
{ok,
{window_unfocused,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>)}};
<<"window_rescaled"/utf8>> ->
{ok,
{window_rescaled,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"scale_factor"/utf8>>, 1.0)}};
<<"window_file_hovered"/utf8>> ->
{ok,
{window_file_hovered,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>),
get_string(Data, <<"path"/utf8>>, <<""/utf8>>)}};
<<"window_file_dropped"/utf8>> ->
{ok,
{window_file_dropped,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>),
get_string(Data, <<"path"/utf8>>, <<""/utf8>>)}};
<<"window_files_hovered_left"/utf8>> ->
{ok,
{window_files_hovered_left,
get_string(Data, <<"window_id"/utf8>>, <<""/utf8>>)}};
<<"ime_opened"/utf8>> ->
{ok, {ime_opened, false}};
<<"ime_preedit"/utf8>> ->
{ok,
{ime_preedit,
get_string(Data, <<"text"/utf8>>, <<""/utf8>>),
none,
false}};
<<"ime_commit"/utf8>> ->
{ok,
{ime_commit,
get_string(Data, <<"text"/utf8>>, <<""/utf8>>),
false}};
<<"ime_closed"/utf8>> ->
{ok, {ime_closed, false}};
<<"modifiers_changed"/utf8>> ->
{ok, {modifiers_changed, decode_modifiers(Data), false}};
<<"mouse_area_right_press"/utf8>> ->
{ok, {mouse_area_right_press, Local, Scope}};
<<"mouse_area_right_release"/utf8>> ->
{ok, {mouse_area_right_release, Local, Scope}};
<<"mouse_area_middle_press"/utf8>> ->
{ok, {mouse_area_middle_press, Local, Scope}};
<<"mouse_area_middle_release"/utf8>> ->
{ok, {mouse_area_middle_release, Local, Scope}};
<<"mouse_area_double_click"/utf8>> ->
{ok, {mouse_area_double_click, Local, Scope}};
<<"mouse_area_enter"/utf8>> ->
{ok, {mouse_area_enter, Local, Scope}};
<<"mouse_area_exit"/utf8>> ->
{ok, {mouse_area_exit, Local, Scope}};
<<"mouse_area_move"/utf8>> ->
{ok,
{mouse_area_move,
Local,
Scope,
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0)}};
<<"mouse_area_scroll"/utf8>> ->
{ok,
{mouse_area_scroll,
Local,
Scope,
get_float(Data, <<"delta_x"/utf8>>, +0.0),
get_float(Data, <<"delta_y"/utf8>>, +0.0)}};
<<"canvas_press"/utf8>> ->
{ok,
{canvas_press,
Local,
Scope,
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
get_string(Data, <<"button"/utf8>>, <<"left"/utf8>>)}};
<<"canvas_release"/utf8>> ->
{ok,
{canvas_release,
Local,
Scope,
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
get_string(Data, <<"button"/utf8>>, <<"left"/utf8>>)}};
<<"canvas_move"/utf8>> ->
{ok,
{canvas_move,
Local,
Scope,
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0)}};
<<"canvas_scroll"/utf8>> ->
{ok,
{canvas_scroll,
Local,
Scope,
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
get_float(Data, <<"delta_x"/utf8>>, +0.0),
get_float(Data, <<"delta_y"/utf8>>, +0.0)}};
<<"canvas_element_enter"/utf8>> ->
{ok,
{canvas_element_enter,
Local,
Scope,
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
false}};
<<"canvas_element_leave"/utf8>> ->
{ok,
{canvas_element_leave,
Local,
Scope,
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>),
false}};
<<"canvas_element_click"/utf8>> ->
{ok,
{canvas_element_click,
Local,
Scope,
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
get_string(Data, <<"button"/utf8>>, <<"left"/utf8>>),
false}};
<<"canvas_element_drag"/utf8>> ->
{ok,
{canvas_element_drag,
Local,
Scope,
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
get_float(Data, <<"delta_x"/utf8>>, +0.0),
get_float(Data, <<"delta_y"/utf8>>, +0.0),
false}};
<<"canvas_element_drag_end"/utf8>> ->
{ok,
{canvas_element_drag_end,
Local,
Scope,
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>),
get_float(Data, <<"x"/utf8>>, +0.0),
get_float(Data, <<"y"/utf8>>, +0.0),
false}};
<<"canvas_element_focused"/utf8>> ->
{ok,
{canvas_element_focused,
Local,
Scope,
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>),
false}};
<<"canvas_element_blurred"/utf8>> ->
{ok,
{canvas_element_blurred,
Local,
Scope,
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>)}};
<<"canvas_focused"/utf8>> ->
{ok, {canvas_focused, Local, Scope}};
<<"canvas_blurred"/utf8>> ->
{ok, {canvas_blurred, Local, Scope}};
<<"canvas_group_focused"/utf8>> ->
{ok,
{canvas_group_focused,
Local,
Scope,
get_string(Data, <<"group_id"/utf8>>, <<""/utf8>>)}};
<<"canvas_group_blurred"/utf8>> ->
{ok,
{canvas_group_blurred,
Local,
Scope,
get_string(Data, <<"group_id"/utf8>>, <<""/utf8>>)}};
<<"diagnostic"/utf8>> ->
{ok,
{diagnostic,
get_string(Data, <<"level"/utf8>>, <<""/utf8>>),
get_string(Data, <<"element_id"/utf8>>, <<""/utf8>>),
get_string(Data, <<"code"/utf8>>, <<""/utf8>>),
get_string(Data, <<"message"/utf8>>, <<""/utf8>>)}};
<<"pane_resized"/utf8>> ->
{ok,
{pane_resized,
Local,
Scope,
get_dynamic(Data, <<"split"/utf8>>),
get_float(Data, <<"ratio"/utf8>>, 0.5)}};
<<"pane_dragged"/utf8>> ->
{ok,
{pane_dragged,
Local,
Scope,
get_dynamic(Data, <<"pane"/utf8>>),
get_dynamic(Data, <<"target"/utf8>>),
get_string(Data, <<"action"/utf8>>, <<""/utf8>>),
get_optional_string(Data, <<"region"/utf8>>),
get_optional_string(Data, <<"edge"/utf8>>)}};
<<"pane_clicked"/utf8>> ->
{ok,
{pane_clicked, Local, Scope, get_dynamic(Data, <<"pane"/utf8>>)}};
<<"pane_focus_cycle"/utf8>> ->
{ok,
{pane_focus_cycle,
Local,
Scope,
get_dynamic(Data, <<"pane"/utf8>>)}};
<<"sensor_resize"/utf8>> ->
{ok,
{sensor_resize,
Local,
Scope,
get_float(Data, <<"width"/utf8>>, +0.0),
get_float(Data, <<"height"/utf8>>, +0.0)}};
<<"animation_frame"/utf8>> ->
{ok, {animation_frame, get_int(Data, <<"timestamp"/utf8>>, 0)}};
<<"theme_changed"/utf8>> ->
{ok,
{theme_changed, get_string(Data, <<"theme"/utf8>>, <<""/utf8>>)}};
<<"all_windows_closed"/utf8>> ->
{ok, all_windows_closed};
_ ->
{error, nil}
end.