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

Widget that contains a list of variable items. More...

#include <gui/widget.h>

Go to the source code of this file.

Data Structures

struct  VarItemKeyValue
 

Typedefs

typedef struct VarItemList VarItemList
 VarItemList opaque structure.
 
typedef struct VarItem VarItem
 VarItem opaque structure.
 
typedef void(* VarItemChangeCallback) (VarItem *item, void *context)
 VarItemList item callback function type.
 

Enumerations

enum  VarItemFlag { VarItemFlagMinIsInf = 1UL << 0 , VarItemFlagMaxIsInf = 1UL << 1 }
 Flags to modify the item behaviour (can be combined). More...
 

Functions

VarItemList * var_item_list_alloc (Widget *parent)
 Create a new VarItemList instance.
 
void var_item_list_free (VarItemList *instance)
 Delete a VarItemList instance and all of its items.
 
Widget * var_item_list_get_base (VarItemList *instance)
 Get a pointer to the base class instance.
 
VarItem * var_item_list_add_timebox (VarItemList *instance, const char *label, int32_t min_mn, int32_t max_mn, uint32_t step_mn, VarItemChangeCallback callback, void *context)
 Add a time selection item.
 
VarItem * var_item_list_add_spinbox (VarItemList *instance, const char *label, const char *suffix, int32_t min, int32_t max, uint32_t step, VarItemChangeCallback callback, void *context)
 Add a numeric value selection item.
 
VarItem * var_item_list_add_selector (VarItemList *instance, const char *label, const char *suffix, const char *choice_text[], uint32_t choice_count, VarItemChangeCallback callback, void *context)
 Add a value list selection item.
 
VarItem * var_item_list_add_selector_key_value (VarItemList *instance, const char *label, const char *suffix, const VarItemKeyValue *choice_key_val, uint32_t choice_count, VarItemChangeCallback callback, void *context)
 Add a key:value list select element.
 
VarItem * var_item_list_add_switch (VarItemList *instance, const char *label, VarItemChangeCallback callback, void *context)
 Add a binary switch (on-off) item.
 
void var_item_set_value (VarItem *item, int32_t value)
 Set the current item value.
 
void var_item_set_value_key_value (VarItem *item, const VarItemKeyValue *choice_key_val, int32_t value)
 Set the current item value.
 
int32_t var_item_get_value (const VarItem *item)
 Get the current item value.
 
void var_item_set_flags (VarItem *item, uint32_t flags)
 Set extra item behaviours via flags.
 
bool var_item_list_exit_edit_mode (VarItemList *instance, bool apply_changes)
 Exit edit mode and return to item selection mode.
 
void var_item_list_enter_edit_mode (VarItemList *instance, VarItem *item)
 Focus an item and enter edit mode on it.
 
void var_item_focus (VarItem *item)
 Focus on a list item.
 

Detailed Description

Widget that contains a list of variable items.

Enumeration Type Documentation

◆ VarItemFlag

Flags to modify the item behaviour (can be combined).

Enumerator
VarItemFlagMinIsInf 

Show infinity symbol instead of minimum value.

VarItemFlagMaxIsInf 

Show infinity symbol instead of maximum value.

Function Documentation

◆ var_item_get_value()

int32_t var_item_get_value ( const VarItem * item)

Get the current item value.

This function has a different meaning depending on the item type:

  • Spinbox: just get the value
  • Timebox: get the time in minutes
  • Selector: get the current choice index
  • Switch: get the current state (0 or 1)
Parameters
[in]itempointer to the item to be queried
Returns
current item value

◆ var_item_list_add_selector()

VarItem * var_item_list_add_selector ( VarItemList * instance,
const char * label,
const char * suffix,
const char * choice_text[],
uint32_t choice_count,
VarItemChangeCallback callback,
void * context )

Add a value list selection item.

Parameters
[in,out]instancepointer to the VarItemList instance to be modified
[in]labelzero-terminated string containing the item label
[in]suffixzero-terminated string containing the item suffix (may be NULL)
[in]choice_textpointer to an array of zero-terminated strings containing choice labels
[in]choice_countnumber of elements in the choice_text array
[in]callbackpointer to the function to call upon value being changed
[in,out]contextpointer to a user-specific object, will be passed to callback
Returns
pointer to the newly created VarItem instance

◆ var_item_list_add_selector_key_value()

VarItem * var_item_list_add_selector_key_value ( VarItemList * instance,
const char * label,
const char * suffix,
const VarItemKeyValue * choice_key_val,
uint32_t choice_count,
VarItemChangeCallback callback,
void * context )

Add a key:value list select element.

