2021-10-03 10:36:05 +00:00
|
|
|
/**
|
|
|
|
* @file variable-item-list.h
|
|
|
|
* GUI: VariableItemList view module API
|
|
|
|
*/
|
|
|
|
|
2021-07-04 22:03:56 +00:00
|
|
|
#pragma once
|
2021-10-03 10:36:05 +00:00
|
|
|
|
2021-07-04 22:03:56 +00:00
|
|
|
#include <gui/view.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct VariableItemList VariableItemList;
|
|
|
|
typedef struct VariableItem VariableItem;
|
|
|
|
typedef void (*VariableItemChangeCallback)(VariableItem* item);
|
2021-09-30 20:03:28 +00:00
|
|
|
typedef void (*VariableItemListEnterCallback)(void* context, uint32_t index);
|
2021-07-04 22:03:56 +00:00
|
|
|
|
|
|
|
/** Allocate and initialize VariableItemList
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return VariableItemList*
|
2021-07-04 22:03:56 +00:00
|
|
|
*/
|
|
|
|
VariableItemList* variable_item_list_alloc();
|
|
|
|
|
|
|
|
/** Deinitialize and free VariableItemList
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
2021-07-04 22:03:56 +00:00
|
|
|
*/
|
|
|
|
void variable_item_list_free(VariableItemList* variable_item_list);
|
2021-09-10 00:29:57 +00:00
|
|
|
|
2021-09-30 20:03:28 +00:00
|
|
|
/** Clear all elements from list
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
2021-09-30 20:03:28 +00:00
|
|
|
*/
|
2021-09-10 00:29:57 +00:00
|
|
|
void variable_item_list_clean(VariableItemList* variable_item_list);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Get VariableItemList View instance
|
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
|
|
|
*
|
|
|
|
* @return View instance
|
|
|
|
*/
|
2021-07-04 22:03:56 +00:00
|
|
|
View* variable_item_list_get_view(VariableItemList* variable_item_list);
|
|
|
|
|
|
|
|
/** Add item to VariableItemList
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
|
|
|
* @param label item name
|
|
|
|
* @param values_count item values count
|
|
|
|
* @param change_callback called on value change in gui
|
|
|
|
* @param context item context
|
|
|
|
*
|
|
|
|
* @return VariableItem* item instance
|
2021-07-04 22:03:56 +00:00
|
|
|
*/
|
|
|
|
VariableItem* variable_item_list_add(
|
|
|
|
VariableItemList* variable_item_list,
|
|
|
|
const char* label,
|
|
|
|
uint8_t values_count,
|
|
|
|
VariableItemChangeCallback change_callback,
|
|
|
|
void* context);
|
|
|
|
|
2021-09-30 20:03:28 +00:00
|
|
|
/** Set enter callback
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
|
|
|
* @param callback VariableItemListEnterCallback instance
|
|
|
|
* @param context pointer to context
|
2021-09-30 20:03:28 +00:00
|
|
|
*/
|
|
|
|
void variable_item_list_set_enter_callback(
|
|
|
|
VariableItemList* variable_item_list,
|
|
|
|
VariableItemListEnterCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
2021-07-04 22:03:56 +00:00
|
|
|
/** Set item current selected index
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
* @param current_value_index The current value index
|
2021-07-04 22:03:56 +00:00
|
|
|
*/
|
|
|
|
void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index);
|
|
|
|
|
|
|
|
/** Set item current selected text
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
* @param current_value_text The current value text
|
2021-07-04 22:03:56 +00:00
|
|
|
*/
|
|
|
|
void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text);
|
|
|
|
|
|
|
|
/** Get item current selected index
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
*
|
|
|
|
* @return uint8_t current selected index
|
2021-07-04 22:03:56 +00:00
|
|
|
*/
|
|
|
|
uint8_t variable_item_get_current_value_index(VariableItem* item);
|
|
|
|
|
|
|
|
/** Get item context
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
*
|
|
|
|
* @return void* item context
|
2021-07-04 22:03:56 +00:00
|
|
|
*/
|
|
|
|
void* variable_item_get_context(VariableItem* item);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2021-10-03 10:36:05 +00:00
|
|
|
#endif
|