unleashed-firmware/applications/gui/modules/submenu.h
gornekich 61c8f3325a
[FL-1217] Menu refactoring (#726)
* menu: remove dead code
* loader: change views from modules instead of menu service
* dolphin: start main menu with loader API
* applications: don't start menu service
* loader: add debug tools menu
* gui modules: introduce menu model
* loader: remove calls to menu service API
* gui modules: implement menu module
* loader: add menu view
* gui menu: add animation
* applications: remove menu service
* gui modules: rename icon_menu -> menu
* loader: clean up code
* menu module: add documentation, format code
* menu: remove unused parameter
* desktop: use loader to launch primary menu
* Applications: cleaner makefile app declaration. Loader: application autostart
* Gui: cleanup menu and submenu API.

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-09-28 16:10:13 +03:00

68 lines
1.5 KiB
C

#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Submenu anonymous structure */
typedef struct Submenu Submenu;
typedef void (*SubmenuItemCallback)(void* context, uint32_t index);
/**
* @brief Allocate and initialize submenu
* This submenu is used to select one option
*/
Submenu* submenu_alloc();
/**
* @brief Deinitialize and free submenu
* @param submenu - Submenu instance
*/
void submenu_free(Submenu* submenu);
/**
* @brief Get submenu view
* @param submenu - Submenu instance
* @return View instance that can be used for embedding
*/
View* submenu_get_view(Submenu* submenu);
/**
* @brief Add item to submenu
* @param submenu - Submenu instance
* @param label - menu item label
* @param index - menu item index, used for callback, may be the same with other items
* @param callback - menu item callback
* @param callback_context - menu item callback context
*/
void submenu_add_item(
Submenu* submenu,
const char* label,
uint32_t index,
SubmenuItemCallback callback,
void* callback_context);
/**
* @brief Remove all items from submenu
* @param submenu - Submenu instance
*/
void submenu_clean(Submenu* submenu);
/**
* @brief Set submenu item selector
* @param submenu
* @param index
*/
void submenu_set_selected_item(Submenu* submenu, uint32_t index);
/**
* @brief Set optional header for submenu
* @param submenu - submenu entity
* @param header - header to set
*/
void submenu_set_header(Submenu* submenu, const char* header);
#ifdef __cplusplus
}
#endif