summaryrefslogtreecommitdiffstats
path: root/src/tk/text.c
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2022-01-31 06:18:38 (EST)
committer P. J. McDermott <pj@pehjota.net>2022-01-31 06:18:38 (EST)
commitc5e354b1ff6e15fc25ce39b5c009c0488ffe8824 (patch)
tree7e93fe79769241e020d01f1227903d319820e150 /src/tk/text.c
parent6f1504c8655e5b674d9ba62486f23fc5c83ef1c8 (diff)
downloadmazefight-c5e354b1ff6e15fc25ce39b5c009c0488ffe8824.zip
mazefight-c5e354b1ff6e15fc25ce39b5c009c0488ffe8824.tar.gz
mazefight-c5e354b1ff6e15fc25ce39b5c009c0488ffe8824.tar.bz2
tk: Add padding to text
Diffstat (limited to 'src/tk/text.c')
-rw-r--r--src/tk/text.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/tk/text.c b/src/tk/text.c
index 99ec76a..2b9a026 100644
--- a/src/tk/text.c
+++ b/src/tk/text.c
@@ -40,6 +40,7 @@ struct mftk_text {
int line_skip;
int ascent;
SDL_Texture *texture;
+ int padding;
int border;
int editable;
int blink_state;
@@ -307,6 +308,8 @@ _mftk_text_render(struct mftk_widget *w, SDL_Renderer *renderer, int x, int y)
}
}
+ x += t->padding;
+ y += t->padding;
rect.x = x;
rect.y = t->y + y;
rect.w = t->w;
@@ -362,7 +365,7 @@ _mftk_text_destroy(struct mftk_widget *w)
struct mftk_widget *
mftk_text_new(const char *allowed_chars, int len, const char *val,
- TTF_Font *font, int border, int editable,
+ TTF_Font *font, int padding, int border, int editable,
int (*action)(void *, const char *), int (*submit)(void *),
void *user_data)
{
@@ -383,6 +386,7 @@ mftk_text_new(const char *allowed_chars, int len, const char *val,
t->line_skip = TTF_FontLineSkip(font);
t->ascent = TTF_FontAscent (font);
t->texture = NULL;
+ t->padding = padding;
t->border = border;
t->editable = editable;
t->blink_state = SDL_TRUE;
@@ -431,8 +435,8 @@ mftk_text_new(const char *allowed_chars, int len, const char *val,
}
w->h = t->line_skip;
if (editable == SDL_TRUE) {
- w->w += border * 2;
- w->h += border * 2;
+ w->w += padding * 2 + border * 2;
+ w->h += padding * 2 + border * 2;
}
return w;