Loading...
Searching...
No Matches
view.h File Reference

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.

Macros

#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.
 

Typedefs

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.
 

Enumerations

enum  ViewOrientation { ViewOrientationHorizontal , ViewOrientationHorizontalFlip , ViewOrientationVertical , ViewOrientationVerticalFlip }
 
enum  ViewModelType { ViewModelTypeNone , ViewModelTypeLockFree , ViewModelTypeLocking }
 View model types. More...
 

Functions

Viewview_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.
 

Detailed Description

GUI: View API.

Macro Definition Documentation

◆ with_view_model

#define with_view_model ( view,
type,
code,
update )
Value:
{ \
type = view_get_model(view); \
{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
viewView instance pointer
typeView model type
codeCode block that will be executed between model lock and unlock
updateBool flag, if true, view will be updated after code block. Can be variable, so code block can decide if update is needed.

Typedef Documentation

◆ ViewCallback

typedef void(* ViewCallback) (void *context)

View callback.

Parameters
contextpointer to context
Warning
called from GUI thread

◆ ViewCustomCallback

typedef bool(* ViewCustomCallback) (uint32_t event, void *context)

View Custom callback.

Parameters
eventnumber of custom event
contextpointer to context
Returns
true if event handled, false if event ignored

◆ ViewDrawCallback

typedef void(* ViewDrawCallback) (Canvas *canvas, void *model)

View Draw callback.

Parameters
canvaspointer to canvas
modelpointer to model
Warning
called from GUI thread

◆ ViewInputCallback

typedef bool(* ViewInputCallback) (InputEvent *event, void *context)

View Input callback.

Parameters
eventpointer to input event data
contextpointer 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
contextpointer 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
viewpointer to view
contextpointer to context
Warning
called from GUI thread

Enumeration Type Documentation

◆ 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.

Function Documentation

◆ view_alloc()

View * view_alloc ( void )

Allocate and init View.

Returns
View instance

◆ view_allocate_model()

void view_allocate_model ( View * view,
ViewModelType type,
size_t size )

Allocate view model.

Parameters
viewView instance
typeView Model Type
sizesize

◆ view_commit_model()

void view_commit_model ( View * view,
bool update )

Commit view model.

Parameters
viewView instance
updatetrue if you want to emit view update, false otherwise

◆ view_free()

void view_free ( View * view)

Free View.

Parameters
viewinstance

◆ view_free_model()

void view_free_model ( View * view)

Free view model data memory.

Parameters
viewView instance

◆ view_get_model()

void * view_get_model ( View * view)

Get view model data.

Parameters
viewView instance
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
viewView instance
contextcontext for callbacks

◆ view_set_custom_callback()

void view_set_custom_callback ( View * view,
ViewCustomCallback callback )

Set View Custom callback.

Parameters
viewView instance
callbackinput callback

◆ view_set_draw_callback()

void view_set_draw_callback ( View * view,
ViewDrawCallback callback )

Set View Draw callback.

Parameters
viewView instance
callbackdraw callback

◆ view_set_enter_callback()

void view_set_enter_callback ( View * view,
ViewCallback callback )

Set Enter callback.

Parameters
viewView instance
callbackcallback

◆ view_set_exit_callback()

void view_set_exit_callback ( View * view,
ViewCallback callback )

Set Exit callback.

Parameters
viewView instance
callbackcallback

◆ view_set_input_callback()

void view_set_input_callback ( View * view,
ViewInputCallback callback )

Set View Input callback.

Parameters
viewView instance
callbackinput callback

◆ view_set_orientation()

void view_set_orientation ( View * view,
ViewOrientation orientation )

Set View Orientation.

Parameters
viewView instance
orientationeither vertical or horizontal

◆ view_set_previous_callback()

void view_set_previous_callback ( View * view,
ViewNavigationCallback callback )

Set Navigation Previous callback.

Parameters
viewView instance
callbackinput callback

◆ view_set_update_callback()

void view_set_update_callback ( View * view,
ViewUpdateCallback callback )

Set Update callback.

Parameters
viewView instance
callbackcallback

◆ view_set_update_callback_context()

void view_set_update_callback_context ( View * view,
void * context )

Set View Draw callback.

Parameters
viewView instance
contextcontext for callbacks

◆ view_tie_icon_animation()

void view_tie_icon_animation ( View * view,
IconAnimation * icon_animation )

Tie IconAnimation with View.

Parameters
viewView instance
icon_animationIconAnimation instance