From adec3666f0d2cb73316cbf7d4ba04b2b05f5c0b1 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Wed, 2 Mar 2022 01:38:04 -0800 Subject: [PATCH] Color picker -> Back; don't 'forget' old crosshair positions --- src/tuxpaint.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 1866f1b9d..35c7ea696 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -21898,6 +21898,13 @@ static int do_color_picker(void) SDL_Rect r_final; val_x = val_y = motioner = 0; valhat_x = valhat_y = hatmotioner = 0; + int old_cp_x, old_cp_y, old_cp_v; + + /* Remember old choices, in case we hit [Back] */ + old_cp_x = color_picker_x; + old_cp_y = color_picker_y; + old_cp_v = color_picker_v; + hide_blinking_cursor(); @@ -22284,10 +22291,9 @@ static int do_color_picker(void) while (!done); - /* Set the new color: */ - if (chose) { + /* Set the new color: */ SDL_GetRGB(getpixel_img_color_picker(img_color_picker, color_picker_x, color_picker_y), img_color_picker->format, &r, &g, &b); color_hexes[COLOR_PICKER][0] = r; @@ -22298,6 +22304,13 @@ static int do_color_picker(void) /* Re-render color picker to show the current color it contains: */ render_color_button(COLOR_PICKER, img_color_picker_thumb, NULL); } + else + { + /* Set crosshairs to the existing color */ + color_picker_x = old_cp_x; + color_picker_y = old_cp_y; + color_picker_v = old_cp_v; + } /* Remove the prompt: */