From 23976aa651dedaa0570a3aabd0454c6edd08bf14 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Mon, 19 Jun 2023 12:28:48 -0700 Subject: [PATCH] New style for color picker (HSV palette) button Also mend a rendering issue with paint wells on the three dynamic color buttons. --- data/images/ui/color_picker_icon.png | Bin 0 -> 6569 bytes docs/CHANGES.txt | 12 ++- src/tuxpaint.c | 108 ++++++++++++--------------- 3 files changed, 56 insertions(+), 64 deletions(-) create mode 100644 data/images/ui/color_picker_icon.png diff --git a/data/images/ui/color_picker_icon.png b/data/images/ui/color_picker_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0f7252a4b86a7e83af0f14b8d3dbc47b0aae25d2 GIT binary patch literal 6569 zcmeHKc{r5o`yYiOTPKCGOw%ca+07VZi?I#KE<$?E!o)1i3^O5)HHsvmP$?(UW-VFL zV#``8m2@OaNQI-5y?*a#zkc8A`d#O`e&7F^>w4#X-}|}m&vW0O`+lDHei9tETgghV zm4-kdvSe#>C-ANyx|U0V{~D8@00?B6Vu*`7-w6;vIb1fK5lDmb_i<=Ynvg+r`{=kpoA(#nuOZdd<^ZcdDx9DXBUs%itwyVB-B8&Ol8=d6}JK<39?-QTg0ZC$aj% z1Ps5rCV2;Kcpx>!rk8O#u!`ki*;8N++$_I#8f_cm%v4Rwl4}}8P7lDWY{aH|18vaJ zYy4EE?zYE?SAE!6G%=FWe`xgGewkJ+K}s+ry5BMJ~v;u-W!iDIQ70>=p!eb%&^@*+p*DP-a78^oZvXK`kwrB zP}DRf`sPqoq2>@rK75@X7U3K|vp+JT9WmLVvh$b%aOk{^+G-8y(F-20!me3Vxmya0 zdn>La+6ETOUb)XC4Y=Mvp&GW^DQA1^rlg@R8Qfjv=Nu{fq0Grgs7(;MW)Ak{R7D{=i&}h${SPYk>VQ? zR~0qYKrSgLIK^*@lwbWp^|(IQ_hswG+3PS=gJM0@Cu6|bI@{NV?6lpYS{z6?YW}-z z6C(6aUVHo#9sMCE4qa?0s!d{r4Z73Shc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7YEVHo?5l#>dAe z^Am}nDmNQe(>gw0q$n-1C8MR}0JlPi$Kzp$M6D~MbV*6cs80+z$!Jqo*P+s`OD-2( zx1_Pi6H~T-k0&dg^LUrq&|mmxR|qu8lEkgZuJbLPxqbV#CP~*WtDRn2Qe3e`>Ln9aG`*;7YK zx}-+E6|AF9MV(Z9q*lZnhMZgK?@ScG1BDIWx{;QaM)I?-X*ggqFDw6t!CRzUnS9Y! z9cW2Q^n_$UTVq}SL@3e0-OJ1H{o^e5c*l@W?r@c7aBfsMq)goZUR1g`PHJzyWwCo5 zDltmZ@KWcVv83di_LCjnT6(v-N(d#4z3(*+QQ9E)M(@8}+9+>yWAwV_l5N|z_3rD@ zmmNP??`tm*Os(i2>N(S+wQ{cO-d>$u^)R*NoYpAy6-NsTQ^F0*jU&F0{~JdW-e%e)j`3~MQGcDn3F3l4TuwD3U5)IJ}}SKz#5 z(ATP{tn_|TI8v$Jw}l|#C6O-1;8mP7xO#KiC$`P_R$uuVW6|; (code) h/t Mark Kim & TOYAMA Shin-ichi + * Made it easier to tell when color picker (HSV palette) + is the currently-selected color. + https://sourceforge.net/p/tuxpaint/bugs/279/ + Bill Kendrick + * Bug Fixes: ---------- * In some window size / button size combinations, Eraser @@ -110,8 +115,11 @@ https://tuxpaint.org/ (e.g., Windows) Bill Kendrick - * Mended bad rendering of color-picker (HSV palette) button when - selecting a Label text with a color not found in built-in colors. + * Mended bad rendering of color picker (HSV palette) button when + selecting a Label text with a color not found in built-in colors, + and mend unwanted outline around the chosen color in the + color selector (pipette), color picker (HSV palette) and + color mixer buttons. Bill Kendrick * Localization Updates: diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 03fa76f48..b38dbce3e 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -1679,7 +1679,7 @@ static SDL_Surface *img_shapes_corner, *img_shapes_center; static SDL_Surface *img_bold, *img_italic; static SDL_Surface *img_label_select, *img_label_apply; static SDL_Surface *img_color_picker, *img_color_picker_thumb, *img_color_picker_val; -static SDL_Surface *img_paintwell, *img_color_sel, *img_color_mix; +static SDL_Surface *img_paintwell, *img_color_sel, *img_color_mix, *img_color_picker_icon; static SDL_Surface *img_color_grab; static int color_picker_x, color_picker_y, color_picker_v; static int color_mixer_reset; @@ -2191,7 +2191,7 @@ static void draw_color_mixer_blank_example(void); static void calc_color_mixer_average(float *out_h, float *out_s, float *out_v); static void draw_color_mixer_tooltip(void); static void draw_color_mix_undo_redo(void); -static void render_color_button(int the_color, SDL_Surface * decoration, SDL_Surface * icon); +static void render_color_button(int the_color, SDL_Surface * icon); static void handle_color_changed(void); static void magic_set_color(void); static void magic_set_size(void); @@ -23852,7 +23852,7 @@ static int do_color_sel(int temp_mode) color_hexes[COLOR_SELECTOR][2] = b; /* Re-render color selector to show the current color it contains: */ - render_color_button(COLOR_SELECTOR, NULL, img_color_sel); + render_color_button(COLOR_SELECTOR, img_color_sel); } return (chose); @@ -24574,7 +24574,7 @@ static int do_color_picker(int prev_color) /* Re-render color picker to show the current color it contains: */ - render_color_button(COLOR_PICKER, img_color_picker_thumb, NULL); + render_color_button(COLOR_PICKER, img_color_picker_icon); } else { @@ -25435,7 +25435,7 @@ static int do_color_mix(void) /* Re-render color mixer to show the current color it contains: */ - render_color_button(COLOR_MIXER, NULL, img_color_mix); + render_color_button(COLOR_MIXER, img_color_mix); } else { @@ -25759,9 +25759,9 @@ static void draw_color_mixer_tooltip(void) * with their current color. * * @param int the_color - the color within the palette (e.g., COLOR_PICKER) (its RGB values will be grabbed via global color_hexes[], and the new button will be rendered into the appropriate img_color_btns[]) - * @param SDL_Surface * decoration - a decoration bitmap to be applied to the button (or NULL if none) (e.g., the color picker rainbow that appears around the color picker button's paintwell) + * @param SDL_Surface * icon - a bitmap to be applied to the button (or NULL if none) (e.g., the pipette icon that appears over the color selector) */ -static void render_color_button(int the_color, SDL_Surface * decoration, SDL_Surface * icon) +static void render_color_button(int the_color, SDL_Surface * icon) { SDL_Surface *tmp_btn_up, *tmp_btn_down; SDL_Rect dest; @@ -25808,30 +25808,18 @@ static void render_color_button(int the_color, SDL_Surface * decoration, SDL_Sur aa = a / 255.0; - if (decoration != NULL) - { - putpixels[img_color_btns[the_color]->format->BytesPerPixel] - (img_color_btns[the_color], x, y, getpixels[decoration->format->BytesPerPixel] (decoration, x, y)); - putpixels[img_color_btns[the_color + NUM_COLORS]-> - format->BytesPerPixel] (img_color_btns[the_color + NUM_COLORS], x, y, - getpixels[decoration->format->BytesPerPixel] (decoration, x, y)); - } + putpixels[img_color_btns[the_color]->format->BytesPerPixel] + (img_color_btns[the_color], x, y, + SDL_MapRGB(img_color_btns[the_color]->format, + linear_to_sRGB(rh * aa + ru * (1.0 - aa)), + linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); - if (a == 255) - { - putpixels[img_color_btns[the_color]->format->BytesPerPixel] - (img_color_btns[the_color], x, y, - SDL_MapRGB(img_color_btns[the_color]->format, - linear_to_sRGB(rh * aa + ru * (1.0 - aa)), - linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); - - putpixels[img_color_btns[the_color + NUM_COLORS]-> - format->BytesPerPixel] (img_color_btns[the_color + NUM_COLORS], x, y, - SDL_MapRGB(img_color_btns[the_color + NUM_COLORS]->format, - linear_to_sRGB(rh * aa + rd * (1.0 - aa)), - linear_to_sRGB(gh * aa + gd * (1.0 - aa)), - linear_to_sRGB(bh * aa + bd * (1.0 - aa)))); - } + putpixels[img_color_btns[the_color + NUM_COLORS]-> + format->BytesPerPixel] (img_color_btns[the_color + NUM_COLORS], x, y, + SDL_MapRGB(img_color_btns[the_color + NUM_COLORS]->format, + linear_to_sRGB(rh * aa + rd * (1.0 - aa)), + linear_to_sRGB(gh * aa + gd * (1.0 - aa)), + linear_to_sRGB(bh * aa + bd * (1.0 - aa)))); } } @@ -26216,7 +26204,7 @@ static struct label_node *search_label_list(struct label_node **ref_head, Uint16 color_hexes[select_color][1] = tmp_node->save_color.g; color_hexes[select_color][2] = tmp_node->save_color.b; - render_color_button(COLOR_PICKER, img_color_picker_thumb, NULL); + render_color_button(COLOR_PICKER, img_color_picker_icon); draw_colors(COLORSEL_CLOBBER); render_brush(); /* FIXME: render_brush should be called at the start of Brush and Line tools? */ } @@ -29856,6 +29844,7 @@ static void setup(void) img_scroll_down_off = loadimagerb(DATA_PREFIX "images/ui/scroll_down_off.png"); img_color_sel = loadimagerb(DATA_PREFIX "images/ui/csel.png"); img_color_mix = loadimagerb(DATA_PREFIX "images/ui/cmix.png"); + img_color_picker_icon = loadimagerb(DATA_PREFIX "images/ui/color_picker_icon.png"); img_color_grab = loadimagerb(DATA_PREFIX "images/ui/color_grab.png"); if (onscreen_keyboard) @@ -30112,37 +30101,23 @@ static void setup(void) double gh = sRGB_to_linear_table[color_hexes[i][1]]; double bh = sRGB_to_linear_table[color_hexes[i][2]]; - if (i == COLOR_PICKER) - { - putpixels[img_color_btns[i]->format->BytesPerPixel] - (img_color_btns[i], x, y, - getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y)); - putpixels[img_color_btns[i + NUM_COLORS]->format->BytesPerPixel] (img_color_btns[i + NUM_COLORS], x, y, - getpixels[img_color_picker_thumb-> - format->BytesPerPixel] - (img_color_picker_thumb, x, y)); - } - - if (i < COLOR_PICKER || a == 0) - { - putpixels[img_color_btns[i]->format->BytesPerPixel] - (img_color_btns[i], x, y, - SDL_MapRGB(img_color_btns[i]->format, - linear_to_sRGB(rh * aa + ru * (1.0 - aa)), - linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); - putpixels[img_color_btns[i + NUM_COLORS]->format->BytesPerPixel] (img_color_btns[i + NUM_COLORS], x, y, - SDL_MapRGB(img_color_btns - [i + NUM_COLORS]->format, - linear_to_sRGB(rh * aa + - rd * (1.0 - - aa)), - linear_to_sRGB(gh * aa + - gd * (1.0 - - aa)), - linear_to_sRGB(bh * aa + - bd * (1.0 - - aa)))); - } + putpixels[img_color_btns[i]->format->BytesPerPixel] + (img_color_btns[i], x, y, + SDL_MapRGB(img_color_btns[i]->format, + linear_to_sRGB(rh * aa + ru * (1.0 - aa)), + linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); + putpixels[img_color_btns[i + NUM_COLORS]->format->BytesPerPixel] (img_color_btns[i + NUM_COLORS], x, y, + SDL_MapRGB(img_color_btns + [i + NUM_COLORS]->format, + linear_to_sRGB(rh * aa + + rd * (1.0 - + aa)), + linear_to_sRGB(gh * aa + + gd * (1.0 - + aa)), + linear_to_sRGB(bh * aa + + bd * (1.0 - + aa)))); } } } @@ -30160,6 +30135,15 @@ static void setup(void) dest.h = img_color_sel->h; SDL_BlitSurface(img_color_sel, NULL, img_color_btns[i], &dest); } + else if (i == COLOR_PICKER || i == COLOR_SELECTOR + NUM_COLORS) + { + /* Color selector; draw rainbow */ + dest.x = (img_color_btns[i]->w - img_color_picker_icon->w) / 2; + dest.y = (img_color_btns[i]->h - img_color_picker_icon->h) / 2; + dest.w = img_color_picker_icon->w; + dest.h = img_color_picker_icon->h; + SDL_BlitSurface(img_color_picker_icon, NULL, img_color_btns[i], &dest); + } else if (i == COLOR_MIXER || i == COLOR_MIXER + NUM_COLORS) { /* Color mixer; draw palette */