From 7121c75c78bca7ef317c0a4fa8f8d41da5d06ad2 Mon Sep 17 00:00:00 2001 From: Pere Pujal i Carabantes Date: Mon, 28 Sep 2020 13:35:18 +0200 Subject: [PATCH] Option 'buttonsize' to change the size of the buttons. --- src/parse.gperf | 1 + src/parse.h | 1 + src/tuxpaint.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/parse.gperf b/src/parse.gperf index 38056240e..143bef138 100644 --- a/src/parse.gperf +++ b/src/parse.gperf @@ -163,6 +163,7 @@ version, IMM(version) wheelmouse, POSBOOL(wheely) windowed, NEGBOOL(fullscreen) windowsize, MULTI(parsertmp_windowsize) +buttonsize, MULTI(button_size) mouse-accessibility, POSBOOL(mouseaccessibility) onscreen-keyboard, POSBOOL(onscreen_keyboard) onscreen-keyboard-layout, MULTI(onscreen_keyboard_layout) diff --git a/src/parse.h b/src/parse.h index be6c4cebd..d8b0b3c96 100644 --- a/src/parse.h +++ b/src/parse.h @@ -43,6 +43,7 @@ struct cfginfo const char *parsertmp_locale; const char *parsertmp_sysconfig; const char *parsertmp_windowsize; + const char *button_size; const char *print_delay; const char *printcommand; // const char *promptless_save; diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 8bbfa69c6..f7eb72f50 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -708,7 +708,7 @@ static SDL_Rect old_dest; static int button_w; /* was 48 */ static int button_h; /* was 48 */ -static float button_scale = 2; /* To be set from user preferences, should default to 1 Change to 1.5, 2, 2.5, etc to test for now */ +static float button_scale; /* scale factor to be applied to the size of buttons */ static int color_button_w; /* was 32 */ static int color_button_h; /* was 48 */ @@ -23151,6 +23151,17 @@ static void setup_config(char *argv[]) native_screensize = 1; fullscreen = strcmp(tmpcfg.parsertmp_fullscreen_native, "no"); } + if (tmpcfg.button_size) + { + if (strtof(tmpcfg.button_size, NULL) < 24 || strtof(tmpcfg.button_size, NULL) > 192) + { + fprintf(stderr, "Button size (now %s) must be between 24 and 192.\n", tmpcfg.button_size); + exit(1); + } + button_scale = strtof(tmpcfg.button_size, NULL) / ORIGINAL_BUTTON_SIZE; + } + else + button_scale = 1; if (tmpcfg.stamp_size_override) { if (!strcmp(tmpcfg.stamp_size_override, "default"))