Mercurial > molko
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmlk-ui/mlk/ui/theme.h Sat Oct 15 21:19:25 2022 +0200 @@ -0,0 +1,91 @@ +/* + * theme.h -- abstract theming + * + * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MLK_UI_THEME_H +#define MLK_UI_THEME_H + +#include <mlk/core/core.h> + +struct button; +struct checkbox; +struct font; +struct frame; +struct label; +struct sprite; + +enum theme_font { + THEME_FONT_DEBUG, + THEME_FONT_INTERFACE, + THEME_FONT_IMPORTANT, + THEME_FONT_NUM +}; + +enum theme_color { + THEME_COLOR_DEBUG, + THEME_COLOR_NORMAL, + THEME_COLOR_SELECTED, + THEME_COLOR_SHADOW, + THEME_COLOR_NUM +}; + +enum theme_sprite { + THEME_SPRITE_CURSOR, + THEME_SPRITE_NUM +}; + +struct theme { + struct font *fonts[THEME_FONT_NUM]; + const struct sprite *sprites[THEME_SPRITE_NUM]; + unsigned long colors[THEME_COLOR_NUM]; + unsigned int padding; + + void (*draw_frame)(const struct theme *, const struct frame *); + void (*draw_label)(const struct theme *, const struct label *); + void (*draw_button)(const struct theme *, const struct button *); + void (*draw_checkbox)(const struct theme *t, const struct checkbox *); +}; + +CORE_BEGIN_DECLS + +int +theme_init(void); + +struct theme * +theme_default(void); + +void +theme_shallow(struct theme *, const struct theme *); + +void +theme_draw_frame(const struct theme *, const struct frame *); + +void +theme_draw_label(const struct theme *, const struct label *); + +void +theme_draw_button(const struct theme *, const struct button *); + +void +theme_draw_checkbox(const struct theme *, const struct checkbox *); + +void +theme_finish(void); + +CORE_END_DECLS + +#endif /* !MLK_UI_THEME_H */