2021-10-03 10:36:05 +00:00
|
|
|
/**
|
|
|
|
* @file button_menu.h
|
|
|
|
* GUI: ButtonMenu view module API
|
|
|
|
*/
|
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
#pragma once
|
2021-10-03 10:36:05 +00:00
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <gui/view.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** ButtonMenu anonymous structure */
|
2021-06-02 15:16:05 +00:00
|
|
|
typedef struct ButtonMenu ButtonMenu;
|
2021-10-03 10:36:05 +00:00
|
|
|
|
|
|
|
/** ButtonMenuItem anonymous structure */
|
2021-06-02 15:16:05 +00:00
|
|
|
typedef struct ButtonMenuItem ButtonMenuItem;
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Callback for any button menu actions */
|
2021-08-11 17:51:06 +00:00
|
|
|
typedef void (*ButtonMenuItemCallback)(void* context, int32_t index, InputType type);
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Type of button. Difference in drawing buttons. */
|
2021-06-02 15:16:05 +00:00
|
|
|
typedef enum {
|
|
|
|
ButtonMenuItemTypeCommon,
|
|
|
|
ButtonMenuItemTypeControl,
|
|
|
|
} ButtonMenuItemType;
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Get button menu view
|
|
|
|
*
|
|
|
|
* @param button_menu ButtonMenu instance
|
|
|
|
*
|
|
|
|
* @return View instance that can be used for embedding
|
2021-06-02 15:16:05 +00:00
|
|
|
*/
|
|
|
|
View* button_menu_get_view(ButtonMenu* button_menu);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Clean button menu
|
|
|
|
*
|
|
|
|
* @param button_menu ButtonMenu instance
|
2021-06-02 15:16:05 +00:00
|
|
|
*/
|
|
|
|
void button_menu_clean(ButtonMenu* button_menu);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Add item to button menu instance
|
|
|
|
*
|
|
|
|
* @param button_menu ButtonMenu instance
|
|
|
|
* @param label text inside new button
|
|
|
|
* @param index value to distinct between buttons inside
|
|
|
|
* ButtonMenuItemCallback
|
|
|
|
* @param callback The callback
|
|
|
|
* @param type type of button to create. Differ by button
|
|
|
|
* drawing. Control buttons have no frames, and
|
|
|
|
* have more squared borders.
|
|
|
|
* @param callback_context The callback context
|
|
|
|
*
|
|
|
|
* @return pointer to just-created item
|
2021-06-02 15:16:05 +00:00
|
|
|
*/
|
|
|
|
ButtonMenuItem* button_menu_add_item(
|
|
|
|
ButtonMenu* button_menu,
|
|
|
|
const char* label,
|
|
|
|
int32_t index,
|
|
|
|
ButtonMenuItemCallback callback,
|
|
|
|
ButtonMenuItemType type,
|
|
|
|
void* callback_context);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Allocate and initialize new instance of ButtonMenu model
|
|
|
|
*
|
|
|
|
* @return just-created ButtonMenu model
|
2021-06-02 15:16:05 +00:00
|
|
|
*/
|
|
|
|
ButtonMenu* button_menu_alloc(void);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Free ButtonMenu element
|
|
|
|
*
|
|
|
|
* @param button_menu ButtonMenu instance
|
2021-06-02 15:16:05 +00:00
|
|
|
*/
|
|
|
|
void button_menu_free(ButtonMenu* button_menu);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Set ButtonMenu header on top of canvas
|
|
|
|
*
|
|
|
|
* @param button_menu ButtonMenu instance
|
|
|
|
* @param header header on the top of button menu
|
2021-06-02 15:16:05 +00:00
|
|
|
*/
|
|
|
|
void button_menu_set_header(ButtonMenu* button_menu, const char* header);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Set selected item
|
|
|
|
*
|
|
|
|
* @param button_menu ButtonMenu instance
|
|
|
|
* @param index index of ButtonMenu to be selected
|
2021-06-09 13:04:49 +00:00
|
|
|
*/
|
|
|
|
void button_menu_set_selected_item(ButtonMenu* button_menu, uint32_t index);
|
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|