Project

General

Profile

Statistics
| Revision:

root / proj / libs / graph / include / menu.h @ 362

History | View | Annotate | Download (1.33 KB)

1
#ifndef MENU_H_INCLUDED
2
#define MENU_H_INCLUDED
3

    
4
/**
5
 * @defgroup    menu_t    menu_t
6
 * @ingroup graph
7
 * @brief Menu module
8
 *
9
 * Allows to create flexible and responsive menus.
10
 *
11
 * @{
12
 */
13

    
14
#include "font.h"
15

    
16
/**
17
 * @brief Menu.
18
 */
19
typedef struct menu menu_t;
20
/**
21
 * @brief Construct menu.
22
 * @param   fnt Font to use when rendering menu options text
23
 * @return      Pointer to constructed menu, or NULL if failed.
24
 */
25
menu_t* (menu_ctor)(const font_t *fnt);
26
/**
27
 * @brief Destruct menu.
28
 * @param   p   Pointer to menu to destruct
29
 */
30
void (menu_dtor)(menu_t *p);
31
/**
32
 * @brief Add item to menu.
33
 * @param   menu    Pointer to menu
34
 * @param   s       String to be used as text for the new item
35
 * @return  SUCCESS if operation was successful, other value otherwise
36
 */
37
int (menu_add_item)(menu_t *menu, const char *s);
38
/**
39
 * @brief Update menu state.
40
 *
41
 * This function allows to check if the mouse is hovering over an item, and knowing
42
 * if an item was clicked.
43
 * @param   menu    Pointer to menu
44
 * @param   click   0 if mouse right button is clicked, other value otherwise
45
 * @return  selected option if clicked, -1 otherwise
46
 */
47
int (menu_update_state)(menu_t *menu, int click);
48
/**
49
 * @brief Draw menu on screen buffer.
50
 * @param   menu    Pointer to menu to be drawn
51
 */
52
void (menu_draw)(menu_t *menu);
53

    
54
/**
55
 * @}
56
 */
57

    
58
#endif //MENU_H_INCLUDED