Loading...
Searching...
No Matches
scene_manager.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <stddef.h>
9#include <stdint.h>
10#include <stdbool.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
17typedef enum {
18 SceneManagerEventTypeCustom,
19 SceneManagerEventTypeBack,
20 SceneManagerEventTypeTick,
22
25typedef struct {
27 uint32_t event;
29
31typedef void (*AppSceneOnEnterCallback)(void* context);
32
34typedef bool (*AppSceneOnEventCallback)(void* context, SceneManagerEvent event);
35
37typedef void (*AppSceneOnExitCallback)(void* context);
38
42typedef struct {
43 const AppSceneOnEnterCallback* on_enter_handlers;
44 const AppSceneOnEventCallback* on_event_handlers;
45 const AppSceneOnExitCallback* on_exit_handlers;
46 const uint32_t scene_num;
48
49typedef struct SceneManager SceneManager;
50
57void scene_manager_set_scene_state(SceneManager* scene_manager, uint32_t scene_id, uint32_t state);
58
66uint32_t scene_manager_get_scene_state(const SceneManager* scene_manager, uint32_t scene_id);
67
77SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context);
78
83void scene_manager_free(SceneManager* scene_manager);
84
94bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t custom_event);
95
105
113
119void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id);
120
127bool scene_manager_previous_scene(SceneManager* scene_manager);
128
136bool scene_manager_has_previous_scene(const SceneManager* scene_manager, uint32_t scene_id);
137
146 SceneManager* scene_manager,
147 uint32_t scene_id);
148
158 SceneManager* scene_manager,
159 const uint32_t* scene_ids,
160 size_t scene_ids_size);
161
170 SceneManager* scene_manager,
171 uint32_t scene_id);
172
177void scene_manager_stop(SceneManager* scene_manager);
178
179#ifdef __cplusplus
180}
181#endif
bool scene_manager_search_and_switch_to_another_scene(SceneManager *scene_manager, uint32_t scene_id)
Clear Scene stack and switch to another Scene.
Definition scene_manager.c:208
SceneManagerEventType
Scene Manager events type.
Definition scene_manager.h:17
bool scene_manager_search_and_switch_to_previous_scene_one_of(SceneManager *scene_manager, const uint32_t *scene_ids, size_t scene_ids_size)
Search and switch to previous Scene, multiple choice.
Definition scene_manager.c:165
bool scene_manager_handle_back_event(SceneManager *scene_manager)
Back event handler.
Definition scene_manager.c:60
uint32_t scene_manager_get_scene_state(const SceneManager *scene_manager, uint32_t scene_id)
Get Scene state.
Definition scene_manager.c:34
bool scene_manager_search_and_switch_to_previous_scene(SceneManager *scene_manager, uint32_t scene_id)
Search and switch to previous Scene.
Definition scene_manager.c:130
bool(* AppSceneOnEventCallback)(void *context, SceneManagerEvent event)
Prototype for Scene on_event handler.
Definition scene_manager.h:34
void scene_manager_stop(SceneManager *scene_manager)
Exit from current scene.
Definition scene_manager.c:233
SceneManager * scene_manager_alloc(const SceneManagerHandlers *app_scene_handlers, void *context)
Scene Manager allocation and configuration.
Definition scene_manager.c:4
void scene_manager_next_scene(SceneManager *scene_manager, uint32_t next_scene_id)
Add and run next Scene.
Definition scene_manager.c:95
void(* AppSceneOnEnterCallback)(void *context)
Prototype for Scene on_enter handler.
Definition scene_manager.h:31
bool scene_manager_has_previous_scene(const SceneManager *scene_manager, uint32_t scene_id)
Search previous Scene.
Definition scene_manager.c:184
void(* AppSceneOnExitCallback)(void *context)
Prototype for Scene on_exit handler.
Definition scene_manager.h:37
bool scene_manager_handle_custom_event(SceneManager *scene_manager, uint32_t custom_event)
Custom event handler.
Definition scene_manager.c:41
void scene_manager_set_scene_state(SceneManager *scene_manager, uint32_t scene_id, uint32_t state)
Set Scene state.
Definition scene_manager.c:27
void scene_manager_handle_tick_event(SceneManager *scene_manager)
Tick event handler.
Definition scene_manager.c:81
bool scene_manager_previous_scene(SceneManager *scene_manager)
Run previous Scene.
Definition scene_manager.c:109
void scene_manager_free(SceneManager *scene_manager)
Free Scene Manager with allocated Scenes.
Definition scene_manager.c:18
Scene Manager event.
Definition scene_manager.h:25
Scene Manager configuration structure Contains array of Scene handlers.
Definition scene_manager.h:42
Definition scene_manager_i.h:17