diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/defs.h | 1 | ||||
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/menu.c | 8 | ||||
-rw-r--r-- | src/tk.h | 2 | ||||
-rw-r--r-- | src/tk/text.c | 10 |
5 files changed, 14 insertions, 9 deletions
@@ -39,6 +39,7 @@ #define MF_CHK_BTN_P 2 /* Radio button and check box padding */ #define MF_CHK_LBL_P 8 /* Radio button and check box label pad */ #define MF_CHK_ITM_P 8 /* Radio button and check box label pad */ +#define MF_TXT_P 2 /* Text padding */ #define MF_BTN_M 8 /* Margin between buttons */ #define MF_BTN_P 8 /* Button padding */ #define MF_TITLE_FONT_S 48 /* Title font size */ @@ -53,7 +53,7 @@ _mf_game_form(SDL_Renderer *renderer, TTF_Font *text_font, struct _mf_game *game) { game->timer = mftk_text_new(MF_DIGITS ":", 5, "00:00", text_font, - MF_WGT_B, SDL_FALSE, NULL, NULL, NULL); + 0, MF_WGT_B, SDL_FALSE, NULL, NULL, NULL); return mftk_grid_new(2, 1, MF_ROW_M, MF_COL_M, game->timer, MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T, @@ -167,11 +167,11 @@ _mf_menu_form(SDL_Renderer *renderer, TTF_Font *text_font, } menu->seed_text = mftk_text_new(MF_DIGITS, rand_max_len, menu->seed_buf, - text_font, MF_WGT_B, SDL_TRUE, &_mf_menu_seed, - &_mf_menu_play, menu); + text_font, MF_TXT_P, MF_WGT_B, SDL_TRUE, + &_mf_menu_seed, &_mf_menu_play, menu); menu->enemies_text = mftk_text_new(MF_DIGITS, 2, menu->enemies_buf, - text_font, MF_WGT_B, SDL_TRUE, &_mf_menu_enemies, - &_mf_menu_play, menu); + text_font, MF_TXT_P, MF_WGT_B, SDL_TRUE, + &_mf_menu_enemies, &_mf_menu_play, menu); grid = mftk_grid_new(6, 2, MF_ROW_M, MF_COL_M, mftk_label_new(text_font, "Seed", renderer), MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T, @@ -73,7 +73,7 @@ mftk_radio_new(int butn_width, int butn_padding, int butn_border, 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); 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; |