comparison libui/ui/checkbox.h @ 152:1008a796a9e7

ui: make UI widgets usable as actions While here add a example-ui program with move support.
author David Demelier <markand@malikania.fr>
date Thu, 15 Oct 2020 18:09:45 +0200
parents b19d076856d2
children 6992085d47fd
comparison
equal deleted inserted replaced
151:b19d076856d2 152:1008a796a9e7
20 #define MOLKO_CHECKBOX_H 20 #define MOLKO_CHECKBOX_H
21 21
22 /** 22 /**
23 * \file checkbox.h 23 * \file checkbox.h
24 * \brief GUI checkbox. 24 * \brief GUI checkbox.
25 * \ingroup ui
25 */ 26 */
26 27
27 #include <stdbool.h> 28 #include <stdbool.h>
28 29
29 union event; 30 union event;
31
32 struct action;
33 struct theme;
30 34
31 /** 35 /**
32 * \brief GUI checkbox. 36 * \brief GUI checkbox.
33 */ 37 */
34 struct checkbox { 38 struct checkbox {
69 * \param cb the checkbox 73 * \param cb the checkbox
70 */ 74 */
71 void 75 void
72 checkbox_draw(const struct checkbox *cb); 76 checkbox_draw(const struct checkbox *cb);
73 77
78 /**
79 * Convert the checkbox into an action.
80 *
81 * The following field will be set into the action:
82 *
83 * - act->data: points to cb (reference),
84 * - act->handle: a wrapper to checkbox_handle,
85 * - act->draw: a wrapper to checkbox_draw.
86 *
87 * The checkbox being an UI element is considered to never completes, as such
88 * you will need to handle this case or to use a custom update function.
89 *
90 * \note You will still need to check the checkbox state and reset it at some
91 * point.
92 * \pre cb != NULL
93 * \pre act != NULL
94 * \param cb the checkbox to reference
95 * \param act the action to fill
96 */
97 void
98 checkbox_action(struct checkbox *cb, struct action *act);
99
74 #endif /* !MOLKO_CHECKBOX_H */ 100 #endif /* !MOLKO_CHECKBOX_H */