summaryrefslogtreecommitdiffstats
path: root/src/tk/check.c
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-09-25 18:39:15 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-09-25 18:39:15 (EDT)
commit2ed3153670ffba9d43f6033ce89dc33c241de193 (patch)
treecd2191e381f72f2938650839962c16fcad6268e2 /src/tk/check.c
parent15f3d1c8385ac7cc2ed3c04bb1e1fb919ba169d1 (diff)
downloadmazefight-2ed3153670ffba9d43f6033ce89dc33c241de193.zip
mazefight-2ed3153670ffba9d43f6033ce89dc33c241de193.tar.gz
mazefight-2ed3153670ffba9d43f6033ce89dc33c241de193.tar.bz2
tk: Define colors within local header
Diffstat (limited to 'src/tk/check.c')
-rw-r--r--src/tk/check.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/tk/check.c b/src/tk/check.c
index 0b2ea56..b24db0b 100644
--- a/src/tk/check.c
+++ b/src/tk/check.c
@@ -20,6 +20,7 @@
#include <SDL.h>
#include <math.h>
#include "../tk.h"
+#include "style.h"
#include "widget.h"
struct mftk_check {
@@ -27,8 +28,6 @@ struct mftk_check {
enum mftk_check_shape shape;
int butn_width;
int butn_padding;
- SDL_Color *butn_color;
- SDL_Color *mark_color;
int state;
int label_padding;
struct mftk_widget *label;
@@ -38,6 +37,15 @@ struct mftk_check {
void *user_data;
};
+static SDL_Color _mftk_check_butn_color = {
+ .r = MFTK_COLOR_CHKB_R, .g = MFTK_COLOR_CHKB_G,
+ .b = MFTK_COLOR_CHKB_B, .a = MFTK_COLOR_CHKB_A
+};
+static SDL_Color _mftk_check_mark_color = {
+ .r = MFTK_COLOR_CHKM_R, .g = MFTK_COLOR_CHKM_G,
+ .b = MFTK_COLOR_CHKM_B, .a = MFTK_COLOR_CHKM_A
+};
+
void
mftk_check_set_shape(struct mftk_widget *w, enum mftk_check_shape shape)
{
@@ -220,11 +228,13 @@ _mftk_check_render(struct mftk_widget *w, SDL_Renderer *renderer, int x, int y)
rect.w = c->butn_width;
rect.h = c->butn_width;
if (c->shape == MFTK_CHECK_SHAPE_BOX) {
- if (_mftk_check_render_box(&rect, c->butn_color, renderer) < 0){
+ if (_mftk_check_render_box(&rect, &_mftk_check_butn_color,
+ renderer) < 0) {
e = -1;
}
} else {
- if (_mftk_check_render_cir(&rect, c->butn_color, renderer) < 0){
+ if (_mftk_check_render_cir(&rect, &_mftk_check_butn_color,
+ renderer) < 0) {
e = -1;
}
}
@@ -235,12 +245,14 @@ _mftk_check_render(struct mftk_widget *w, SDL_Renderer *renderer, int x, int y)
rect.w -= c->butn_padding * 2;
rect.h -= c->butn_padding * 2;
if (c->shape == MFTK_CHECK_SHAPE_BOX) {
- if (_mftk_check_render_box(&rect, c->mark_color,
+ if (_mftk_check_render_box(&rect,
+ &_mftk_check_mark_color,
renderer) < 0) {
e = -1;
}
} else {
- if (_mftk_check_render_cir(&rect, c->mark_color,
+ if (_mftk_check_render_cir(&rect,
+ &_mftk_check_mark_color,
renderer) < 0) {
e = -1;
}
@@ -266,19 +278,17 @@ _mftk_check_destroy(struct mftk_widget *w)
}
struct mftk_widget *
-mftk_check_new(int butn_width, int butn_padding, SDL_Color *butn_color,
- SDL_Color *mark_color, int state, int label_padding,
- TTF_Font *font, const char *text, SDL_Color *text_color,
- int (*action)(void *, int), int (*submit)(void *),
- void *user_data, SDL_Renderer *renderer)
+mftk_check_new(int butn_width, int butn_padding, int state, int label_padding,
+ TTF_Font *font, const char *text, int (*action)(void *, int),
+ int (*submit)(void *), void *user_data, SDL_Renderer *renderer)
{
struct mftk_widget *w;
struct mftk_check *c;
mftk_widget_init_focusable(w, c, check);
- if (font != NULL && text != NULL && text_color != NULL) {
- c->label = mftk_label_new(font, text, text_color, renderer);
+ if (font != NULL && text != NULL) {
+ c->label = mftk_label_new(font, text, renderer);
if (c->label == NULL) {
free(c);
return NULL;
@@ -288,8 +298,6 @@ mftk_check_new(int butn_width, int butn_padding, SDL_Color *butn_color,
c->shape = MFTK_CHECK_SHAPE_BOX;
c->butn_width = butn_width;
c->butn_padding = butn_padding;
- c->butn_color = butn_color;
- c->mark_color = mark_color;
c->state = state;
c->label_padding = label_padding;
c->steals_focus = SDL_TRUE;