root / proj / libs / graph / include / menu.h @ 340
History | View | Annotate | Download (1.33 KB)
1 | 291 | up20180642 | #ifndef MENU_H_INCLUDED
|
---|---|---|---|
2 | #define MENU_H_INCLUDED
|
||
3 | |||
4 | 333 | up20180642 | /**
|
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 | 291 | up20180642 | #include "font.h" |
15 | |||
16 | 334 | up20180642 | /**
|
17 | * @brief Menu.
|
||
18 | */
|
||
19 | 291 | up20180642 | typedef struct menu menu_t; |
20 | 334 | up20180642 | /**
|
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 | 291 | up20180642 | menu_t* (menu_ctor)(const font_t *fnt);
|
26 | 334 | up20180642 | /**
|
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 | 293 | up20180642 | int (menu_add_item)(menu_t *menu, const char *s); |
38 | 334 | up20180642 | /**
|
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 | 291 | up20180642 | int (menu_update_state)(menu_t *menu, int click); |
48 | 334 | up20180642 | /**
|
49 | * @brief Draw menu on screen buffer.
|
||
50 | * @param menu Pointer to menu to be drawn
|
||
51 | */
|
||
52 | 291 | up20180642 | void (menu_draw)(menu_t *menu);
|
53 | |||
54 | 333 | up20180642 | /**
|
55 | * @}
|
||
56 | */
|
||
57 | |||
58 | 291 | up20180642 | #endif //MENU_H_INCLUDED |