comparison libui/ui/button.h @ 148:c577c15df07f

misc: split libraries, closes #2496
author David Demelier <markand@malikania.fr>
date Thu, 15 Oct 2020 10:32:18 +0200
parents libcore/core/button.h@b386d25832c8
children b19d076856d2
comparison
equal deleted inserted replaced
147:b386d25832c8 148:c577c15df07f
1 /*
2 * button.h -- GUI button
3 *
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef MOLKO_BUTTON_H
20 #define MOLKO_BUTTON_H
21
22 /**
23 * \file button.h
24 * \brief GUI button.
25 */
26
27 union event;
28
29 struct theme;
30
31 /**
32 * \brief Button state.
33 */
34 enum button_state {
35 BUTTON_STATE_NONE, /*!< Button is inactive. */
36 BUTTON_STATE_PRESSED, /*!< Button is currently pressed. */
37 BUTTON_STATE_ACTIVATED /*!< Button is considered activated. */
38 };
39
40 /**
41 * \brief GUI button.
42 */
43 struct button {
44 int x; /*!< (+) Position in x. */
45 int y; /*!< (+) Position in y. */
46 unsigned int w; /*!< (+) Width. */
47 unsigned int h; /*!< (+) Height. */
48 const char *text; /*!< (+&) Text to draw. */
49 enum button_state state; /*!< (+) Button state. */
50 struct theme *theme; /*!< (+&?) Theme to use. */
51 };
52
53 /**
54 * Handle the event.
55 *
56 * You should always call this function even if the event is completely
57 * unrelated.
58 *
59 * \pre button != NULL
60 * \pre ev != NULL
61 * \param button the button
62 * \param ev the event
63 */
64 void
65 button_handle(struct button *button, const union event *ev);
66
67 /**
68 * Use this function once the button has been considered activated.
69 *
70 * \pre button != NULL
71 * \param button the button
72 */
73 void
74 button_reset(struct button *button);
75
76 /**
77 * Draw the button.
78 *
79 * \pre button != NULL
80 * \param button the button
81 */
82 void
83 button_draw(struct button *button);
84
85 #endif /* !MOLKO_BUTTON_H */