From c5e354b1ff6e15fc25ce39b5c009c0488ffe8824 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 31 Jan 2022 06:18:38 -0500 Subject: tk: Add padding to text --- (limited to 'src/tk/text.c') 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; -- cgit v0.9.1