comparison src/libmlk-ui/ui/gridmenu.h @ 320:8f9937403749

misc: improve loading of data
author David Demelier <markand@malikania.fr>
date Fri, 01 Oct 2021 20:30:00 +0200
parents libmlk-ui/ui/gridmenu.h@d01e83210ca2
children 19782ea1cf4a
comparison
equal deleted inserted replaced
319:b843eef4cc35 320:8f9937403749
1 /*
2 * gridmenu.h -- GUI grid menu
3 *
4 * Copyright (c) 2020-2021 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_UI_GRIDMENU_H
20 #define MOLKO_UI_GRIDMENU_H
21
22 #include <stddef.h>
23
24 #include <core/core.h>
25 #include <core/texture.h>
26
27 #include "label.h"
28
29 #define GRIDMENU_ENTRY_MAX (256)
30
31 struct theme;
32
33 union event;
34
35 enum gridmenu_state {
36 GRIDMENU_STATE_NONE,
37 GRIDMENU_STATE_ACTIVATED
38 };
39
40 struct gridmenu_texture {
41 int rely;
42 unsigned int relh;
43 unsigned int eltw;
44 unsigned int elth;
45 unsigned int spacev;
46 unsigned int spaceh;
47 struct texture texture;
48 struct label labels[GRIDMENU_ENTRY_MAX];
49 };
50
51 struct gridmenu {
52 int x;
53 int y;
54 unsigned int w;
55 unsigned int h;
56 enum gridmenu_state state;
57 size_t selected;
58 const struct theme *theme;
59 const char *menu[GRIDMENU_ENTRY_MAX];
60 unsigned int nrows;
61 unsigned int ncols;
62 struct gridmenu_texture tex;
63 };
64
65 CORE_BEGIN_DECLS
66
67 void
68 gridmenu_reset(struct gridmenu *);
69
70 void
71 gridmenu_repaint(struct gridmenu *);
72
73 void
74 gridmenu_handle(struct gridmenu *, const union event *);
75
76 void
77 gridmenu_draw(const struct gridmenu *);
78
79 void
80 gridmenu_finish(struct gridmenu *);
81
82 CORE_END_DECLS
83
84 #endif /* !MOLKO_UI_GRIDMENU_H */