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

GUI: ViewHolder API. More...

#include <gui/view.h>
#include <gui/gui.h>

Go to the source code of this file.

Typedefs

typedef struct ViewHolder ViewHolder
 
typedef void(* FreeCallback) (void *free_context)
 Free callback type.
 
typedef void(* BackCallback) (void *back_context)
 Back callback type.
 

Functions

ViewHolderview_holder_alloc (void)
 Allocate ViewHolder.
 
void view_holder_free (ViewHolder *view_holder)
 Free ViewHolder and call Free callback.
 
void view_holder_set_view (ViewHolder *view_holder, View *view)
 Set view for ViewHolder.
 
void view_holder_set_free_callback (ViewHolder *view_holder, FreeCallback free_callback, void *free_context)
 Set Free callback.
 
void * view_holder_get_free_context (ViewHolder *view_holder)
 Free callback context getter.
 
void view_holder_set_back_callback (ViewHolder *view_holder, BackCallback back_callback, void *back_context)
 Set the back key callback.
 
void view_holder_attach_to_gui (ViewHolder *view_holder, Gui *gui)
 Attach ViewHolder to GUI.
 
void view_holder_update (View *view, void *context)
 View Update Handler.
 
void view_holder_send_to_front (ViewHolder *view_holder)
 Send ViewPort of this ViewHolder instance to front.
 
void view_holder_send_to_back (ViewHolder *view_holder)
 Send ViewPort of this ViewHolder instance to back.
 

Detailed Description

GUI: ViewHolder API.

ViewHolder is used to connect a single View to a Gui instance. This is useful in smaller applications with a simple user interface. If advanced view switching capabilites are required, consider using ViewDispatcher instead.

Warning
Views added to a ViewHolder MUST NOT be in a ViewStack at the same time.

Typedef Documentation

◆ BackCallback

typedef void(* BackCallback) (void *back_context)

Back callback type.

Warning
Will be called from the GUI thread

Function Documentation

◆ view_holder_alloc()

ViewHolder * view_holder_alloc ( void )

Allocate ViewHolder.

Returns
pointer to ViewHolder instance

◆ view_holder_attach_to_gui()

void view_holder_attach_to_gui ( ViewHolder * view_holder,
Gui * gui )

Attach ViewHolder to GUI.

Parameters
view_holderViewHolder instance
guiGUI instance to attach to

◆ view_holder_free()

void view_holder_free ( ViewHolder * view_holder)

Free ViewHolder and call Free callback.

Warning
The current view must be unset prior to freeing a ViewHolder instance.
Parameters
view_holderpointer to ViewHolder

◆ view_holder_get_free_context()

void * view_holder_get_free_context ( ViewHolder * view_holder)

Free callback context getter.

Useful if your Free callback is a module destructor, so you can get an instance of the module using this method.

Parameters
view_holderViewHolder instance
Returns
void* free callback context

◆ view_holder_send_to_back()

void view_holder_send_to_back ( ViewHolder * view_holder)

Send ViewPort of this ViewHolder instance to back.

Parameters
view_holderViewHolder instance

◆ view_holder_send_to_front()

void view_holder_send_to_front ( ViewHolder * view_holder)

Send ViewPort of this ViewHolder instance to front.

Parameters
view_holderViewHolder instance

◆ view_holder_set_back_callback()

void view_holder_set_back_callback ( ViewHolder * view_holder,
BackCallback back_callback,
void * back_context )

Set the back key callback.

The callback function will be called if the user has pressed the Back key and the current view did not handle this event.

Parameters
view_holderViewHolder instance
back_callbackpointer to the callback function
back_contextpointer to a user-specific object, can be NULL

◆ view_holder_set_free_callback()

void view_holder_set_free_callback ( ViewHolder * view_holder,
FreeCallback free_callback,
void * free_context )

Set Free callback.

Parameters
view_holderViewHolder instance
free_callbackcallback pointer
free_contextcallback context

◆ view_holder_set_view()

void view_holder_set_view ( ViewHolder * view_holder,
View * view )

Set view for ViewHolder.

Pass NULL as the view parameter to unset the current view.

Parameters
view_holderViewHolder instance
viewView instance

◆ view_holder_update()

void view_holder_update ( View * view,
void * context )

View Update Handler.

Parameters
viewView Instance
contextViewHolder instance