2021-10-03 10:36:05 +00:00
|
|
|
/**
|
|
|
|
* @file menu.h
|
|
|
|
* GUI: Menu view module API
|
|
|
|
*/
|
|
|
|
|
2021-09-28 13:10:13 +00:00
|
|
|
#pragma once
|
2021-10-03 10:36:05 +00:00
|
|
|
|
2021-09-28 13:10:13 +00:00
|
|
|
#include <gui/view.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Menu anonymous structure */
|
|
|
|
typedef struct Menu Menu;
|
2021-10-03 10:36:05 +00:00
|
|
|
|
|
|
|
/** Menu Item Callback */
|
2021-09-28 13:10:13 +00:00
|
|
|
typedef void (*MenuItemCallback)(void* context, uint32_t index);
|
|
|
|
|
|
|
|
/** Menu allocation and initialization
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return Menu instance
|
2021-09-28 13:10:13 +00:00
|
|
|
*/
|
|
|
|
Menu* menu_alloc();
|
|
|
|
|
|
|
|
/** Free menu
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param menu Menu instance
|
2021-09-28 13:10:13 +00:00
|
|
|
*/
|
|
|
|
void menu_free(Menu* menu);
|
|
|
|
|
|
|
|
/** Get Menu view
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param menu Menu instance
|
|
|
|
*
|
|
|
|
* @return View instance
|
2021-09-28 13:10:13 +00:00
|
|
|
*/
|
|
|
|
View* menu_get_view(Menu* menu);
|
|
|
|
|
|
|
|
/** Add item to menu
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param menu Menu instance
|
|
|
|
* @param label menu item string label
|
|
|
|
* @param icon IconAnimation instance
|
|
|
|
* @param index menu item index
|
|
|
|
* @param callback MenuItemCallback instance
|
|
|
|
* @param context pointer to context
|
2021-09-28 13:10:13 +00:00
|
|
|
*/
|
|
|
|
void menu_add_item(
|
|
|
|
Menu* menu,
|
|
|
|
const char* label,
|
2021-12-15 12:23:16 +00:00
|
|
|
const Icon* icon,
|
2021-09-28 13:10:13 +00:00
|
|
|
uint32_t index,
|
|
|
|
MenuItemCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
|
|
|
/** Clean menu
|
2021-10-03 10:36:05 +00:00
|
|
|
* @note this function does not free menu instance
|
|
|
|
*
|
|
|
|
* @param menu Menu instance
|
2021-09-28 13:10:13 +00:00
|
|
|
*/
|
2022-01-21 17:32:03 +00:00
|
|
|
void menu_reset(Menu* menu);
|
2021-09-28 13:10:13 +00:00
|
|
|
|
2021-09-29 04:18:28 +00:00
|
|
|
/** Set current menu item
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param menu Menu instance
|
|
|
|
* @param index The index
|
2021-09-29 04:18:28 +00:00
|
|
|
*/
|
|
|
|
void menu_set_selected_item(Menu* menu, uint32_t index);
|
|
|
|
|
2021-09-28 13:10:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|