GUI: View API.
More...
#include <input/input.h>
#include "icon_animation.h"
#include "canvas.h"
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
#define | VIEW_NONE 0xFFFFFFFF |
| Hides drawing view_port.
|
|
#define | VIEW_IGNORE 0xFFFFFFFE |
| Ignore navigation event.
|
|
#define | with_view_model(view, type, code, update) |
| With clause for view model.
|
|
|
typedef struct View | View |
| View, anonymous type.
|
|
typedef void(* | ViewDrawCallback) (Canvas *canvas, void *model) |
| View Draw callback.
|
|
typedef bool(* | ViewInputCallback) (InputEvent *event, void *context) |
| View Input callback.
|
|
typedef bool(* | ViewCustomCallback) (uint32_t event, void *context) |
| View Custom callback.
|
|
typedef uint32_t(* | ViewNavigationCallback) (void *context) |
| View navigation callback.
|
|
typedef void(* | ViewCallback) (void *context) |
| View callback.
|
|
typedef void(* | ViewUpdateCallback) (View *view, void *context) |
| View Update Callback Called upon model change, need to be propagated to GUI throw ViewPort update.
|
|
|
View * | view_alloc (void) |
| Allocate and init View.
|
|
void | view_free (View *view) |
| Free View.
|
|
void | view_tie_icon_animation (View *view, IconAnimation *icon_animation) |
| Tie IconAnimation with View.
|
|
void | view_set_draw_callback (View *view, ViewDrawCallback callback) |
| Set View Draw callback.
|
|
void | view_set_input_callback (View *view, ViewInputCallback callback) |
| Set View Input callback.
|
|
void | view_set_custom_callback (View *view, ViewCustomCallback callback) |
| Set View Custom callback.
|
|
void | view_set_previous_callback (View *view, ViewNavigationCallback callback) |
| Set Navigation Previous callback.
|
|
void | view_set_enter_callback (View *view, ViewCallback callback) |
| Set Enter callback.
|
|
void | view_set_exit_callback (View *view, ViewCallback callback) |
| Set Exit callback.
|
|
void | view_set_update_callback (View *view, ViewUpdateCallback callback) |
| Set Update callback.
|
|
void | view_set_update_callback_context (View *view, void *context) |
| Set View Draw callback.
|
|
void | view_set_context (View *view, void *context) |
| Set View Draw callback.
|
|
void | view_set_orientation (View *view, ViewOrientation orientation) |
| Set View Orientation.
|
|
void | view_allocate_model (View *view, ViewModelType type, size_t size) |
| Allocate view model.
|
|
void | view_free_model (View *view) |
| Free view model data memory.
|
|
void * | view_get_model (View *view) |
| Get view model data.
|
|
void | view_commit_model (View *view, bool update) |
| Commit view model.
|
|
◆ with_view_model
#define with_view_model |
( |
| view, |
|
|
| type, |
|
|
| code, |
|
|
| update ) |
Value: { \
{code}; \
view_commit_model(view, update); \
}
void * view_get_model(View *view)
Get view model data.
Definition view.c:100
With clause for view model.
- Parameters
-
view | View instance pointer |
type | View model type |
code | Code block that will be executed between model lock and unlock |
update | Bool flag, if true, view will be updated after code block. Can be variable, so code block can decide if update is needed. |
◆ ViewCallback
typedef void(* ViewCallback) (void *context) |
View callback.
- Parameters
-
context | pointer to context |
- Warning
- called from GUI thread
◆ ViewCustomCallback
typedef bool(* ViewCustomCallback) (uint32_t event, void *context) |
View Custom callback.
- Parameters
-
event | number of custom event |
context | pointer to context |
- Returns
- true if event handled, false if event ignored
◆ ViewDrawCallback
typedef void(* ViewDrawCallback) (Canvas *canvas, void *model) |
View Draw callback.
- Parameters
-
canvas | pointer to canvas |
model | pointer to model |
- Warning
- called from GUI thread
◆ ViewInputCallback
typedef bool(* ViewInputCallback) (InputEvent *event, void *context) |
View Input callback.
- Parameters
-
event | pointer to input event data |
context | pointer to context |
- Returns
- true if event handled, false if event ignored
- Warning
- called from GUI thread
◆ ViewNavigationCallback
typedef uint32_t(* ViewNavigationCallback) (void *context) |
View navigation callback.
- Parameters
-
context | pointer to context |
- Returns
- next view id
- Warning
- called from GUI thread
◆ ViewUpdateCallback
typedef void(* ViewUpdateCallback) (View *view, void *context) |
View Update Callback Called upon model change, need to be propagated to GUI throw ViewPort update.
- Parameters
-
view | pointer to view |
context | pointer to context |
- Warning
- called from GUI thread
◆ ViewModelType
View model types.
Enumerator |
---|
ViewModelTypeNone | Model is not allocated.
|
ViewModelTypeLockFree | Model consist of atomic types and/or partial update is not critical for rendering.
Lock free.
|
ViewModelTypeLocking | Model access is guarded with mutex.
Locking gui thread.
|
◆ view_alloc()
View * view_alloc |
( |
void | | ) |
|
Allocate and init View.
- Returns
- View instance
◆ view_allocate_model()
Allocate view model.
- Parameters
-
view | View instance |
type | View Model Type |
size | size |
◆ view_commit_model()
void view_commit_model |
( |
View * | view, |
|
|
bool | update ) |
Commit view model.
- Parameters
-
view | View instance |
update | true if you want to emit view update, false otherwise |
◆ view_free()
void view_free |
( |
View * | view | ) |
|
◆ view_free_model()
void view_free_model |
( |
View * | view | ) |
|
Free view model data memory.
- Parameters
-
◆ view_get_model()
void * view_get_model |
( |
View * | view | ) |
|
Get view model data.
- Parameters
-
- Returns
- pointer to model data
- Warning
- Don't forget to commit model changes
◆ view_set_context()
void view_set_context |
( |
View * | view, |
|
|
void * | context ) |
Set View Draw callback.
- Parameters
-
view | View instance |
context | context for callbacks |
◆ view_set_custom_callback()
Set View Custom callback.
- Parameters
-
view | View instance |
callback | input callback |
◆ view_set_draw_callback()
Set View Draw callback.
- Parameters
-
view | View instance |
callback | draw callback |
◆ view_set_enter_callback()
Set Enter callback.
- Parameters
-
view | View instance |
callback | callback |
◆ view_set_exit_callback()
Set Exit callback.
- Parameters
-
view | View instance |
callback | callback |
◆ view_set_input_callback()
Set View Input callback.
- Parameters
-
view | View instance |
callback | input callback |
◆ view_set_orientation()
void view_set_orientation |
( |
View * | view, |
|
|
ViewOrientation | orientation ) |
Set View Orientation.
- Parameters
-
view | View instance |
orientation | either vertical or horizontal |
◆ view_set_previous_callback()
Set Navigation Previous callback.
- Parameters
-
view | View instance |
callback | input callback |
◆ view_set_update_callback()
Set Update callback.
- Parameters
-
view | View instance |
callback | callback |
◆ view_set_update_callback_context()
void view_set_update_callback_context |
( |
View * | view, |
|
|
void * | context ) |
Set View Draw callback.
- Parameters
-
view | View instance |
context | context for callbacks |
◆ view_tie_icon_animation()
Tie IconAnimation with View.
- Parameters
-
view | View instance |
icon_animation | IconAnimation instance |