Mercurial > molko
changeset 495:2af25db99273
ui: theme -> mlk_theme
line wrap: on
line diff
--- a/examples/example-battle/example-battle.c Tue Feb 28 13:32:01 2023 +0100 +++ b/examples/example-battle/example-battle.c Tue Feb 28 13:40:55 2023 +0100 @@ -136,7 +136,7 @@ registry_init(); /* Set cursor in default theme. */ - theme_default()->sprites[THEME_SPRITE_CURSOR] = ®istry_sprites[REGISTRY_TEXTURE_CURSOR]; + mlk_theme_default()->sprites[MLK_THEME_SPRITE_CURSOR] = ®istry_sprites[REGISTRY_TEXTURE_CURSOR]; } static struct mlk_state *states[2]; @@ -325,7 +325,7 @@ quit(void) { registry_finish(); - theme_finish(); + mlk_theme_finish(); mlk_window_finish(); mlk_sys_finish(); }
--- a/examples/example-font/example-font.c Tue Feb 28 13:32:01 2023 +0100 +++ b/examples/example-font/example-font.c Tue Feb 28 13:40:55 2023 +0100 @@ -81,7 +81,7 @@ else style = MLK_FONT_STYLE_ANTIALIASED; - theme_default()->fonts[THEME_FONT_INTERFACE]->style = style; + mlk_theme_default()->fonts[MLK_THEME_FONT_INTERFACE]->style = style; default: break; } @@ -99,7 +99,7 @@ { (void)st; - struct mlk_font *font = theme_default()->fonts[THEME_FONT_INTERFACE]; + struct mlk_font *font = mlk_theme_default()->fonts[MLK_THEME_FONT_INTERFACE]; struct mlk_texture tex; int err;
--- a/examples/example-message/example-message.c Tue Feb 28 13:32:01 2023 +0100 +++ b/examples/example-message/example-message.c Tue Feb 28 13:40:55 2023 +0100 @@ -109,7 +109,7 @@ } static void -my_draw_frame(const struct theme *th, const struct mlk_frame *f) +my_draw_frame(const struct mlk_theme *th, const struct mlk_frame *f) { (void)th; @@ -309,7 +309,7 @@ "This one will destroy your eyes.", "Because it use a terrible custom theme." }; - struct theme theme; + struct mlk_theme theme; struct message msg = { .x = MX, .y = MY, @@ -321,9 +321,9 @@ }; /* Borrow default theme and change its frame drawing. */ - theme_shallow(&theme, NULL); + mlk_theme_shallow(&theme, NULL); theme.draw_frame = my_draw_frame; - theme.colors[THEME_COLOR_NORMAL] = 0x0000ffff; + theme.colors[MLK_THEME_COLOR_NORMAL] = 0x0000ffff; run(&msg); }
--- a/examples/example-ui/example-ui.c Tue Feb 28 13:32:01 2023 +0100 +++ b/examples/example-ui/example-ui.c Tue Feb 28 13:40:55 2023 +0100 @@ -140,13 +140,13 @@ mlk_label_query(l, &w, &h); mlk_align(MLK_ALIGN_LEFT, &l->x, &l->y, w, h, f->x, f->y, f->w, HEADER_HEIGHT); - l->x += theme_default()->padding; + l->x += mlk_theme_default()->padding; } static void resize_autosave(void) { - unsigned int padding = theme_default()->padding; + unsigned int padding = mlk_theme_default()->padding; struct mlk_frame *f = &ui.panel.frame; struct mlk_checkbox *c = &ui.autosave.cb; struct mlk_label *l = &ui.autosave.label; @@ -161,7 +161,7 @@ static void resize_button(void) { - unsigned int padding = theme_default()->padding; + unsigned int padding = mlk_theme_default()->padding; struct mlk_frame *f = &ui.panel.frame; struct mlk_button *b = &ui.quit.button;
--- a/libmlk-example/mlk/example/trace-hud.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-example/mlk/example/trace-hud.c Tue Feb 28 13:40:55 2023 +0100 @@ -31,7 +31,7 @@ #include "trace-hud.h" #define LINES_MAX (4) -#define THEME(t) ((t) ? (t) : theme_default()) +#define THEME(t) ((t) ? (t) : mlk_theme_default()) static struct { char lines[LINES_MAX + 1][TRACE_LINE_MAX]; @@ -88,7 +88,7 @@ void trace_hud_draw(void) { - struct theme *th; + struct mlk_theme *th; int x, y; th = THEME(trace_hud.theme); @@ -104,7 +104,7 @@ .flags = MLK_LABEL_FLAGS_SHADOW }); - y += mlk_font_height(th->fonts[THEME_FONT_INTERFACE]); + y += mlk_font_height(th->fonts[MLK_THEME_FONT_INTERFACE]); y += th->padding; } }
--- a/libmlk-example/mlk/example/trace-hud.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-example/mlk/example/trace-hud.h Tue Feb 28 13:40:55 2023 +0100 @@ -22,10 +22,10 @@ #define TRACE_HUD_TIMEOUT_DEFAULT (3000) struct action; -struct theme; +struct mlk_theme; struct trace_hud { - struct theme *theme; + struct mlk_theme *theme; unsigned int timeout; };
--- a/libmlk-rpg/mlk/rpg/battle-bar-default.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar-default.c Tue Feb 28 13:40:55 2023 +0100 @@ -42,7 +42,7 @@ #include "item.h" #include "spell.h" -#define THEME(bar) ((bar)->theme ? (bar)->theme : theme_default()) +#define THEME(bar) ((bar)->theme ? (bar)->theme : mlk_theme_default()) struct geo { int x, y; @@ -155,7 +155,7 @@ battle_state_selection(bt, &sel); /* A cursor should be present. */ - if (!mlk_sprite_ok(BATTLE_THEME(bt)->sprites[THEME_SPRITE_CURSOR])) + if (!mlk_sprite_ok(BATTLE_THEME(bt)->sprites[MLK_THEME_SPRITE_CURSOR])) mlk_tracef("battle: no cursor sprite in theme"); } @@ -228,13 +228,13 @@ int y, unsigned int h) { - const struct theme *theme = THEME(bar); + const struct mlk_theme *theme = THEME(bar); struct mlk_label label; unsigned int spacing, lw, lh; char line[64]; /* Compute spacing between elements. */ - spacing = h - (mlk_font_height(theme->fonts[THEME_FONT_INTERFACE]) * 3); + spacing = h - (mlk_font_height(theme->fonts[MLK_THEME_FONT_INTERFACE]) * 3); spacing /= 4; /* Reuse the same label. */ @@ -353,7 +353,7 @@ } }; - const struct theme *theme = THEME(bar); + const struct mlk_theme *theme = THEME(bar); int bx, by; unsigned int bw, bh;
--- a/libmlk-rpg/mlk/rpg/battle-bar-default.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar-default.h Tue Feb 28 13:40:55 2023 +0100 @@ -27,7 +27,7 @@ struct battle_bar; struct character; struct selection; -struct theme; +struct mlk_theme; union mlk_event; @@ -49,7 +49,7 @@ int y; unsigned int w; unsigned int h; - struct theme *theme; + struct mlk_theme *theme; enum battle_bar_default_state state; enum battle_bar_default_menu menu;
--- a/libmlk-rpg/mlk/rpg/battle-indicator.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-indicator.c Tue Feb 28 13:40:55 2023 +0100 @@ -29,7 +29,7 @@ #include "battle-indicator.h" -#define THEME(bti) ((bti)->theme ? (bti)->theme : theme_default()) +#define THEME(bti) ((bti)->theme ? (bti)->theme : mlk_theme_default()) #define STEP (2) #define DELAY (5) @@ -54,7 +54,7 @@ assert(bti); char buf[128]; - const struct theme *theme = THEME(bti); + const struct mlk_theme *theme = THEME(bti); int err; snprintf(buf, sizeof (buf), "%u", bti->amount); @@ -63,8 +63,8 @@ bti->elapsed = 0; bti->alpha = 250; - if ((err = mlk_font_render(theme->fonts[THEME_FONT_INTERFACE], &bti->tex[0], buf, bti->cur)) < 0 || - (err = mlk_font_render(theme->fonts[THEME_FONT_INTERFACE], &bti->tex[1], buf, 0x000000ff)) < 0) + if ((err = mlk_font_render(theme->fonts[MLK_THEME_FONT_INTERFACE], &bti->tex[0], buf, bti->cur)) < 0 || + (err = mlk_font_render(theme->fonts[MLK_THEME_FONT_INTERFACE], &bti->tex[1], buf, 0x000000ff)) < 0) mlk_panic(err); }
--- a/libmlk-rpg/mlk/rpg/battle-indicator.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-indicator.h Tue Feb 28 13:40:55 2023 +0100 @@ -25,12 +25,12 @@ #define BATTLE_INDICATOR_HP_COLOR (0xa5303000) #define BATTLE_INDICATOR_MP_COLOR (0xa23e8c00) -struct theme; +struct mlk_theme; struct battle_indicator { unsigned int color; unsigned int amount; - const struct theme *theme; + const struct mlk_theme *theme; unsigned int cur; unsigned int elapsed; unsigned int alpha;
--- a/libmlk-rpg/mlk/rpg/battle-message.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-message.h Tue Feb 28 13:40:55 2023 +0100 @@ -21,11 +21,11 @@ #include <mlk/core/core.h> -struct theme; +struct mlk_theme; struct battle_message { const char *text; - struct theme *theme; + struct mlk_theme *theme; unsigned int elapsed; };
--- a/libmlk-rpg/mlk/rpg/battle-state-selection.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-selection.c Tue Feb 28 13:40:55 2023 +0100 @@ -115,8 +115,8 @@ static void draw_cursor(const struct battle *bt, const struct battle_entity *et) { - const struct theme *theme = BATTLE_THEME(bt); - const struct mlk_sprite *cursor = theme->sprites[THEME_SPRITE_CURSOR]; + const struct mlk_theme *theme = BATTLE_THEME(bt); + const struct mlk_sprite *cursor = theme->sprites[MLK_THEME_SPRITE_CURSOR]; int x, y; unsigned int lh;
--- a/libmlk-rpg/mlk/rpg/battle.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle.h Tue Feb 28 13:40:55 2023 +0100 @@ -42,14 +42,14 @@ struct mlk_music; struct selection; struct spell; -struct theme; +struct mlk_theme; #define BATTLE_TEAM_FOREACH(bt, iter) \ for (size_t i = 0; i < (bt)->teamsz && ((iter) = (bt)->team[i]); ++i) #define BATTLE_ENEMY_FOREACH(bt, iter) \ for (size_t i = 0; i < (bt)->enemiesz && ((iter) = (bt)->enemies[i]); ++i) -#define BATTLE_THEME(bt) ((bt)->theme ? (bt)->theme : theme_default()) +#define BATTLE_THEME(bt) ((bt)->theme ? (bt)->theme : mlk_theme_default()) enum battle_status { BATTLE_STATUS_NONE, @@ -79,7 +79,7 @@ size_t ordersz; struct mlk_texture *background; struct mlk_music *music[3]; - struct theme *theme; + struct mlk_theme *theme; struct mlk_drawable_stack *effects; struct mlk_action_stack *actions; struct inventory *inventory;
--- a/libmlk-rpg/mlk/rpg/message.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/message.c Tue Feb 28 13:40:55 2023 +0100 @@ -36,7 +36,7 @@ #include "message.h" -#define THEME(msg) (msg->theme ? msg->theme : theme_default()) +#define THEME(msg) (msg->theme ? msg->theme : mlk_theme_default()) static void draw_frame(const struct message *msg) @@ -63,7 +63,7 @@ for (size_t i = 0; i < msg->linesz; ++i) { if (!msg->lines[i]) continue; - if ((err = mlk_font_query(THEME(msg)->fonts[THEME_FONT_INTERFACE], msg->lines[i], &w, NULL)) < 0) + if ((err = mlk_font_query(THEME(msg)->fonts[MLK_THEME_FONT_INTERFACE], msg->lines[i], &w, NULL)) < 0) mlk_panic(err); if (w > maxw) maxw = w; @@ -77,8 +77,8 @@ { assert(msg); - const struct theme *th = THEME(msg); - const unsigned int lh = mlk_font_height(th->fonts[THEME_FONT_INTERFACE]); + const struct mlk_theme *th = THEME(msg); + const unsigned int lh = mlk_font_height(th->fonts[MLK_THEME_FONT_INTERFACE]); return (th->padding * 2) + (msg->linesz * lh) + ((msg->linesz - 1) * msg->spacing); } @@ -86,7 +86,7 @@ static void draw_lines(const struct message *msg) { - const struct theme *theme = THEME(msg); + const struct mlk_theme *theme = THEME(msg); struct mlk_label label; unsigned int lw, lh; int err; @@ -94,7 +94,7 @@ for (size_t i = 0; i < msg->linesz; ++i) { if (!msg->lines[i]) continue; - if ((err = mlk_font_query(theme->fonts[THEME_FONT_INTERFACE], msg->lines[i], &lw, &lh)) < 0) + if ((err = mlk_font_query(theme->fonts[MLK_THEME_FONT_INTERFACE], msg->lines[i], &lw, &lh)) < 0) mlk_panic(err); label.theme = theme;
--- a/libmlk-rpg/mlk/rpg/message.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/message.h Tue Feb 28 13:40:55 2023 +0100 @@ -25,7 +25,7 @@ #include <mlk/core/texture.h> struct mlk_font; -struct theme; +struct mlk_theme; union mlk_event; @@ -59,7 +59,7 @@ unsigned int index; enum message_flags flags; enum message_state state; - const struct theme *theme; + const struct mlk_theme *theme; unsigned int elapsed; double scale; };
--- a/libmlk-ui/mlk/ui/button.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/button.c Tue Feb 28 13:40:55 2023 +0100 @@ -41,7 +41,7 @@ } void -mlk_button_draw_default(const struct theme *t, const struct mlk_button *button) +mlk_button_draw_default(const struct mlk_theme *t, const struct mlk_button *button) { assert(t); assert(button); @@ -111,5 +111,5 @@ { assert(button); - theme_draw_button(button->theme, button); + mlk_theme_draw_button(button->theme, button); }
--- a/libmlk-ui/mlk/ui/button.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/button.h Tue Feb 28 13:40:55 2023 +0100 @@ -23,7 +23,7 @@ union mlk_event; -struct theme; +struct mlk_theme; enum mlk_button_state { MLK_BUTTON_STATE_NONE, @@ -38,7 +38,7 @@ unsigned int h; const char *text; enum mlk_button_state state; - const struct theme *theme; + const struct mlk_theme *theme; }; MLK_CORE_BEGIN_DECLS @@ -50,7 +50,7 @@ mlk_button_reset(struct mlk_button *); void -mlk_button_draw_default(const struct theme *, const struct mlk_button *); +mlk_button_draw_default(const struct mlk_theme *, const struct mlk_button *); void mlk_button_draw(const struct mlk_button *);
--- a/libmlk-ui/mlk/ui/checkbox.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/checkbox.c Tue Feb 28 13:40:55 2023 +0100 @@ -37,7 +37,7 @@ } void -mlk_checkbox_draw_default(const struct theme *t, const struct mlk_checkbox *cb) +mlk_checkbox_draw_default(const struct mlk_theme *t, const struct mlk_checkbox *cb) { (void)t; @@ -75,5 +75,5 @@ void mlk_checkbox_draw(const struct mlk_checkbox *cb) { - theme_draw_checkbox(cb->theme, cb); + mlk_theme_draw_checkbox(cb->theme, cb); }
--- a/libmlk-ui/mlk/ui/checkbox.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/checkbox.h Tue Feb 28 13:40:55 2023 +0100 @@ -23,7 +23,7 @@ union mlk_event; -struct theme; +struct mlk_theme; struct mlk_checkbox { int x; @@ -31,13 +31,13 @@ unsigned int w; unsigned int h; int checked; - const struct theme *theme; + const struct mlk_theme *theme; }; MLK_CORE_BEGIN_DECLS void -mlk_checkbox_draw_default(const struct theme *, const struct mlk_checkbox *); +mlk_checkbox_draw_default(const struct mlk_theme *, const struct mlk_checkbox *); int mlk_checkbox_handle(struct mlk_checkbox *, const union mlk_event *);
--- a/libmlk-ui/mlk/ui/debug.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/debug.c Tue Feb 28 13:40:55 2023 +0100 @@ -56,17 +56,17 @@ return; char line[MLK_DEBUG_LINE_MAX]; - const struct theme *theme; + const struct mlk_theme *theme; struct mlk_font *font; struct mlk_texture tex; int x, y; vsnprintf(line, sizeof (line), fmt, ap); - theme = report->theme ? report->theme : theme_default(); - font = theme->fonts[THEME_FONT_DEBUG]; + theme = report->theme ? report->theme : mlk_theme_default(); + font = theme->fonts[MLK_THEME_FONT_DEBUG]; - if (mlk_font_render(font, &tex, line, theme->colors[THEME_COLOR_DEBUG]) < 0) + if (mlk_font_render(font, &tex, line, theme->colors[MLK_THEME_COLOR_DEBUG]) < 0) return; x = theme->padding;
--- a/libmlk-ui/mlk/ui/debug.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/debug.h Tue Feb 28 13:40:55 2023 +0100 @@ -26,14 +26,14 @@ #define MLK_DEBUG_LINE_MAX 256 -struct theme; +struct mlk_theme; struct mlk_debug_options { int enable; }; struct mlk_debug_report { - const struct theme *theme; + const struct mlk_theme *theme; unsigned int count; };
--- a/libmlk-ui/mlk/ui/frame.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/frame.c Tue Feb 28 13:40:55 2023 +0100 @@ -25,7 +25,7 @@ #include "theme.h" void -mlk_frame_draw_default(const struct theme *t, const struct mlk_frame *frame) +mlk_frame_draw_default(const struct mlk_theme *t, const struct mlk_frame *frame) { assert(t); assert(frame); @@ -45,5 +45,5 @@ { assert(frame); - theme_draw_frame(frame->theme, frame); + mlk_theme_draw_frame(frame->theme, frame); }
--- a/libmlk-ui/mlk/ui/frame.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/frame.h Tue Feb 28 13:40:55 2023 +0100 @@ -21,7 +21,7 @@ #include <mlk/core/core.h> -struct theme; +struct mlk_theme; enum mlk_frame_style { MLK_FRAME_STYLE_NORMAL, @@ -34,13 +34,13 @@ unsigned int w; unsigned int h; enum mlk_frame_style style; - const struct theme *theme; + const struct mlk_theme *theme; }; MLK_CORE_BEGIN_DECLS void -mlk_frame_draw_default(const struct theme *, const struct mlk_frame *); +mlk_frame_draw_default(const struct mlk_theme *, const struct mlk_frame *); void mlk_frame_draw(const struct mlk_frame *);
--- a/libmlk-ui/mlk/ui/gridmenu.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/gridmenu.c Tue Feb 28 13:40:55 2023 +0100 @@ -32,7 +32,7 @@ #include "gridmenu.h" #include "theme.h" -#define THEME(m) ((m)->theme ? (m)->theme : theme_default()) +#define THEME(m) ((m)->theme ? (m)->theme : mlk_theme_default()) struct index { unsigned int row; @@ -51,7 +51,7 @@ static void geometry(struct mlk_gridmenu *menu) { - const struct theme *theme = THEME(menu); + const struct mlk_theme *theme = THEME(menu); struct mlk_label label = { .theme = theme, .flags = MLK_LABEL_FLAGS_SHADOW @@ -117,7 +117,7 @@ { size_t pagesz, pagenr, item, c = 0, r = 0; struct mlk_label label = {0}; - const struct theme *theme = THEME(menu); + const struct mlk_theme *theme = THEME(menu); label.theme = theme; label.flags = MLK_LABEL_FLAGS_SHADOW; @@ -195,7 +195,7 @@ { assert(click->type == MLK_EVENT_CLICKDOWN); - const struct theme *theme = THEME(menu); + const struct mlk_theme *theme = THEME(menu); size_t pagesz, pagenr, selected, c = 0, r = 0; int x, y;
--- a/libmlk-ui/mlk/ui/gridmenu.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/gridmenu.h Tue Feb 28 13:40:55 2023 +0100 @@ -25,7 +25,7 @@ #include "label.h" -struct theme; +struct mlk_theme; union mlk_event; @@ -36,7 +36,7 @@ unsigned int w; unsigned int h; size_t selected; - const struct theme *theme; + const struct mlk_theme *theme; const char * const *items; size_t itemsz; unsigned int nrows;
--- a/libmlk-ui/mlk/ui/label.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/label.c Tue Feb 28 13:40:55 2023 +0100 @@ -27,7 +27,7 @@ #include "theme.h" void -mlk_label_draw_default(const struct theme *t, const struct mlk_label *label) +mlk_label_draw_default(const struct mlk_theme *t, const struct mlk_label *label) { assert(t); assert(label); @@ -38,15 +38,15 @@ int err; font = label->flags & MLK_LABEL_FLAGS_IMPORTANT - ? t->fonts[THEME_FONT_IMPORTANT] - : t->fonts[THEME_FONT_INTERFACE]; + ? t->fonts[MLK_THEME_FONT_IMPORTANT] + : t->fonts[MLK_THEME_FONT_INTERFACE]; color = label->flags & MLK_LABEL_FLAGS_SELECTED - ? t->colors[THEME_COLOR_SELECTED] - : t->colors[THEME_COLOR_NORMAL]; + ? t->colors[MLK_THEME_COLOR_SELECTED] + : t->colors[MLK_THEME_COLOR_NORMAL]; /* Shadow text, only if enabled. */ if (label->flags & MLK_LABEL_FLAGS_SHADOW) { - if ((err = mlk_font_render(font, &tex, label->text, t->colors[THEME_COLOR_SHADOW])) < 0) + if ((err = mlk_font_render(font, &tex, label->text, t->colors[MLK_THEME_COLOR_SHADOW])) < 0) mlk_panic(err); mlk_texture_draw(&tex, label->x + 1, label->y + 1); @@ -73,10 +73,10 @@ assert(label); assert(label->text); - const struct theme *t = label->theme ? label->theme : theme_default(); + const struct mlk_theme *t = label->theme ? label->theme : mlk_theme_default(); const struct mlk_font *f = label->flags & MLK_LABEL_FLAGS_IMPORTANT - ? t->fonts[THEME_FONT_IMPORTANT] - : t->fonts[THEME_FONT_INTERFACE]; + ? t->fonts[MLK_THEME_FONT_IMPORTANT] + : t->fonts[MLK_THEME_FONT_INTERFACE]; int err; if ((err = mlk_font_query(f, label->text, w, h)) < 0) @@ -89,5 +89,5 @@ assert(label); assert(label->text); - theme_draw_label(label->theme, label); + mlk_theme_draw_label(label->theme, label); }
--- a/libmlk-ui/mlk/ui/label.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/label.h Tue Feb 28 13:40:55 2023 +0100 @@ -21,7 +21,7 @@ #include <mlk/core/core.h> -struct theme; +struct mlk_theme; enum mlk_label_flags { MLK_LABEL_FLAGS_NONE, @@ -35,13 +35,13 @@ int y; const char *text; enum mlk_label_flags flags; - const struct theme *theme; + const struct mlk_theme *theme; }; MLK_CORE_BEGIN_DECLS void -mlk_label_draw_default(const struct theme *, const struct mlk_label *); +mlk_label_draw_default(const struct mlk_theme *, const struct mlk_label *); int mlk_label_ok(const struct mlk_label *);
--- a/libmlk-ui/mlk/ui/notify.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/notify.c Tue Feb 28 13:40:55 2023 +0100 @@ -35,7 +35,7 @@ #define HEIGHT (mlk_window.h / 10) struct geo { - const struct theme *theme; + const struct mlk_theme *theme; int frame_x; int frame_y; unsigned int frame_w; @@ -63,7 +63,7 @@ int x, y; /* Determine theme. */ - geo->theme = system->theme ? system->theme : theme_default(); + geo->theme = system->theme ? system->theme : mlk_theme_default(); /* Determine notification position. */ x = mlk_window.w - geo->theme->padding; @@ -91,12 +91,12 @@ /* Align title to the right of the icon at the same y coordinate. */ geo->title_x = geo->icon_x + n->icon->w + geo->theme->padding; geo->title_y = geo->icon_y; - geo->title_y -= mlk_font_height(geo->theme->fonts[THEME_FONT_IMPORTANT]) / 2; + geo->title_y -= mlk_font_height(geo->theme->fonts[MLK_THEME_FONT_IMPORTANT]) / 2; /* Align body so it ends at the end of the icon. */ geo->body_x = geo->title_x; geo->body_y = geo->icon_y + n->icon->h; - geo->body_y -= mlk_font_height(geo->theme->fonts[THEME_FONT_INTERFACE]) / 2; + geo->body_y -= mlk_font_height(geo->theme->fonts[MLK_THEME_FONT_INTERFACE]) / 2; } static void
--- a/libmlk-ui/mlk/ui/notify.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/notify.h Tue Feb 28 13:40:55 2023 +0100 @@ -28,7 +28,7 @@ #define MLK_NOTIFY_TIMEOUT_DEFAULT (5000) struct mlk_texture; -struct theme; +struct mlk_theme; struct mlk_notify { const struct mlk_texture *icon; @@ -38,7 +38,7 @@ }; struct mlk_notify_system { - struct theme *theme; + struct mlk_theme *theme; void (*draw)(const struct mlk_notify *, size_t); };
--- a/libmlk-ui/mlk/ui/theme.c Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/theme.c Tue Feb 28 13:40:55 2023 +0100 @@ -45,12 +45,12 @@ { bin, sizeof (bin), size, &default_theme.fonts[index], {0} } /* Default theme. */ -static struct theme default_theme = { +static struct mlk_theme default_theme = { .colors = { - [THEME_COLOR_DEBUG] = 0xff0000ff, - [THEME_COLOR_NORMAL] = 0xffffffff, - [THEME_COLOR_SELECTED] = 0x006554ff, - [THEME_COLOR_SHADOW] = 0x000000ff + [MLK_THEME_COLOR_DEBUG] = 0xff0000ff, + [MLK_THEME_COLOR_NORMAL] = 0xffffffff, + [MLK_THEME_COLOR_SELECTED] = 0x006554ff, + [MLK_THEME_COLOR_SHADOW] = 0x000000ff }, .padding = 10, .draw_frame = mlk_frame_draw_default, @@ -66,13 +66,13 @@ struct mlk_font **dest; struct mlk_font font; } default_fonts[] = { - FONT(assets_fonts_opensans_light, 12, THEME_FONT_DEBUG), - FONT(assets_fonts_opensans_regular, 14, THEME_FONT_INTERFACE), - FONT(assets_fonts_opensans_medium, 14, THEME_FONT_IMPORTANT) + FONT(assets_fonts_opensans_light, 12, MLK_THEME_FONT_DEBUG), + FONT(assets_fonts_opensans_regular, 14, MLK_THEME_FONT_INTERFACE), + FONT(assets_fonts_opensans_medium, 14, MLK_THEME_FONT_IMPORTANT) }; int -theme_init(void) +mlk_theme_init(void) { /* Open all fonts. */ for (size_t i = 0; i < MLK_UTIL_SIZE(default_fonts); ++i) { @@ -88,25 +88,25 @@ return 0; failed: - theme_finish(); + mlk_theme_finish(); return -1; } -struct theme * -theme_default(void) +struct mlk_theme * +mlk_theme_default(void) { return &default_theme; } unsigned int -theme_padding(const struct theme *t) +theme_padding(const struct mlk_theme *t) { return THEME(t)->padding; } void -theme_shallow(struct theme *dst, const struct theme *src) +mlk_theme_shallow(struct mlk_theme *dst, const struct mlk_theme *src) { assert(dst); @@ -114,7 +114,7 @@ } void -theme_draw_frame(const struct theme *t, const struct mlk_frame *frame) +mlk_theme_draw_frame(const struct mlk_theme *t, const struct mlk_frame *frame) { assert(frame); @@ -122,7 +122,7 @@ } void -theme_draw_label(const struct theme *t, const struct label *label) +mlk_theme_draw_label(const struct mlk_theme *t, const struct mlk_label *label) { assert(label); @@ -130,7 +130,7 @@ } void -theme_draw_button(const struct theme *t, const struct mlk_button *button) +mlk_theme_draw_button(const struct mlk_theme *t, const struct mlk_button *button) { assert(button); @@ -138,7 +138,7 @@ } void -theme_draw_checkbox(const struct theme *t, const struct mlk_checkbox *cb) +mlk_theme_draw_checkbox(const struct mlk_theme *t, const struct mlk_checkbox *cb) { assert(cb); @@ -146,7 +146,7 @@ } void -theme_finish(void) +mlk_theme_finish(void) { for (size_t i = 0; i < MLK_UTIL_SIZE(default_fonts); ++i) { mlk_font_finish(&default_fonts[i].font);
--- a/libmlk-ui/mlk/ui/theme.h Tue Feb 28 13:32:01 2023 +0100 +++ b/libmlk-ui/mlk/ui/theme.h Tue Feb 28 13:40:55 2023 +0100 @@ -25,66 +25,66 @@ struct mlk_checkbox; struct mlk_font; struct mlk_frame; -struct label; +struct mlk_label; struct mlk_sprite; -enum theme_font { - THEME_FONT_DEBUG, - THEME_FONT_INTERFACE, - THEME_FONT_IMPORTANT, - THEME_FONT_NUM +enum mlk_theme_font { + MLK_THEME_FONT_DEBUG, + MLK_THEME_FONT_INTERFACE, + MLK_THEME_FONT_IMPORTANT, + MLK_THEME_FONT_NUM }; -enum theme_color { - THEME_COLOR_DEBUG, - THEME_COLOR_NORMAL, - THEME_COLOR_SELECTED, - THEME_COLOR_SHADOW, - THEME_COLOR_NUM +enum mlk_theme_color { + MLK_THEME_COLOR_DEBUG, + MLK_THEME_COLOR_NORMAL, + MLK_THEME_COLOR_SELECTED, + MLK_THEME_COLOR_SHADOW, + MLK_THEME_COLOR_NUM }; -enum theme_sprite { - THEME_SPRITE_CURSOR, - THEME_SPRITE_NUM +enum mlk_theme_sprite { + MLK_THEME_SPRITE_CURSOR, + MLK_THEME_SPRITE_NUM }; -struct theme { - struct mlk_font *fonts[THEME_FONT_NUM]; - const struct mlk_sprite *sprites[THEME_SPRITE_NUM]; - unsigned long colors[THEME_COLOR_NUM]; +struct mlk_theme { + struct mlk_font *fonts[MLK_THEME_FONT_NUM]; + const struct mlk_sprite *sprites[MLK_THEME_SPRITE_NUM]; + unsigned long colors[MLK_THEME_COLOR_NUM]; unsigned int padding; - void (*draw_frame)(const struct theme *, const struct mlk_frame *); - void (*draw_label)(const struct theme *, const struct label *); - void (*draw_button)(const struct theme *, const struct mlk_button *); - void (*draw_checkbox)(const struct theme *t, const struct mlk_checkbox *); + void (*draw_frame)(const struct mlk_theme *, const struct mlk_frame *); + void (*draw_label)(const struct mlk_theme *, const struct mlk_label *); + void (*draw_button)(const struct mlk_theme *, const struct mlk_button *); + void (*draw_checkbox)(const struct mlk_theme *t, const struct mlk_checkbox *); }; MLK_CORE_BEGIN_DECLS int -theme_init(void); +mlk_theme_init(void); -struct theme * -theme_default(void); +struct mlk_theme * +mlk_theme_default(void); void -theme_shallow(struct theme *, const struct theme *); +mlk_theme_shallow(struct mlk_theme *, const struct mlk_theme *); void -theme_draw_frame(const struct theme *, const struct mlk_frame *); +mlk_theme_draw_frame(const struct mlk_theme *, const struct mlk_frame *); void -theme_draw_label(const struct theme *, const struct label *); +mlk_theme_draw_label(const struct mlk_theme *, const struct mlk_label *); void -theme_draw_button(const struct theme *, const struct mlk_button *); +mlk_theme_draw_button(const struct mlk_theme *, const struct mlk_button *); void -theme_draw_checkbox(const struct theme *, const struct mlk_checkbox *); +mlk_theme_draw_checkbox(const struct mlk_theme *, const struct mlk_checkbox *); void -theme_finish(void); +mlk_theme_finish(void); MLK_CORE_END_DECLS