BSB Developer Docs
Loading...
Searching...
No Matches
gui.h File Reference

GUI system APIs. More...

#include <input/input.h>
#include "widget.h"

Go to the source code of this file.

Data Structures

struct  GuiDisplayParameters
 Display parameters descriptor. More...
 

Macros

#define RECORD_GUI   "gui"
 
#define with_gui(gui, code)
 Shorthand for automatically locking and unlocking the GUI.
 

Typedefs

typedef struct Gui Gui
 Gui opaque type declaration.
 
typedef struct GuiLayer GuiLayer
 GuiLayer opaque type declaration.
 
typedef bool(* GuiInputCallback) (const InputEvent *event, void *context)
 Input callback function type.
 

Enumerations

enum  GuiDisplayId { GuiDisplayIdFront = 0 , GuiDisplayIdBack , GuiDisplayIdMax }
 Enumeration of available display identifiers. More...
 
enum  GuiLayerId {
  GuiLayerIdSystem = 0 , GuiLayerIdTop , GuiLayerIdMain , GuiLayerIdBottom ,
  GuiLayerIdMax
}
 Enumeration of available layer identifiers. More...
 

Functions

void gui_lock (Gui *instance)
 Lock the GUI system.
 
void gui_unlock (Gui *instance)
 Unlock the GUI system.
 
GuiLayer * gui_get_layer (Gui *instance, GuiLayerId layer_id)
 Get a GUI layer by its identifier.
 
Widget * gui_layer_get_root_widget (GuiLayer *layer, GuiDisplayId display_id)
 Get the root widget of a Layer on a certain display.
 
void gui_layer_add_input_callback (GuiLayer *layer, GuiInputCallback callback, void *context)
 Register a callback to report for unhandled input events on a certain layer.
 
void gui_layer_remove_input_callback (GuiLayer *layer, GuiInputCallback callback)
 Unregister a previously registered input callback.
 
const uint8_t * gui_display_get_frame_buffer (Gui *instance, GuiDisplayId display_id)
 Returns pointer to frame buffer for requested display.
 
const GuiDisplayParameters * gui_display_get_parameters (GuiDisplayId display_id)
 Get the static parameters for a given display.
 
GuiDisplayId gui_get_display_id (Widget *widget)
 Get the display a widget instance belongs to.
 

Detailed Description

GUI system APIs.

Macro Definition Documentation

◆ with_gui

#define with_gui ( gui,
code )
Value:
{ \
gui_lock(gui); \
{code}; \
gui_unlock(gui); \
}

Shorthand for automatically locking and unlocking the GUI.

Parameters
[in,out]guipointer to the Gui instance
[in]codethe code to execute when the Gui will be in locked state

Typedef Documentation

◆ GuiInputCallback

typedef bool(* GuiInputCallback) (const InputEvent *event, void *context)

Input callback function type.

Parameters
[in]eventpointer to the input event that has occurred
[in,out]contextpointer to a user-specific object, given upon callback registration
Returns
true if the event was consumed (handled) by the recipient, false otherwise

Enumeration Type Documentation

◆ GuiDisplayId

Enumeration of available display identifiers.

Enumerator
GuiDisplayIdFront 

Front (main display)

GuiDisplayIdBack 

Back (greyscale) display.

GuiDisplayIdMax 

Special value, equal to display number.

◆ GuiLayerId

enum GuiLayerId

Enumeration of available layer identifiers.

Enumerator
GuiLayerIdSystem 

System layer - for displaying statuses and other persistent info.

GuiLayerIdTop 

Top layer - for displaying dialog windows and overlays.

GuiLayerIdMain 

Main layer - for displaying regular applications.

GuiLayerIdBottom 

Bottom layer - visible only if there is nothing on layers above it.

GuiLayerIdMax 

Special value, not to be used in application code.

Function Documentation

◆ gui_display_get_frame_buffer()

const uint8_t * gui_display_get_frame_buffer ( Gui * instance,
GuiDisplayId display_id )

Returns pointer to frame buffer for requested display.

Parameters
[in,out]instancepointer to the Gui instance
[in]display_ididentifier of the display which frame buffer required
Returns
pointer to the frame buffer

◆ gui_display_get_parameters()

const GuiDisplayParameters * gui_display_get_parameters ( GuiDisplayId display_id)

Get the static parameters for a given display.

Parameters
[in]display_ididentifier of the display to query
Returns
pointer to the GuiDisplayParameters for the requested display
See also
GuiDisplayParameters

◆ gui_get_display_id()

GuiDisplayId gui_get_display_id ( Widget * widget)

Get the display a widget instance belongs to.

Parameters
[in]widgetpointer to the Widget instance to be queried
Returns
identifier of the display the widget instance is attached to

◆ gui_get_layer()

GuiLayer * gui_get_layer ( Gui * instance,
GuiLayerId layer_id )

Get a GUI layer by its identifier.

Parameters
[in,out]instancepointer to the Gui instance
[in]layer_ididentifier of the layer to retrieve
Returns
pointer to the requested GuiLayer, or NULL on invalid arguments

◆ gui_layer_add_input_callback()

void gui_layer_add_input_callback ( GuiLayer * layer,
GuiInputCallback callback,
void * context )

Register a callback to report for unhandled input events on a certain layer.

Parameters
[in,out]layerpointer to the layer to be modified
[in]callbackpointer to the function to be called upon eligible events
[in,out]contextpointer to a user-specific object (will be passed to the callback)

◆ gui_layer_get_root_widget()

Widget * gui_layer_get_root_widget ( GuiLayer * layer,
GuiDisplayId display_id )

Get the root widget of a Layer on a certain display.

A root widget cannot be moved, resized or used as the input event source.

Parameters
[in,out]layerpointer to the GuiLayer instance
[in]display_ididentifier of the display required
Returns
pointer to the root widget

◆ gui_layer_remove_input_callback()

void gui_layer_remove_input_callback ( GuiLayer * layer,
GuiInputCallback callback )

Unregister a previously registered input callback.

Parameters
[in,out]layerpointer to the layer to be modified
[in]callbackpointer to the function to be unregistered

◆ gui_lock()

void gui_lock ( Gui * instance)

Lock the GUI system.

Warning
This function MUST be called BEFORE ANY Gui-related function calls. Examples include, but not limited to: creating, deleting and modifying of Widgets, adding or removing of active widgets, etc. Failure to do so will result in possible instabilities and crashes.
Parameters
[in,out]instancepointer to the Gui instance to lock

◆ gui_unlock()

void gui_unlock ( Gui * instance)

Unlock the GUI system.

Warning
This function MUST be called AFTER calling gui_lock() and performing the required Gui-related calls. Failure to do so will result in Gui lockup.
Parameters
[in,out]instancepointer to the Gui instance to unlock