diff src/libmlk-ui/ui/theme.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/theme.h@d01e83210ca2
children 42a6710629f5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libmlk-ui/ui/theme.h	Fri Oct 01 20:30:00 2021 +0200
@@ -0,0 +1,90 @@
+/*
+ * theme.h -- abstract theming
+ *
+ * Copyright (c) 2020-2021 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 MOLKO_UI_THEME_H
+#define MOLKO_UI_THEME_H
+
+#include <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_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 /* !MOLKO_UI_THEME_H */