Loading...
Searching...
No Matches
view.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <input/input.h>
9
10#include "icon_animation.h"
11#include "canvas.h"
12
13#include <stddef.h>
14#include <stdint.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
21#define VIEW_NONE 0xFFFFFFFF
22
24#define VIEW_IGNORE 0xFFFFFFFE
25
26typedef enum {
27 ViewOrientationHorizontal,
28 ViewOrientationHorizontalFlip,
29 ViewOrientationVertical,
30 ViewOrientationVerticalFlip,
31} ViewOrientation;
32
34typedef struct View View;
35
41typedef void (*ViewDrawCallback)(Canvas* canvas, void* model);
42
49typedef bool (*ViewInputCallback)(InputEvent* event, void* context);
50
56typedef bool (*ViewCustomCallback)(uint32_t event, void* context);
57
63typedef uint32_t (*ViewNavigationCallback)(void* context);
64
69typedef void (*ViewCallback)(void* context);
70
77typedef void (*ViewUpdateCallback)(View* view, void* context);
78
92
96View* view_alloc(void);
97
102void view_free(View* view);
103
109void view_tie_icon_animation(View* view, IconAnimation* icon_animation);
110
116void view_set_draw_callback(View* view, ViewDrawCallback callback);
117
124
131
138
144void view_set_enter_callback(View* view, ViewCallback callback);
145
151void view_set_exit_callback(View* view, ViewCallback callback);
152
159
165void view_set_update_callback_context(View* view, void* context);
166
172void view_set_context(View* view, void* context);
173
179void view_set_orientation(View* view, ViewOrientation orientation);
180
187void view_allocate_model(View* view, ViewModelType type, size_t size);
188
193void view_free_model(View* view);
194
202void* view_get_model(View* view);
203
209void view_commit_model(View* view, bool update);
210
211#ifdef __cplusplus
212}
213#endif
214
215#ifdef __cplusplus
216#define with_view_model_cpp(view, type, var, code, update) \
217 { \
218 type var = static_cast<type>(view_get_model(view)); \
219 {code}; \
220 view_commit_model(view, update); \
221 }
222#else
231#define with_view_model(view, type, code, update) \
232 { \
233 type = view_get_model(view); \
234 {code}; \
235 view_commit_model(view, update); \
236 }
237#endif
GUI: Canvas API.
GUI: IconAnimation API.
Input: main API.
Canvas structure.
Definition canvas_i.h:40
Definition icon_animation_i.h:12
Input Event, dispatches with FuriPubSub.
Definition input.h:31
Definition view_i.h:16
void view_set_orientation(View *view, ViewOrientation orientation)
Set View Orientation.
Definition view.c:65
void view_set_context(View *view, void *context)
Set View Draw callback.
Definition view.c:60
void(* ViewDrawCallback)(Canvas *canvas, void *model)
View Draw callback.
Definition view.h:41
void view_commit_model(View *view, bool update)
Commit view model.
Definition view.c:110
void view_set_draw_callback(View *view, ViewDrawCallback callback)
Set View Draw callback.
Definition view.c:20
void view_set_previous_callback(View *view, ViewNavigationCallback callback)
Set Navigation Previous callback.
Definition view.c:35
void view_set_update_callback_context(View *view, void *context)
Set View Draw callback.
Definition view.c:55
void(* ViewCallback)(void *context)
View callback.
Definition view.h:69
bool(* ViewCustomCallback)(uint32_t event, void *context)
View Custom callback.
Definition view.h:56
bool(* ViewInputCallback)(InputEvent *event, void *context)
View Input callback.
Definition view.h:49
void view_allocate_model(View *view, ViewModelType type, size_t size)
Allocate view model.
Definition view.c:70
void view_free_model(View *view)
Free view model data memory.
Definition view.c:87
void view_set_enter_callback(View *view, ViewCallback callback)
Set Enter callback.
Definition view.c:40
void view_set_exit_callback(View *view, ViewCallback callback)
Set Exit callback.
Definition view.c:45
void(* ViewUpdateCallback)(View *view, void *context)
View Update Callback Called upon model change, need to be propagated to GUI throw ViewPort update.
Definition view.h:77
void * view_get_model(View *view)
Get view model data.
Definition view.c:100
uint32_t(* ViewNavigationCallback)(void *context)
View navigation callback.
Definition view.h:63
void view_set_custom_callback(View *view, ViewCustomCallback callback)
Set View Custom callback.
Definition view.c:30
View * view_alloc(void)
Allocate and init View.
Definition view.c:3
void view_free(View *view)
Free View.
Definition view.c:9
void view_set_update_callback(View *view, ViewUpdateCallback callback)
Set Update callback.
Definition view.c:50
void view_set_input_callback(View *view, ViewInputCallback callback)
Set View Input callback.
Definition view.c:25
void view_tie_icon_animation(View *view, IconAnimation *icon_animation)
Tie IconAnimation with View.
Definition view.c:15
ViewModelType
View model types.
Definition view.h:80
@ ViewModelTypeNone
Model is not allocated.
Definition view.h:82
@ ViewModelTypeLockFree
Model consist of atomic types and/or partial update is not critical for rendering.
Definition view.h:86
@ ViewModelTypeLocking
Model access is guarded with mutex.
Definition view.h:90