From 43d4f8b4944e198bd06d22bc654835c13a1c47c5 Mon Sep 17 00:00:00 2001 From: Pere Pujal i Carabantes Date: Fri, 5 Feb 2021 03:42:01 +0100 Subject: [PATCH] Activating the ability to have more than one colors row. Usefull for people with coarse input devices that need bigger buttons but got color buttons too narrow. Just added the option, all the support code where already in place. --- src/parse.gperf | 1 + src/parse.h | 1 + src/tuxpaint.c | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/parse.gperf b/src/parse.gperf index 143bef138..bed172c49 100644 --- a/src/parse.gperf +++ b/src/parse.gperf @@ -164,6 +164,7 @@ wheelmouse, POSBOOL(wheely) windowed, NEGBOOL(fullscreen) windowsize, MULTI(parsertmp_windowsize) buttonsize, MULTI(button_size) +colorsrows, MULTI(colors_rows) 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 d8b0b3c96..237337992 100644 --- a/src/parse.h +++ b/src/parse.h @@ -44,6 +44,7 @@ struct cfginfo const char *parsertmp_sysconfig; const char *parsertmp_windowsize; const char *button_size; + const char *colors_rows; const char *print_delay; const char *printcommand; // const char *promptless_save; diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 4d327d809..867199352 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -713,6 +713,7 @@ static int button_h; /* was 48 */ 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 */ +static int colors_rows; static int buttons_tall; /* promoted to a global variable from setup_normal_screen_layout() */ @@ -774,10 +775,10 @@ static void setup_normal_screen_layout(void) r_ttoolopt.x = WINDOW_WIDTH - r_ttoolopt.w; r_ttoolopt.y = 0; - gd_colors.rows = 1; + gd_colors.rows = colors_rows; gd_colors.cols = (NUM_COLORS + gd_colors.rows - 1) / gd_colors.rows; - r_colors.h = 48 * button_scale; + r_colors.h = 48 * button_scale * gd_colors.rows; color_button_h = r_colors.h / gd_colors.rows; r_tcolors.h = r_colors.h; @@ -8547,6 +8548,10 @@ static unsigned draw_colors(unsigned action) if (colors_state == old_colors_state) return old_colors_state; + /* If more than one colors rows, fill the parts of the r_tcolors not covered by the title. */ + if (gd_colors.rows > 1) + SDL_FillRect(screen, &r_tcolors, SDL_MapRGBA(screen->format, 255,255,255,255)); + if (colors_state == COLORSEL_ENABLE) { SDL_BlitSurface(img_title_large_on, NULL, screen, &r_tcolors); @@ -23293,6 +23298,17 @@ static void setup_config(char *argv[]) } else button_scale = 1; + if (tmpcfg.colors_rows) + { + if (strtof(tmpcfg.colors_rows, NULL) > 3) + { + fprintf(stderr, "Color rows (now %s) must be between 1 and 3.\n", tmpcfg.colors_rows); + exit(1); + } + colors_rows = strtof(tmpcfg.colors_rows, NULL); + } + else + colors_rows = 1; if (tmpcfg.stamp_size_override) { if (!strcmp(tmpcfg.stamp_size_override, "default"))