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