Mercurial > molko
comparison libmlk-rpg/mlk/rpg/message.c @ 495:2af25db99273
ui: theme -> mlk_theme
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 28 Feb 2023 13:40:55 +0100 |
parents | fce3b3c4b496 |
children | 52a305833381 |
comparison
equal
deleted
inserted
replaced
494:35cc5d51bcb2 | 495:2af25db99273 |
---|---|
34 #include <mlk/ui/label.h> | 34 #include <mlk/ui/label.h> |
35 #include <mlk/ui/theme.h> | 35 #include <mlk/ui/theme.h> |
36 | 36 |
37 #include "message.h" | 37 #include "message.h" |
38 | 38 |
39 #define THEME(msg) (msg->theme ? msg->theme : theme_default()) | 39 #define THEME(msg) (msg->theme ? msg->theme : mlk_theme_default()) |
40 | 40 |
41 static void | 41 static void |
42 draw_frame(const struct message *msg) | 42 draw_frame(const struct message *msg) |
43 { | 43 { |
44 assert(msg); | 44 assert(msg); |
61 int err; | 61 int err; |
62 | 62 |
63 for (size_t i = 0; i < msg->linesz; ++i) { | 63 for (size_t i = 0; i < msg->linesz; ++i) { |
64 if (!msg->lines[i]) | 64 if (!msg->lines[i]) |
65 continue; | 65 continue; |
66 if ((err = mlk_font_query(THEME(msg)->fonts[THEME_FONT_INTERFACE], msg->lines[i], &w, NULL)) < 0) | 66 if ((err = mlk_font_query(THEME(msg)->fonts[MLK_THEME_FONT_INTERFACE], msg->lines[i], &w, NULL)) < 0) |
67 mlk_panic(err); | 67 mlk_panic(err); |
68 if (w > maxw) | 68 if (w > maxw) |
69 maxw = w; | 69 maxw = w; |
70 } | 70 } |
71 | 71 |
75 static inline unsigned int | 75 static inline unsigned int |
76 min_height(const struct message *msg) | 76 min_height(const struct message *msg) |
77 { | 77 { |
78 assert(msg); | 78 assert(msg); |
79 | 79 |
80 const struct theme *th = THEME(msg); | 80 const struct mlk_theme *th = THEME(msg); |
81 const unsigned int lh = mlk_font_height(th->fonts[THEME_FONT_INTERFACE]); | 81 const unsigned int lh = mlk_font_height(th->fonts[MLK_THEME_FONT_INTERFACE]); |
82 | 82 |
83 return (th->padding * 2) + (msg->linesz * lh) + ((msg->linesz - 1) * msg->spacing); | 83 return (th->padding * 2) + (msg->linesz * lh) + ((msg->linesz - 1) * msg->spacing); |
84 } | 84 } |
85 | 85 |
86 static void | 86 static void |
87 draw_lines(const struct message *msg) | 87 draw_lines(const struct message *msg) |
88 { | 88 { |
89 const struct theme *theme = THEME(msg); | 89 const struct mlk_theme *theme = THEME(msg); |
90 struct mlk_label label; | 90 struct mlk_label label; |
91 unsigned int lw, lh; | 91 unsigned int lw, lh; |
92 int err; | 92 int err; |
93 | 93 |
94 for (size_t i = 0; i < msg->linesz; ++i) { | 94 for (size_t i = 0; i < msg->linesz; ++i) { |
95 if (!msg->lines[i]) | 95 if (!msg->lines[i]) |
96 continue; | 96 continue; |
97 if ((err = mlk_font_query(theme->fonts[THEME_FONT_INTERFACE], msg->lines[i], &lw, &lh)) < 0) | 97 if ((err = mlk_font_query(theme->fonts[MLK_THEME_FONT_INTERFACE], msg->lines[i], &lw, &lh)) < 0) |
98 mlk_panic(err); | 98 mlk_panic(err); |
99 | 99 |
100 label.theme = theme; | 100 label.theme = theme; |
101 label.x = theme->padding; | 101 label.x = theme->padding; |
102 label.y = theme->padding + (i * (lh + msg->spacing)); | 102 label.y = theme->padding + (i * (lh + msg->spacing)); |