Ctrl+click to pick colors immediately
A keyboard shortcut is now available for picking colors from the canvas more quickly. Hold either (left or right) [Ctrl] key while clicking, and the color selector option will appear. Release the mouse button over a color on the canvas to choose it (or outside the canvas to abort). Closes https://sourceforge.net/p/tuxpaint/feature-requests/209/ Also, * Don't play 'bubble' paint sound when color picker or selector are aborted (e.g., via their "Back" buttons). * Replace many instances of "NUM_COLOR - 1" and "NUM_COLOR - 2" (which correspond to color chose via picker (palette) and selector (canvas), respectively) with #define's that represent them. (Avoid magic numbers.)
This commit is contained in:
parent
076b15fd20
commit
3b4d2fc8f2
2 changed files with 531 additions and 478 deletions
|
|
@ -70,10 +70,16 @@ http://www.tuxpaint.org/
|
||||||
* Show a "pipette"-shaped mouse pointer when selecting a
|
* Show a "pipette"-shaped mouse pointer when selecting a
|
||||||
color from the color palette, or the picture.
|
color from the color palette, or the picture.
|
||||||
|
|
||||||
* WIP Provide a keyboard shortcut for picking colors from
|
* A keyboard shortcut is now available for picking colors from
|
||||||
the canvas more quickly.
|
the canvas more quickly. Hold either (left or right) [Ctrl] key
|
||||||
|
while clicking, and the color selector option will appear.
|
||||||
|
Release the mouse button over a color on the canvas to choose it
|
||||||
|
(or outside the canvas to abort).
|
||||||
Closes https://sourceforge.net/p/tuxpaint/feature-requests/209/
|
Closes https://sourceforge.net/p/tuxpaint/feature-requests/209/
|
||||||
|
|
||||||
|
* Don't play 'bubble' paint sound when color picker or selector
|
||||||
|
are aborted (e.g., via their "Back" buttons).
|
||||||
|
|
||||||
* Localization Updates:
|
* Localization Updates:
|
||||||
---------------------
|
---------------------
|
||||||
* Albanian translation
|
* Albanian translation
|
||||||
|
|
|
||||||
247
src/tuxpaint.c
247
src/tuxpaint.c
|
|
@ -691,6 +691,8 @@ static int NUM_COLORS;
|
||||||
static Uint8 **color_hexes;
|
static Uint8 **color_hexes;
|
||||||
static char **color_names;
|
static char **color_names;
|
||||||
|
|
||||||
|
#define COLOR_SELECTOR (NUM_COLORS - 2)
|
||||||
|
#define COLOR_PICKER (NUM_COLORS - 1)
|
||||||
|
|
||||||
/* Show debugging stuff: */
|
/* Show debugging stuff: */
|
||||||
|
|
||||||
|
|
@ -2180,6 +2182,7 @@ static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, int *d
|
||||||
char * *d_exts, int *white_in_palette);
|
char * *d_exts, int *white_in_palette);
|
||||||
static int do_color_picker(void);
|
static int do_color_picker(void);
|
||||||
static int do_color_sel(int temp_mode);
|
static int do_color_sel(int temp_mode);
|
||||||
|
static void handle_color_changed(void);
|
||||||
|
|
||||||
static int do_slideshow(void);
|
static int do_slideshow(void);
|
||||||
static void play_slideshow(int *selected, int num_selected, char *dirname, char **d_names, char **d_exts, int speed);
|
static void play_slideshow(int *selected, int num_selected, char *dirname, char **d_names, char **d_exts, int speed);
|
||||||
|
|
@ -2599,6 +2602,7 @@ static void mainloop(void)
|
||||||
(key_unicode > ' ' && key_unicode < 127) ? (char)event.text.text : ' ',
|
(key_unicode > ' ' && key_unicode < 127) ? (char)event.text.text : ' ',
|
||||||
iswprint(key_unicode) ? "" : "not ", (unsigned)key_down);
|
iswprint(key_unicode) ? "" : "not ", (unsigned)key_down);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cur_tool == TOOL_STAMP)
|
if (cur_tool == TOOL_STAMP)
|
||||||
{
|
{
|
||||||
SDL_Rect r_stamps_sizesel;
|
SDL_Rect r_stamps_sizesel;
|
||||||
|
|
@ -4708,17 +4712,19 @@ static void mainloop(void)
|
||||||
cur_color = whichc;
|
cur_color = whichc;
|
||||||
draw_tux_text(TUX_KISS, color_names[cur_color], 1);
|
draw_tux_text(TUX_KISS, color_names[cur_color], 1);
|
||||||
|
|
||||||
if (cur_color == (unsigned)(NUM_COLORS - 1) || cur_color == (unsigned)(NUM_COLORS - 2))
|
if (cur_color == (unsigned) COLOR_PICKER || cur_color == (unsigned) COLOR_SELECTOR)
|
||||||
{
|
{
|
||||||
|
int chose_color;
|
||||||
|
|
||||||
disable_avail_tools();
|
disable_avail_tools();
|
||||||
draw_toolbar();
|
draw_toolbar();
|
||||||
draw_colors(COLORSEL_CLOBBER_WIPE);
|
draw_colors(COLORSEL_CLOBBER_WIPE);
|
||||||
draw_none();
|
draw_none();
|
||||||
|
|
||||||
if (cur_color == (unsigned)(NUM_COLORS - 1))
|
if (cur_color == (unsigned) COLOR_PICKER)
|
||||||
do_color_picker();
|
chose_color = do_color_picker();
|
||||||
else
|
else
|
||||||
do_color_sel(0);
|
chose_color = do_color_sel(0);
|
||||||
|
|
||||||
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
||||||
{
|
{
|
||||||
|
|
@ -4757,7 +4763,10 @@ static void mainloop(void)
|
||||||
else if (cur_tool == TOOL_FILL)
|
else if (cur_tool == TOOL_FILL)
|
||||||
draw_fills();
|
draw_fills();
|
||||||
|
|
||||||
|
if (chose_color)
|
||||||
playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, SNDDIST_NEAR);
|
playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, SNDDIST_NEAR);
|
||||||
|
else
|
||||||
|
playsound(screen, 1, SND_CLICK, 1, SNDPOS_CENTER, SNDDIST_NEAR);
|
||||||
|
|
||||||
SDL_Flip(screen);
|
SDL_Flip(screen);
|
||||||
}
|
}
|
||||||
|
|
@ -4768,23 +4777,38 @@ static void mainloop(void)
|
||||||
playsound(screen, 1, SND_BUBBLE, 1, event.button.x, SNDDIST_NEAR);
|
playsound(screen, 1, SND_BUBBLE, 1, event.button.x, SNDDIST_NEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_brush();
|
handle_color_changed();
|
||||||
|
|
||||||
|
|
||||||
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
|
||||||
do_render_cur_text(0);
|
|
||||||
else if (cur_tool == TOOL_MAGIC)
|
|
||||||
magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].set_color(
|
|
||||||
magic_api_struct,
|
|
||||||
color_hexes[cur_color][0],
|
|
||||||
color_hexes[cur_color][1],
|
|
||||||
color_hexes[cur_color][2]);
|
|
||||||
else if (cur_tool == TOOL_STAMP)
|
|
||||||
clear_cached_stamp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (HIT(r_canvas) && valid_click(event.button.button) && keyglobal == 0)
|
else if (HIT(r_canvas) && valid_click(event.button.button) && keyglobal == 0)
|
||||||
|
{
|
||||||
|
Uint8 * kbd_state;
|
||||||
|
|
||||||
|
kbd_state = SDL_GetKeyState(NULL);
|
||||||
|
|
||||||
|
if ((kbd_state[SDLK_LCTRL] || kbd_state[SDLK_RCTRL]) && colors_are_selectable)
|
||||||
|
{
|
||||||
|
int chose_color;
|
||||||
|
|
||||||
|
/* Holding [Ctrl] while clicking; switch to temp-mode color selector! */
|
||||||
|
chose_color = do_color_sel(1);
|
||||||
|
|
||||||
|
draw_cur_tool_tip();
|
||||||
|
draw_colors(COLORSEL_FORCE_REDRAW);
|
||||||
|
|
||||||
|
if (chose_color)
|
||||||
|
{
|
||||||
|
playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, SNDDIST_NEAR);
|
||||||
|
cur_color = COLOR_SELECTOR;
|
||||||
|
handle_color_changed();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
playsound(screen, 1, SND_CLICK, 1, SNDPOS_CENTER, SNDDIST_NEAR);
|
||||||
|
|
||||||
|
SDL_Flip(screen);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* Draw something! */
|
/* Draw something! */
|
||||||
old_x = event.button.x - r_canvas.x;
|
old_x = event.button.x - r_canvas.x;
|
||||||
|
|
@ -5003,7 +5027,7 @@ static void mainloop(void)
|
||||||
if (cur_fill == FILL_FLOOD)
|
if (cur_fill == FILL_FLOOD)
|
||||||
{
|
{
|
||||||
/* Flood fill a solid color */
|
/* Flood fill a solid color */
|
||||||
do_flood_fill(screen, texture, renderer, last, canvas, old_x, old_y, draw_color, canv_color, &x1, &y1, &x2, &y2, sim_flood_touched);
|
do_flood_fill(screen, last, canvas, old_x, old_y, draw_color, canv_color, &x1, &y1, &x2, &y2, sim_flood_touched);
|
||||||
|
|
||||||
update_canvas(x1, y1, x2, y2);
|
update_canvas(x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
@ -5016,7 +5040,7 @@ static void mainloop(void)
|
||||||
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||||
SDL_BlitSurface(canvas, NULL, tmp_canvas, NULL);
|
SDL_BlitSurface(canvas, NULL, tmp_canvas, NULL);
|
||||||
|
|
||||||
simulate_flood_fill(screen, texture, renderer, last, tmp_canvas, old_x, old_y, draw_color, canv_color, &x1, &y1, &x2, &y2, sim_flood_touched);
|
simulate_flood_fill(screen, last, tmp_canvas, old_x, old_y, draw_color, canv_color, &x1, &y1, &x2, &y2, sim_flood_touched);
|
||||||
SDL_FreeSurface(tmp_canvas);
|
SDL_FreeSurface(tmp_canvas);
|
||||||
|
|
||||||
sim_flood_x1 = x1;
|
sim_flood_x1 = x1;
|
||||||
|
|
@ -5050,6 +5074,7 @@ static void mainloop(void)
|
||||||
draw_tux_text(TUX_GREAT, fill_tips[cur_fill], 1);
|
draw_tux_text(TUX_GREAT, fill_tips[cur_fill], 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
else if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
||||||
{
|
{
|
||||||
if (onscreen_keyboard && !kbd)
|
if (onscreen_keyboard && !kbd)
|
||||||
|
|
@ -5096,7 +5121,7 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
draw_fonts();
|
draw_fonts();
|
||||||
update_screen_rect(&r_toolopt);
|
update_screen_rect(&r_toolopt);
|
||||||
if (onscreen_keyboard && kbd)
|
if (onscreen_keyboard)
|
||||||
{
|
{
|
||||||
if (old_y < r_canvas.h / 2)
|
if (old_y < r_canvas.h / 2)
|
||||||
kbd_rect.y = r_canvas.h - kbd->surface->h;
|
kbd_rect.y = r_canvas.h - kbd->surface->h;
|
||||||
|
|
@ -5107,6 +5132,11 @@ static void mainloop(void)
|
||||||
update_screen_rect(&kbd_rect);
|
update_screen_rect(&kbd_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_render_cur_text(0);
|
||||||
|
draw_colors(COLORSEL_REFRESH);
|
||||||
|
draw_fonts();
|
||||||
|
}
|
||||||
|
|
||||||
if (onscreen_keyboard && !kbd)
|
if (onscreen_keyboard && !kbd)
|
||||||
{
|
{
|
||||||
r_tir.y = (float)old_y / render_scale;
|
r_tir.y = (float)old_y / render_scale;
|
||||||
|
|
@ -5117,8 +5147,6 @@ static void mainloop(void)
|
||||||
draw_colors(COLORSEL_REFRESH);
|
draw_colors(COLORSEL_REFRESH);
|
||||||
draw_fonts();
|
draw_fonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
hide_blinking_cursor();
|
hide_blinking_cursor();
|
||||||
|
|
||||||
|
|
@ -5135,8 +5163,7 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
if (onscreen_keyboard && kbd && HIT(kbd_rect)
|
if (onscreen_keyboard && kbd && HIT(kbd_rect) && !(cur_tool == TOOL_LABEL && cur_label == LABEL_SELECT))
|
||||||
&& !(cur_tool == TOOL_LABEL && cur_label == LABEL_SELECT))
|
|
||||||
{
|
{
|
||||||
new_kbd = osk_clicked(kbd, old_x - kbd_rect.x + r_canvas.x, old_y - kbd_rect.y + r_canvas.y);
|
new_kbd = osk_clicked(kbd, old_x - kbd_rect.x + r_canvas.x, old_y - kbd_rect.y + r_canvas.y);
|
||||||
/* keyboard has changed, erase the old, note that the old kbd has yet been freed. */
|
/* keyboard has changed, erase the old, note that the old kbd has yet been freed. */
|
||||||
|
|
@ -5161,7 +5188,7 @@ static void mainloop(void)
|
||||||
cursor_y = old_y;
|
cursor_y = old_y;
|
||||||
cursor_left = old_x;
|
cursor_left = old_x;
|
||||||
|
|
||||||
if (onscreen_keyboard && kbd && !(cur_tool == TOOL_LABEL && cur_label == LABEL_SELECT))
|
if (onscreen_keyboard && !(cur_tool == TOOL_LABEL && cur_label == LABEL_SELECT))
|
||||||
{
|
{
|
||||||
if (old_y < r_canvas.h / 2)
|
if (old_y < r_canvas.h / 2)
|
||||||
{
|
{
|
||||||
|
|
@ -5188,6 +5215,7 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (onscreen_keyboard && !kbd)
|
if (onscreen_keyboard && !kbd)
|
||||||
{
|
{
|
||||||
|
|
@ -5202,6 +5230,7 @@ static void mainloop(void)
|
||||||
|
|
||||||
button_down = 1;
|
button_down = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (HIT(r_sfx) && valid_click(event.button.button))
|
else if (HIT(r_sfx) && valid_click(event.button.button))
|
||||||
{
|
{
|
||||||
/* A sound player button on the lower left has been pressed! */
|
/* A sound player button on the lower left has been pressed! */
|
||||||
|
|
@ -7095,8 +7124,6 @@ static void stamp_draw(int x, int y)
|
||||||
|
|
||||||
if (current_stamp_cached == NULL)
|
if (current_stamp_cached == NULL)
|
||||||
{
|
{
|
||||||
printf("Generating stamp image\n");
|
|
||||||
|
|
||||||
Uint32(*getpixel) (SDL_Surface *, int, int);
|
Uint32(*getpixel) (SDL_Surface *, int, int);
|
||||||
void (*putpixel) (SDL_Surface *, int, int, Uint32);
|
void (*putpixel) (SDL_Surface *, int, int, Uint32);
|
||||||
|
|
||||||
|
|
@ -7189,13 +7216,10 @@ static void stamp_draw(int x, int y)
|
||||||
tmp_surf = surf_ptr;
|
tmp_surf = surf_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Caching stamp\n");
|
|
||||||
current_stamp_cached = SDL_DisplayFormatAlpha(tmp_surf);
|
current_stamp_cached = SDL_DisplayFormatAlpha(tmp_surf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Using cached stamp!\n");
|
|
||||||
|
|
||||||
tmp_surf = current_stamp_cached;
|
tmp_surf = current_stamp_cached;
|
||||||
dont_free_tmp_surf = 1;
|
dont_free_tmp_surf = 1;
|
||||||
dont_free_scaled_surf = 1;
|
dont_free_scaled_surf = 1;
|
||||||
|
|
@ -7924,14 +7948,9 @@ static void clear_cached_stamp(void)
|
||||||
{
|
{
|
||||||
if (current_stamp_cached != NULL)
|
if (current_stamp_cached != NULL)
|
||||||
{
|
{
|
||||||
printf("Clearing cached stamp\n");
|
|
||||||
SDL_FreeSurface(current_stamp_cached);
|
SDL_FreeSurface(current_stamp_cached);
|
||||||
current_stamp_cached = NULL;
|
current_stamp_cached = NULL;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("No cached stamp to clear\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21706,7 +21725,7 @@ static int do_new_dialog(void)
|
||||||
|
|
||||||
/* Launch color picker if they chose that: */
|
/* Launch color picker if they chose that: */
|
||||||
|
|
||||||
if (which == NUM_COLORS - 1)
|
if (which == COLOR_PICKER)
|
||||||
{
|
{
|
||||||
if (do_color_picker() == 0)
|
if (do_color_picker() == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
@ -21794,7 +21813,7 @@ static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, int *d
|
||||||
{
|
{
|
||||||
added = 0;
|
added = 0;
|
||||||
|
|
||||||
if (j < NUM_COLORS - 1)
|
if (j < COLOR_PICKER)
|
||||||
{
|
{
|
||||||
if (j == -1 || /* (short circuit) */
|
if (j == -1 || /* (short circuit) */
|
||||||
color_hexes[j][0] != 255 || /* Ignore white, we'll have already added it */
|
color_hexes[j][0] != 255 || /* Ignore white, we'll have already added it */
|
||||||
|
|
@ -22058,8 +22077,9 @@ static int do_color_sel(int temp_mode)
|
||||||
|
|
||||||
SDL_FillRect(screen, &color_example_dest,
|
SDL_FillRect(screen, &color_example_dest,
|
||||||
SDL_MapRGB(screen->format,
|
SDL_MapRGB(screen->format,
|
||||||
color_hexes[NUM_COLORS - 2][0],
|
color_hexes[COLOR_SELECTOR][0],
|
||||||
color_hexes[NUM_COLORS - 2][1], color_hexes[NUM_COLORS - 2][2]));
|
color_hexes[COLOR_SELECTOR][1],
|
||||||
|
color_hexes[COLOR_SELECTOR][2]));
|
||||||
|
|
||||||
/* Show "Back" button */
|
/* Show "Back" button */
|
||||||
back_left = r_color_sel.x + r_color_sel.w - button_w - 4;
|
back_left = r_color_sel.x + r_color_sel.w - button_w - 4;
|
||||||
|
|
@ -22083,6 +22103,9 @@ static int do_color_sel(int temp_mode)
|
||||||
SDL_GetMouseState(&mx, &my);
|
SDL_GetMouseState(&mx, &my);
|
||||||
SDL_WarpMouse(mx - 1, my); /* Need to move to a different spot, or no events occur */
|
SDL_WarpMouse(mx - 1, my); /* Need to move to a different spot, or no events occur */
|
||||||
SDL_WarpMouse(mx, my);
|
SDL_WarpMouse(mx, my);
|
||||||
|
|
||||||
|
/* These will be unused in this mode: */
|
||||||
|
back_left = back_top = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22212,8 +22235,9 @@ static int do_color_sel(int temp_mode)
|
||||||
|
|
||||||
SDL_FillRect(screen, &color_example_dest,
|
SDL_FillRect(screen, &color_example_dest,
|
||||||
SDL_MapRGB(screen->format,
|
SDL_MapRGB(screen->format,
|
||||||
color_hexes[NUM_COLORS - 2][0],
|
color_hexes[COLOR_SELECTOR][0],
|
||||||
color_hexes[NUM_COLORS - 2][1], color_hexes[NUM_COLORS - 2][2]));
|
color_hexes[COLOR_SELECTOR][1],
|
||||||
|
color_hexes[COLOR_SELECTOR][2]));
|
||||||
|
|
||||||
SDL_UpdateRect(screen,
|
SDL_UpdateRect(screen,
|
||||||
color_example_dest.x,
|
color_example_dest.x,
|
||||||
|
|
@ -22262,9 +22286,9 @@ static int do_color_sel(int temp_mode)
|
||||||
getpixel_img_color_picker = getpixels[canvas->format->BytesPerPixel];
|
getpixel_img_color_picker = getpixels[canvas->format->BytesPerPixel];
|
||||||
SDL_GetRGB(getpixel_img_color_picker(canvas, color_sel_x, color_sel_y), canvas->format, &r, &g, &b);
|
SDL_GetRGB(getpixel_img_color_picker(canvas, color_sel_x, color_sel_y), canvas->format, &r, &g, &b);
|
||||||
|
|
||||||
color_hexes[NUM_COLORS - 2][0] = r;
|
color_hexes[COLOR_SELECTOR][0] = r;
|
||||||
color_hexes[NUM_COLORS - 2][1] = g;
|
color_hexes[COLOR_SELECTOR][1] = g;
|
||||||
color_hexes[NUM_COLORS - 2][2] = b;
|
color_hexes[COLOR_SELECTOR][2] = b;
|
||||||
|
|
||||||
|
|
||||||
/* Re-render color picker to show the current color it contains: */
|
/* Re-render color picker to show the current color it contains: */
|
||||||
|
|
@ -22277,14 +22301,14 @@ static int do_color_sel(int temp_mode)
|
||||||
getpixel_tmp_btn_down = getpixels[tmp_btn_down->format->BytesPerPixel];
|
getpixel_tmp_btn_down = getpixels[tmp_btn_down->format->BytesPerPixel];
|
||||||
getpixel_img_paintwell = getpixels[img_paintwell->format->BytesPerPixel];
|
getpixel_img_paintwell = getpixels[img_paintwell->format->BytesPerPixel];
|
||||||
|
|
||||||
rh = sRGB_to_linear_table[color_hexes[NUM_COLORS - 2][0]];
|
rh = sRGB_to_linear_table[color_hexes[COLOR_SELECTOR][0]];
|
||||||
gh = sRGB_to_linear_table[color_hexes[NUM_COLORS - 2][1]];
|
gh = sRGB_to_linear_table[color_hexes[COLOR_SELECTOR][1]];
|
||||||
bh = sRGB_to_linear_table[color_hexes[NUM_COLORS - 2][2]];
|
bh = sRGB_to_linear_table[color_hexes[COLOR_SELECTOR][2]];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SDL_LockSurface(img_color_btns[NUM_COLORS - 2]);
|
SDL_LockSurface(img_color_btns[COLOR_SELECTOR]);
|
||||||
SDL_LockSurface(img_color_btns[NUM_COLORS - 2 + NUM_COLORS]);
|
SDL_LockSurface(img_color_btns[COLOR_SELECTOR + NUM_COLORS]);
|
||||||
|
|
||||||
for (y = 0; y < tmp_btn_up->h /* 48 */ ; y++)
|
for (y = 0; y < tmp_btn_up->h /* 48 */ ; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -22309,14 +22333,14 @@ static int do_color_sel(int temp_mode)
|
||||||
|
|
||||||
if (a == 255)
|
if (a == 255)
|
||||||
{
|
{
|
||||||
putpixels[img_color_btns[NUM_COLORS - 2]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_SELECTOR]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 2], x, y,
|
(img_color_btns[COLOR_SELECTOR], x, y,
|
||||||
SDL_MapRGB(img_color_btns[i]->format,
|
SDL_MapRGB(img_color_btns[i]->format,
|
||||||
linear_to_sRGB(rh * aa + ru * (1.0 - aa)),
|
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))));
|
linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa))));
|
||||||
|
|
||||||
putpixels[img_color_btns[NUM_COLORS - 2 + NUM_COLORS]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_SELECTOR + NUM_COLORS]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 2 + NUM_COLORS], x, y,
|
(img_color_btns[COLOR_SELECTOR + NUM_COLORS], x, y,
|
||||||
SDL_MapRGB(img_color_btns[i + NUM_COLORS]->format,
|
SDL_MapRGB(img_color_btns[i + NUM_COLORS]->format,
|
||||||
linear_to_sRGB(rh * aa + rd * (1.0 - aa)),
|
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))));
|
linear_to_sRGB(gh * aa + gd * (1.0 - aa)), linear_to_sRGB(bh * aa + bd * (1.0 - aa))));
|
||||||
|
|
@ -22324,18 +22348,18 @@ static int do_color_sel(int temp_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockSurface(img_color_btns[NUM_COLORS - 2]);
|
SDL_UnlockSurface(img_color_btns[COLOR_SELECTOR]);
|
||||||
SDL_UnlockSurface(img_color_btns[NUM_COLORS - 2 + NUM_COLORS]);
|
SDL_UnlockSurface(img_color_btns[COLOR_SELECTOR + NUM_COLORS]);
|
||||||
|
|
||||||
dest.x = (img_color_btns[NUM_COLORS - 2]->w - img_color_sel->w) / 2;
|
dest.x = (img_color_btns[COLOR_SELECTOR]->w - img_color_sel->w) / 2;
|
||||||
dest.y = (img_color_btns[NUM_COLORS - 2]->h - img_color_sel->h) / 2;
|
dest.y = (img_color_btns[COLOR_SELECTOR]->h - img_color_sel->h) / 2;
|
||||||
dest.w = img_color_sel->w;
|
dest.w = img_color_sel->w;
|
||||||
dest.h = img_color_sel->h;
|
dest.h = img_color_sel->h;
|
||||||
SDL_BlitSurface(img_color_sel, NULL, img_color_btns[NUM_COLORS - 2], &dest);
|
SDL_BlitSurface(img_color_sel, NULL, img_color_btns[COLOR_SELECTOR], &dest);
|
||||||
|
|
||||||
dest.x = (img_color_btns[NUM_COLORS - 2 + NUM_COLORS]->w - img_color_sel->w) / 2;
|
dest.x = (img_color_btns[COLOR_SELECTOR + NUM_COLORS]->w - img_color_sel->w) / 2;
|
||||||
dest.y = (img_color_btns[NUM_COLORS - 2 + NUM_COLORS]->h - img_color_sel->h) / 2;
|
dest.y = (img_color_btns[COLOR_SELECTOR + NUM_COLORS]->h - img_color_sel->h) / 2;
|
||||||
SDL_BlitSurface(img_color_sel, NULL, img_color_btns[NUM_COLORS - 2 + NUM_COLORS], &dest);
|
SDL_BlitSurface(img_color_sel, NULL, img_color_btns[COLOR_SELECTOR + NUM_COLORS], &dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (chose);
|
return (chose);
|
||||||
|
|
@ -22534,8 +22558,9 @@ static int do_color_picker(void)
|
||||||
|
|
||||||
SDL_FillRect(screen, &color_example_dest,
|
SDL_FillRect(screen, &color_example_dest,
|
||||||
SDL_MapRGB(screen->format,
|
SDL_MapRGB(screen->format,
|
||||||
color_hexes[NUM_COLORS - 1][0],
|
color_hexes[COLOR_PICKER][0],
|
||||||
color_hexes[NUM_COLORS - 1][1], color_hexes[NUM_COLORS - 1][2]));
|
color_hexes[COLOR_PICKER][1],
|
||||||
|
color_hexes[COLOR_PICKER][2]));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22655,8 +22680,9 @@ static int do_color_picker(void)
|
||||||
|
|
||||||
SDL_FillRect(screen, &color_example_dest,
|
SDL_FillRect(screen, &color_example_dest,
|
||||||
SDL_MapRGB(screen->format,
|
SDL_MapRGB(screen->format,
|
||||||
color_hexes[NUM_COLORS - 1][0],
|
color_hexes[COLOR_PICKER][0],
|
||||||
color_hexes[NUM_COLORS - 1][1], color_hexes[NUM_COLORS - 1][2]));
|
color_hexes[COLOR_PICKER][1],
|
||||||
|
color_hexes[COLOR_PICKER][2]));
|
||||||
|
|
||||||
SDL_UpdateRect(screen,
|
SDL_UpdateRect(screen,
|
||||||
color_example_dest.x,
|
color_example_dest.x,
|
||||||
|
|
@ -22704,9 +22730,9 @@ static int do_color_picker(void)
|
||||||
getpixel_img_color_picker = getpixels[img_color_picker->format->BytesPerPixel];
|
getpixel_img_color_picker = getpixels[img_color_picker->format->BytesPerPixel];
|
||||||
SDL_GetRGB(getpixel_img_color_picker(img_color_picker, x, y), img_color_picker->format, &r, &g, &b);
|
SDL_GetRGB(getpixel_img_color_picker(img_color_picker, x, y), img_color_picker->format, &r, &g, &b);
|
||||||
|
|
||||||
color_hexes[NUM_COLORS - 1][0] = r;
|
color_hexes[COLOR_PICKER][0] = r;
|
||||||
color_hexes[NUM_COLORS - 1][1] = g;
|
color_hexes[COLOR_PICKER][1] = g;
|
||||||
color_hexes[NUM_COLORS - 1][2] = b;
|
color_hexes[COLOR_PICKER][2] = b;
|
||||||
|
|
||||||
|
|
||||||
/* Re-render color picker to show the current color it contains: */
|
/* Re-render color picker to show the current color it contains: */
|
||||||
|
|
@ -22719,14 +22745,14 @@ static int do_color_picker(void)
|
||||||
getpixel_tmp_btn_down = getpixels[tmp_btn_down->format->BytesPerPixel];
|
getpixel_tmp_btn_down = getpixels[tmp_btn_down->format->BytesPerPixel];
|
||||||
getpixel_img_paintwell = getpixels[img_paintwell->format->BytesPerPixel];
|
getpixel_img_paintwell = getpixels[img_paintwell->format->BytesPerPixel];
|
||||||
|
|
||||||
rh = sRGB_to_linear_table[color_hexes[NUM_COLORS - 1][0]];
|
rh = sRGB_to_linear_table[color_hexes[COLOR_PICKER][0]];
|
||||||
gh = sRGB_to_linear_table[color_hexes[NUM_COLORS - 1][1]];
|
gh = sRGB_to_linear_table[color_hexes[COLOR_PICKER][1]];
|
||||||
bh = sRGB_to_linear_table[color_hexes[NUM_COLORS - 1][2]];
|
bh = sRGB_to_linear_table[color_hexes[COLOR_PICKER][2]];
|
||||||
SDL_BlitSurface(tmp_btn_down, NULL, img_color_btns[NUM_COLORS - 1], NULL);
|
SDL_BlitSurface(tmp_btn_down, NULL, img_color_btns[NUM_COLORS - 1], NULL);
|
||||||
SDL_BlitSurface(tmp_btn_up, NULL, img_color_btns[NUM_COLORS - 1 + NUM_COLORS], NULL);
|
SDL_BlitSurface(tmp_btn_up, NULL, img_color_btns[NUM_COLORS - 1 + NUM_COLORS], NULL);
|
||||||
|
|
||||||
SDL_LockSurface(img_color_btns[NUM_COLORS - 1]);
|
SDL_LockSurface(img_color_btns[COLOR_PICKER]);
|
||||||
SDL_LockSurface(img_color_btns[NUM_COLORS - 1 + NUM_COLORS]);
|
SDL_LockSurface(img_color_btns[COLOR_PICKER + NUM_COLORS]);
|
||||||
|
|
||||||
for (y = 0; y < tmp_btn_up->h /* 48 */ ; y++)
|
for (y = 0; y < tmp_btn_up->h /* 48 */ ; y++)
|
||||||
{
|
{
|
||||||
|
|
@ -22749,23 +22775,23 @@ static int do_color_picker(void)
|
||||||
|
|
||||||
aa = a / 255.0;
|
aa = a / 255.0;
|
||||||
|
|
||||||
putpixels[img_color_btns[NUM_COLORS - 1]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_PICKER]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 1], x, y,
|
(img_color_btns[COLOR_PICKER], x, y,
|
||||||
getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y));
|
getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y));
|
||||||
putpixels[img_color_btns[NUM_COLORS - 1 + NUM_COLORS]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_PICKER + NUM_COLORS]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 1 + NUM_COLORS], x, y,
|
(img_color_btns[COLOR_PICKER + NUM_COLORS], x, y,
|
||||||
getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y));
|
getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y));
|
||||||
|
|
||||||
if (a == 255)
|
if (a == 255)
|
||||||
{
|
{
|
||||||
putpixels[img_color_btns[NUM_COLORS - 1]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_PICKER]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 1], x, y,
|
(img_color_btns[COLOR_PICKER], x, y,
|
||||||
SDL_MapRGB(img_color_btns[i]->format,
|
SDL_MapRGB(img_color_btns[i]->format,
|
||||||
linear_to_sRGB(rh * aa + ru * (1.0 - aa)),
|
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))));
|
linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa))));
|
||||||
|
|
||||||
putpixels[img_color_btns[NUM_COLORS - 1 + NUM_COLORS]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_PICKER + NUM_COLORS]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 1 + NUM_COLORS], x, y,
|
(img_color_btns[COLOR_PICKER + NUM_COLORS], x, y,
|
||||||
SDL_MapRGB(img_color_btns[i + NUM_COLORS]->format,
|
SDL_MapRGB(img_color_btns[i + NUM_COLORS]->format,
|
||||||
linear_to_sRGB(rh * aa + rd * (1.0 - aa)),
|
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))));
|
linear_to_sRGB(gh * aa + gd * (1.0 - aa)), linear_to_sRGB(bh * aa + bd * (1.0 - aa))));
|
||||||
|
|
@ -22773,8 +22799,8 @@ static int do_color_picker(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockSurface(img_color_btns[NUM_COLORS - 1]);
|
SDL_UnlockSurface(img_color_btns[COLOR_PICKER]);
|
||||||
SDL_UnlockSurface(img_color_btns[NUM_COLORS - 1 + NUM_COLORS]);
|
SDL_UnlockSurface(img_color_btns[COLOR_PICKER + NUM_COLORS]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22786,6 +22812,27 @@ static int do_color_picker(void)
|
||||||
return (chose);
|
return (chose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Things to do whenever a color is changed
|
||||||
|
* (either by selecting a color, using the color selector in full-UI mode,
|
||||||
|
* using the color picker (palette), or using the shortcut key to
|
||||||
|
* use color selector in temp-mode.
|
||||||
|
*/
|
||||||
|
static void handle_color_changed(void) {
|
||||||
|
render_brush();
|
||||||
|
|
||||||
|
|
||||||
|
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
||||||
|
do_render_cur_text(0);
|
||||||
|
else if (cur_tool == TOOL_MAGIC)
|
||||||
|
magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].set_color(
|
||||||
|
magic_api_struct,
|
||||||
|
color_hexes[cur_color][0],
|
||||||
|
color_hexes[cur_color][1],
|
||||||
|
color_hexes[cur_color][2]);
|
||||||
|
else if (cur_tool == TOOL_STAMP)
|
||||||
|
clear_cached_stamp();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME
|
* FIXME
|
||||||
|
|
@ -23022,22 +23069,22 @@ static struct label_node *search_label_list(struct label_node **ref_head, Uint16
|
||||||
{
|
{
|
||||||
if ((color_hexes[k][0] == tmp_node->save_color.r) &&
|
if ((color_hexes[k][0] == tmp_node->save_color.r) &&
|
||||||
(color_hexes[k][1] == tmp_node->save_color.g) &&
|
(color_hexes[k][1] == tmp_node->save_color.g) &&
|
||||||
(color_hexes[k][2] == tmp_node->save_color.b) && (k < NUM_COLORS - 1))
|
(color_hexes[k][2] == tmp_node->save_color.b) && (k < COLOR_PICKER))
|
||||||
{
|
{
|
||||||
select_color = k;
|
select_color = k;
|
||||||
cur_color = k;
|
cur_color = k;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k == NUM_COLORS - 1)
|
if (k == COLOR_PICKER)
|
||||||
{
|
{
|
||||||
cur_color = NUM_COLORS - 1;
|
cur_color = COLOR_PICKER;
|
||||||
select_color = NUM_COLORS - 1;
|
select_color = COLOR_PICKER;
|
||||||
color_hexes[select_color][0] = tmp_node->save_color.r;
|
color_hexes[select_color][0] = tmp_node->save_color.r;
|
||||||
color_hexes[select_color][1] = tmp_node->save_color.g;
|
color_hexes[select_color][1] = tmp_node->save_color.g;
|
||||||
color_hexes[select_color][2] = tmp_node->save_color.b;
|
color_hexes[select_color][2] = tmp_node->save_color.b;
|
||||||
SDL_LockSurface(img_color_btns[NUM_COLORS - 1]);
|
SDL_LockSurface(img_color_btns[COLOR_PICKER]);
|
||||||
SDL_LockSurface(img_color_btns[NUM_COLORS - 1 + NUM_COLORS]);
|
SDL_LockSurface(img_color_btns[COLOR_PICKER + NUM_COLORS]);
|
||||||
|
|
||||||
for (j = 0; j < 48 /* 48 */ ; j++)
|
for (j = 0; j < 48 /* 48 */ ; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -23047,19 +23094,19 @@ static struct label_node *search_label_list(struct label_node **ref_head, Uint16
|
||||||
img_paintwell->format, &r, &g, &b, &a);
|
img_paintwell->format, &r, &g, &b, &a);
|
||||||
if (a == 255)
|
if (a == 255)
|
||||||
{
|
{
|
||||||
putpixels[img_color_btns[NUM_COLORS - 1]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_PICKER]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 1], i, j,
|
(img_color_btns[COLOR_PICKER], i, j,
|
||||||
SDL_MapRGB(img_color_btns[NUM_COLORS - 1]->format,
|
SDL_MapRGB(img_color_btns[COLOR_PICKER]->format,
|
||||||
tmp_node->save_color.r, tmp_node->save_color.g, tmp_node->save_color.b));
|
tmp_node->save_color.r, tmp_node->save_color.g, tmp_node->save_color.b));
|
||||||
putpixels[img_color_btns[NUM_COLORS - 1 + NUM_COLORS]->format->BytesPerPixel]
|
putpixels[img_color_btns[COLOR_PICKER + NUM_COLORS]->format->BytesPerPixel]
|
||||||
(img_color_btns[NUM_COLORS - 1 + NUM_COLORS], i, j,
|
(img_color_btns[COLOR_PICKER + NUM_COLORS], i, j,
|
||||||
SDL_MapRGB(img_color_btns[NUM_COLORS - 1 + NUM_COLORS]->format,
|
SDL_MapRGB(img_color_btns[COLOR_PICKER + NUM_COLORS]->format,
|
||||||
tmp_node->save_color.r, tmp_node->save_color.g, tmp_node->save_color.b));
|
tmp_node->save_color.r, tmp_node->save_color.g, tmp_node->save_color.b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_UnlockSurface(img_color_btns[NUM_COLORS - 1]);
|
SDL_UnlockSurface(img_color_btns[COLOR_PICKER]);
|
||||||
SDL_UnlockSurface(img_color_btns[NUM_COLORS - 1 + NUM_COLORS]);
|
SDL_UnlockSurface(img_color_btns[COLOR_PICKER + NUM_COLORS]);
|
||||||
|
|
||||||
draw_colors(COLORSEL_CLOBBER);
|
draw_colors(COLORSEL_CLOBBER);
|
||||||
render_brush(); /* FIXME: render_brush should be called at the start of Brush and Line tools? */
|
render_brush(); /* FIXME: render_brush should be called at the start of Brush and Line tools? */
|
||||||
|
|
@ -26660,7 +26707,7 @@ static void setup(void)
|
||||||
double gh = sRGB_to_linear_table[color_hexes[i][1]];
|
double gh = sRGB_to_linear_table[color_hexes[i][1]];
|
||||||
double bh = sRGB_to_linear_table[color_hexes[i][2]];
|
double bh = sRGB_to_linear_table[color_hexes[i][2]];
|
||||||
|
|
||||||
if (i == NUM_COLORS - 1)
|
if (i == COLOR_PICKER)
|
||||||
{
|
{
|
||||||
putpixels[img_color_btns[i]->format->BytesPerPixel]
|
putpixels[img_color_btns[i]->format->BytesPerPixel]
|
||||||
(img_color_btns[i], x, y,
|
(img_color_btns[i], x, y,
|
||||||
|
|
@ -26670,7 +26717,7 @@ static void setup(void)
|
||||||
getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y));
|
getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < NUM_COLORS - 1 || a == 255)
|
if (i < COLOR_PICKER || a == 255)
|
||||||
{
|
{
|
||||||
putpixels[img_color_btns[i]->format->BytesPerPixel]
|
putpixels[img_color_btns[i]->format->BytesPerPixel]
|
||||||
(img_color_btns[i], x, y,
|
(img_color_btns[i], x, y,
|
||||||
|
|
@ -26690,7 +26737,7 @@ static void setup(void)
|
||||||
for (i = 0; i < NUM_COLORS * 2; i++)
|
for (i = 0; i < NUM_COLORS * 2; i++)
|
||||||
{
|
{
|
||||||
SDL_UnlockSurface(img_color_btns[i]);
|
SDL_UnlockSurface(img_color_btns[i]);
|
||||||
if (i == NUM_COLORS - 2 || i == 2 * NUM_COLORS - 2)
|
if (i == COLOR_SELECTOR || i == 2 * COLOR_SELECTOR)
|
||||||
{
|
{
|
||||||
dest.x = (img_color_btns[i]->w - img_color_sel->w) / 2;
|
dest.x = (img_color_btns[i]->w - img_color_sel->w) / 2;
|
||||||
dest.y = (img_color_btns[i]->h - img_color_sel->h) / 2;
|
dest.y = (img_color_btns[i]->h - img_color_sel->h) / 2;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue