Welcome to mirror list, hosted at ThFree Co, Russian Federation.

scene_manager.h « gui « applications - github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6916285302c8a60c04da4540f80b7c789754ce08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**
 * @file scene_manager.h
 * GUI: SceneManager API
 */

#pragma once

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Scene Manager events type */
typedef enum {
    SceneManagerEventTypeCustom,
    SceneManagerEventTypeBack,
    SceneManagerEventTypeTick,
} SceneManagerEventType;

/** Scene Manager event
 */
typedef struct {
    SceneManagerEventType type;
    uint32_t event;
} SceneManagerEvent;

/** Prototype for Scene on_enter handler */
typedef void (*AppSceneOnEnterCallback)(void* context);

/** Prototype for Scene on_event handler */
typedef bool (*AppSceneOnEventCallback)(void* context, SceneManagerEvent event);

/** Prototype for Scene on_exit handler */
typedef void (*AppSceneOnExitCallback)(void* context);

/** Scene Manager configuration structure
 * Contains array of Scene handlers
 */
typedef struct {
    const AppSceneOnEnterCallback* on_enter_handlers;
    const AppSceneOnEventCallback* on_event_handlers;
    const AppSceneOnExitCallback* on_exit_handlers;
    const uint32_t scene_num;
} SceneManagerHandlers;

typedef struct SceneManager SceneManager;

/** Set Scene state
 *
 * @param      scene_manager  SceneManager instance
 * @param      scene_id       Scene ID
 * @param      state          Scene new state
 */
void scene_manager_set_scene_state(SceneManager* scene_manager, uint32_t scene_id, uint32_t state);

/** Get Scene state
 *
 * @param      scene_manager  SceneManager instance
 * @param      scene_id       Scene ID
 *
 * @return     Scene state
 */
uint32_t scene_manager_get_scene_state(SceneManager* scene_manager, uint32_t scene_id);

/** Scene Manager allocation and configuration
 *
 * Scene Manager allocates all scenes internally
 *
 * @param      app_scene_handlers  SceneManagerHandlers instance
 * @param      context             context to be set on Scene handlers calls
 *
 * @return     SceneManager instance
 */
SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context);

/** Free Scene Manager with allocated Scenes
 *
 * @param      scene_manager  SceneManager instance
 */
void scene_manager_free(SceneManager* scene_manager);

/** Custom event handler
 *
 * Calls Scene event handler with Custom event parameter
 *
 * @param      scene_manager  SceneManager instance
 * @param      custom_event   Custom event code
 *
 * @return     true if event was consumed, false otherwise
 */
bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t custom_event);

/** Back event handler
 *
 * Calls Scene event handler with Back event parameter
 *
 * @param      scene_manager  SceneManager instance
 *
 * @return     true if event was consumed, false otherwise
 */
bool scene_manager_handle_back_event(SceneManager* scene_manager);

/** Tick event handler
 *
 * Calls Scene event handler with Tick event parameter
 *
 * @param      scene_manager  SceneManager instance
 * @return     true if event was consumed, false otherwise
 */
void scene_manager_handle_tick_event(SceneManager* scene_manager);

/** Add and run next Scene
 *
 * @param      scene_manager  SceneManager instance
 * @param      next_scene_id  next Scene ID
 */
void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id);

/** Run previous Scene
 *
 * @param      scene_manager  SceneManager instance
 *
 * @return     true if previous scene was found, false otherwise
 */
bool scene_manager_previous_scene(SceneManager* scene_manager);

/** Search previous Scene
 *
 * @param      scene_manager  SceneManager instance
 * @param      scene_id       Scene ID
 *
 * @return     true if previous scene was found, false otherwise
 */
bool scene_manager_has_previous_scene(SceneManager* scene_manager, uint32_t scene_id);

/** Search and switch to previous Scene
 *
 * @param      scene_manager  SceneManager instance
 * @param      scene_id       Scene ID
 *
 * @return     true if previous scene was found, false otherwise
 */
bool scene_manager_search_and_switch_to_previous_scene(
    SceneManager* scene_manager,
    uint32_t scene_id);

/** Clear Scene stack and switch to another Scene
 *
 * @param      scene_manager  SceneManager instance
 * @param      scene_id       Scene ID
 *
 * @return     true if previous scene was found, false otherwise
 */
bool scene_manager_search_and_switch_to_another_scene(
    SceneManager* scene_manager,
    uint32_t scene_id);

/** Exit from current scene
 *
 * @param      scene_manager  SceneManager instance
 */
void scene_manager_stop(SceneManager* scene_manager);

#ifdef __cplusplus
}
#endif