2021-10-03 13:36:05 +03:00
|
|
|
/**
|
2022-01-05 19:10:18 +03:00
|
|
|
* @file variable_item_list.h
|
2021-10-03 13:36:05 +03:00
|
|
|
* GUI: VariableItemList view module API
|
|
|
|
*/
|
|
|
|
|
2021-07-05 01:03:56 +03:00
|
|
|
#pragma once
|
2021-10-03 13:36:05 +03:00
|
|
|
|
2021-07-05 01:03:56 +03: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 23:03:28 +03:00
|
|
|
typedef void (*VariableItemListEnterCallback)(void* context, uint32_t index);
|
2021-07-05 01:03:56 +03:00
|
|
|
|
|
|
|
/** Allocate and initialize VariableItemList
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @return VariableItemList*
|
2021-07-05 01:03:56 +03:00
|
|
|
*/
|
|
|
|
VariableItemList* variable_item_list_alloc();
|
|
|
|
|
|
|
|
/** Deinitialize and free VariableItemList
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
2021-07-05 01:03:56 +03:00
|
|
|
*/
|
|
|
|
void variable_item_list_free(VariableItemList* variable_item_list);
|
2021-09-10 03:29:57 +03:00
|
|
|
|
2021-09-30 23:03:28 +03:00
|
|
|
/** Clear all elements from list
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
2021-09-30 23:03:28 +03:00
|
|
|
*/
|
2022-01-21 20:32:03 +03:00
|
|
|
void variable_item_list_reset(VariableItemList* variable_item_list);
|
2021-09-10 03:29:57 +03:00
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Get VariableItemList View instance
|
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
|
|
|
*
|
|
|
|
* @return View instance
|
|
|
|
*/
|
2021-07-05 01:03:56 +03:00
|
|
|
View* variable_item_list_get_view(VariableItemList* variable_item_list);
|
|
|
|
|
|
|
|
/** Add item to VariableItemList
|
2021-10-03 13:36:05 +03: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-05 01:03:56 +03: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 23:03:28 +03:00
|
|
|
/** Set enter callback
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param variable_item_list VariableItemList instance
|
|
|
|
* @param callback VariableItemListEnterCallback instance
|
|
|
|
* @param context pointer to context
|
2021-09-30 23:03:28 +03:00
|
|
|
*/
|
|
|
|
void variable_item_list_set_enter_callback(
|
|
|
|
VariableItemList* variable_item_list,
|
|
|
|
VariableItemListEnterCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
2021-11-04 22:33:28 +03:00
|
|
|
void variable_item_list_set_selected_item(VariableItemList* variable_item_list, uint8_t index);
|
|
|
|
|
|
|
|
uint8_t variable_item_list_get_selected_item_index(VariableItemList* variable_item_list);
|
|
|
|
|
2021-07-05 01:03:56 +03:00
|
|
|
/** Set item current selected index
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
* @param current_value_index The current value index
|
2021-07-05 01:03:56 +03:00
|
|
|
*/
|
|
|
|
void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index);
|
|
|
|
|
2022-10-18 18:06:18 +03:00
|
|
|
/** Set number of values for item
|
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
* @param values_count The new values count
|
|
|
|
*/
|
|
|
|
void variable_item_set_values_count(VariableItem* item, uint8_t values_count);
|
|
|
|
|
2021-07-05 01:03:56 +03:00
|
|
|
/** Set item current selected text
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
* @param current_value_text The current value text
|
2021-07-05 01:03:56 +03:00
|
|
|
*/
|
|
|
|
void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text);
|
|
|
|
|
2023-05-13 00:14:22 +03:00
|
|
|
/** Set item locked state and text
|
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
* @param locked Is item locked boolean
|
|
|
|
* @param locked_message The locked message text
|
|
|
|
*/
|
|
|
|
void variable_item_set_locked(VariableItem* item, bool locked, const char* locked_message);
|
|
|
|
|
2021-07-05 01:03:56 +03:00
|
|
|
/** Get item current selected index
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
*
|
|
|
|
* @return uint8_t current selected index
|
2021-07-05 01:03:56 +03:00
|
|
|
*/
|
|
|
|
uint8_t variable_item_get_current_value_index(VariableItem* item);
|
|
|
|
|
|
|
|
/** Get item context
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param item VariableItem* instance
|
|
|
|
*
|
|
|
|
* @return void* item context
|
2021-07-05 01:03:56 +03:00
|
|
|
*/
|
|
|
|
void* variable_item_get_context(VariableItem* item);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2021-10-03 13:36:05 +03:00
|
|
|
#endif
|