1#include <enqueue_entity_event.h>
2#include <stdio.h>
3
4
5
6
7
8
9
11
12
13typedef struct {
14 double width, height;
15} Resize;
16
18
20
21
23 printf("clicked on %s!\n", path);
24 ecs_os_free(path);
25}
26
28
29 Resize *p = it->
param;
31 printf("resized %s to {%.0f, %.0f}!\n", path, p->width, p->height);
32 ecs_os_free(path);
33}
34
35int main(int argc, char *argv[]) {
37
40
41
43
44
45
47 .query.terms = {{ .id =
EcsAny, .src.id = widget }},
48 .events = { Click },
49 .callback = OnClick
50 });
51
52
54 .query.terms = {{ .id =
EcsAny, .src.id = widget }},
55 .events = {
ecs_id(Resize) },
56 .callback = OnResize
57 });
58
60
61
63 .event = Click,
64 .entity = widget
65 });
66
67
70 .entity = widget,
71 .param = &(Resize){100, 200}
72 });
73
74 printf("Events enqueued\n");
75
76
78
80
81
82
83
84
85}
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
bool ecs_is_stage(const ecs_world_t *world)
Test whether a world object is a stage.
void ecs_merge(ecs_world_t *stage)
Merge a stage.
ecs_world_t * ecs_get_stage(const ecs_world_t *world, int32_t stage_id)
Get stage-specific world pointer.
ecs_id_t ecs_entity_t
An entity identifier.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
#define ECS_TAG_DECLARE
Forward declare a tag.
#define ecs_entity(world,...)
Shorthand for creating an entity with ecs_entity_init().
#define ECS_COMPONENT_DEFINE(world, id_)
Define a forward-declared component.
#define ecs_observer(world,...)
Shorthand for creating an observer with ecs_observer_init().
#define ECS_TAG_DEFINE(world, id_)
Define a forward-declared tag.
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
#define ecs_get_path(world, child)
Get path from root.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return the field source.
void ecs_enqueue(ecs_world_t *world, ecs_event_desc_t *desc)
Enqueue an event.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.
void * param
Param passed to ecs_run().