comparison libmlk-ui/mlk/ui/theme.h @ 433:862b15c3a3ae

ui: cleanup hierarchy
author David Demelier <markand@malikania.fr>
date Sat, 15 Oct 2022 21:19:25 +0200
parents src/libmlk-ui/ui/theme.h@8f59201dc76b
children 773a082f0b91
comparison
equal deleted inserted replaced
432:38cf60f5a1c4 433:862b15c3a3ae
1 /*
2 * theme.h -- abstract theming
3 *
4 * Copyright (c) 2020-2022 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 MLK_UI_THEME_H
20 #define MLK_UI_THEME_H
21
22 #include <mlk/core/core.h>
23
24 struct button;
25 struct checkbox;
26 struct font;
27 struct frame;
28 struct label;
29 struct sprite;
30
31 enum theme_font {
32 THEME_FONT_DEBUG,
33 THEME_FONT_INTERFACE,
34 THEME_FONT_IMPORTANT,
35 THEME_FONT_NUM
36 };
37
38 enum theme_color {
39 THEME_COLOR_DEBUG,
40 THEME_COLOR_NORMAL,
41 THEME_COLOR_SELECTED,
42 THEME_COLOR_SHADOW,
43 THEME_COLOR_NUM
44 };
45
46 enum theme_sprite {
47 THEME_SPRITE_CURSOR,
48 THEME_SPRITE_NUM
49 };
50
51 struct theme {
52 struct font *fonts[THEME_FONT_NUM];
53 const struct sprite *sprites[THEME_SPRITE_NUM];
54 unsigned long colors[THEME_COLOR_NUM];
55 unsigned int padding;
56
57 void (*draw_frame)(const struct theme *, const struct frame *);
58 void (*draw_label)(const struct theme *, const struct label *);
59 void (*draw_button)(const struct theme *, const struct button *);
60 void (*draw_checkbox)(const struct theme *t, const struct checkbox *);
61 };
62
63 CORE_BEGIN_DECLS
64
65 int
66 theme_init(void);
67
68 struct theme *
69 theme_default(void);
70
71 void
72 theme_shallow(struct theme *, const struct theme *);
73
74 void
75 theme_draw_frame(const struct theme *, const struct frame *);
76
77 void
78 theme_draw_label(const struct theme *, const struct label *);
79
80 void
81 theme_draw_button(const struct theme *, const struct button *);
82
83 void
84 theme_draw_checkbox(const struct theme *, const struct checkbox *);
85
86 void
87 theme_finish(void);
88
89 CORE_END_DECLS
90
91 #endif /* !MLK_UI_THEME_H */