Parameters
[in,out]instancepointer to the VarItemList instance to be modified
[in]labelzero-terminated string containing the item label
[in]suffixzero-terminated string containing the item suffix (may be NULL)
[in]choice_key_valpointer to an array of VarItemKeyValue structures
[in]choice_countnumber of elements in the choice_text array
[in]callbackpointer to the function to call upon value being changed
[in,out]contextpointer to a user-specific object, will be passed to callback
Returns
pointer to the newly created VarItem instance

◆ var_item_list_add_spinbox()

VarItem * var_item_list_add_spinbox ( VarItemList * instance,
const char * label,
const char * suffix,
int32_t min,
int32_t max,
uint32_t step,
VarItemChangeCallback callback,
void * context )

Add a numeric value selection item.

Parameters
[in,out]instancepointer to the VarItemList instance to be modified
[in]labelzero-terminated string containing the item label
[in]suffixzero-terminated string containing the item suffix (may be NULL)
[in]minminimum allowed value
[in]maxmaximum allowed value
[in]stepstep or increment
[in]callbackpointer to the function to call upon value being changed
[in,out]contextpointer to a user-specific object, will be passed to callback
Returns
pointer to the newly created VarItem instance

◆ var_item_list_add_switch()

VarItem * var_item_list_add_switch ( VarItemList * instance,
const char * label,
VarItemChangeCallback callback,
void * context )

Add a binary switch (on-off) item.

Parameters
[in,out]instancepointer to the VarItemList instance to be modified
[in]labelzero-terminated string containing the item label
[in]callbackpointer to the function to call upon value being changed
[in,out]contextpointer to a user-specific object, will be passed to callback
Returns
pointer to the newly created VarItem instance

◆ var_item_list_add_timebox()

VarItem * var_item_list_add_timebox ( VarItemList * instance,
const char * label,
int32_t min_mn,
int32_t max_mn,
uint32_t step_mn,
VarItemChangeCallback callback,
void * context )

Add a time selection item.

Parameters
[in,out]instancepointer to the VarItemList instance to be modified
[in]labelzero-terminated string containing the item label
[in]min_mnminimum allowed value, in minutes
[in]max_mnmaximum allowed value, in minutes
[in]step_mnstep or increment, in minutes
[in]callbackpointer to the function to call upon value being changed
[in,out]contextpointer to a user-specific object, will be passed to callback
Returns
pointer to the newly created VarItem instance

◆ var_item_list_alloc()

VarItemList * var_item_list_alloc ( Widget * parent)

Create a new VarItemList instance.

Parameters
[in,out]parentpointer to the parent Widget instance
Returns
pointer to the newly created VarItemList instance

◆ var_item_list_enter_edit_mode()

void var_item_list_enter_edit_mode ( VarItemList * instance,
VarItem * item )

Focus an item and enter edit mode on it.

If another item is being edited, it is exited first.

Parameters
[in,out]instancepointer to the VarItemList instance which contains the item
[in]itemitem to focus and edit

◆ var_item_list_exit_edit_mode()

bool var_item_list_exit_edit_mode ( VarItemList * instance,
bool apply_changes )

Exit edit mode and return to item selection mode.

Parameters
[in,out]instancepointer to the VarItemList instance which contains the edited item
[in]apply_changesif false, VarItemChangeCallback will not be called
Returns
true if an item was being edited, false otherwise

◆ var_item_list_free()

void var_item_list_free ( VarItemList * instance)

Delete a VarItemList instance and all of its items.

Parameters
[in,out]instancepointer to the VarItemList instance to be deleted

◆ var_item_list_get_base()

Widget * var_item_list_get_base ( VarItemList * instance)

Get a pointer to the base class instance.

The return value can be used in all Widget methods.

Parameters
[in,out]instancepointer to the VarItemList instance to be queried
Returns
pointer to the base class instance

◆ var_item_set_flags()

void var_item_set_flags ( VarItem * item,
uint32_t flags )

Set extra item behaviours via flags.

Parameters
[in,out]itempointer to the item to be modified
[in]flagsa bitmask of flags to be set (will replace current one)

◆ var_item_set_value()

void var_item_set_value ( VarItem * item,
int32_t value )

Set the current item value.

This function has a different meaning depending on the item type:

  • Spinbox: just set the value
  • Timebox: set the time in minutes
  • Selector: set the current choice index
  • Switch: set the current state (0 or 1)
Parameters
[in,out]itempointer to the item to be modified
[in]valuevalue to be set

◆ var_item_set_value_key_value()

void var_item_set_value_key_value ( VarItem * item,
const VarItemKeyValue * choice_key_val,
int32_t value )

Set the current item value.

This function has a different meaning depending on the item type:

  • VarItemKeyValue: set the current choice index
Parameters
[in,out]itempointer to the item to be modified
[in]choice_key_valpointer to the array of VarItemKeyValue structures
[in]valuevalue to be set