Zoom/Perspective: Support background color changes
When in the middle of adjusting a drawing with Zoom or Perspective, you could change the color. However, the background would not relfect this until you further adjusted the zoom/perspective. Now, a color change causes the background to update immediately. This involved updating the Tux Paint Magic API to send more arguments to each Magic tool's "XYZ_set_color()" function, which means a bump in the API version. (Forthcoming, all other Magic tools will have their set_color() functions updated.)
This commit is contained in:
parent
5e829819aa
commit
34de8311db
4 changed files with 69 additions and 31 deletions
4
Makefile
4
Makefile
|
|
@ -4,7 +4,7 @@
|
||||||
# Various contributors (see AUTHORS.txt)
|
# Various contributors (see AUTHORS.txt)
|
||||||
# https://tuxpaint.org/
|
# https://tuxpaint.org/
|
||||||
|
|
||||||
# June 14, 2002 - January 10, 2023
|
# June 14, 2002 - January 25, 2023
|
||||||
|
|
||||||
|
|
||||||
# The version number, for release:
|
# The version number, for release:
|
||||||
|
|
@ -16,7 +16,7 @@ ifdef SOURCE_DATE_EPOCH
|
||||||
else
|
else
|
||||||
VER_DATE=$(shell date "+%Y-%m-%d")
|
VER_DATE=$(shell date "+%Y-%m-%d")
|
||||||
endif
|
endif
|
||||||
MAGIC_API_VERSION:=0x00000006
|
MAGIC_API_VERSION:=0x00000007
|
||||||
|
|
||||||
# Need to know the OS
|
# Need to know the OS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ https://tuxpaint.org/
|
||||||
* Better performance from "Rush" (by using SDL_gfx rotozoom)
|
* Better performance from "Rush" (by using SDL_gfx rotozoom)
|
||||||
Pere Pujal i Carabantes <perepujal@gmail.com>
|
Pere Pujal i Carabantes <perepujal@gmail.com>
|
||||||
|
|
||||||
|
* "Zoom" and "Perspective" background colors change
|
||||||
|
immediately when you select new colors.
|
||||||
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
* Other Improvements:
|
* Other Improvements:
|
||||||
-------------------
|
-------------------
|
||||||
* A keyboard shortcut is now available for quickly accessing
|
* A keyboard shortcut is now available for quickly accessing
|
||||||
|
|
@ -73,6 +77,11 @@ https://tuxpaint.org/
|
||||||
* Changed default UI font from Bitstream Vera to DejaVu Sans.
|
* Changed default UI font from Bitstream Vera to DejaVu Sans.
|
||||||
h/t Mark Kim <markuskimius@gmail.com>
|
h/t Mark Kim <markuskimius@gmail.com>
|
||||||
|
|
||||||
|
* Update Tux Paint Magic API so `set_color()` functions can
|
||||||
|
alter the canvas. (Utilized by "Zoom" and "Perspective", so far.)
|
||||||
|
Note: Bumps `TP_MAGIC_API_VERSION` to 0x00000007.
|
||||||
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
* Bug Fixes:
|
* Bug Fixes:
|
||||||
----------
|
----------
|
||||||
* Always creating 24-bit canvases, in an attempt to avoid blending
|
* Always creating 24-bit canvases, in an attempt to avoid blending
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
Last updated: January 25, 2023
|
Last updated: January 25, 2023
|
||||||
$Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -77,7 +76,8 @@ void perspective_release(magic_api * api, int which,
|
||||||
|
|
||||||
void perspective_shutdown(magic_api * api);
|
void perspective_shutdown(magic_api * api);
|
||||||
|
|
||||||
void perspective_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
|
void perspective_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
|
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||||
|
|
||||||
int perspective_requires_colors(magic_api * api, int which);
|
int perspective_requires_colors(magic_api * api, int which);
|
||||||
|
|
||||||
|
|
@ -109,6 +109,7 @@ int corner;
|
||||||
int dash;
|
int dash;
|
||||||
|
|
||||||
int click_x, click_y;
|
int click_x, click_y;
|
||||||
|
int latest_x, latest_y;
|
||||||
int new_w, new_h, old_h, sound_h;
|
int new_w, new_h, old_h, sound_h;
|
||||||
|
|
||||||
int perspective_average_r, perspective_average_g, perspective_average_b,
|
int perspective_average_r, perspective_average_g, perspective_average_b,
|
||||||
|
|
@ -251,6 +252,9 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
int oy ATTRIBUTE_UNUSED, int x, int y,
|
int oy ATTRIBUTE_UNUSED, int x, int y,
|
||||||
SDL_Rect * update_rect)
|
SDL_Rect * update_rect)
|
||||||
{
|
{
|
||||||
|
latest_x = x;
|
||||||
|
latest_y = y;
|
||||||
|
|
||||||
switch (which)
|
switch (which)
|
||||||
{
|
{
|
||||||
case TOOL_PERSPECTIVE:
|
case TOOL_PERSPECTIVE:
|
||||||
|
|
@ -376,6 +380,8 @@ void perspective_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||||
{
|
{
|
||||||
click_x = x;
|
click_x = x;
|
||||||
click_y = y;
|
click_y = y;
|
||||||
|
latest_x = x;
|
||||||
|
latest_y = y;
|
||||||
|
|
||||||
switch (which)
|
switch (which)
|
||||||
{
|
{
|
||||||
|
|
@ -776,16 +782,15 @@ void perspective_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the color from Tux Paint:
|
// Record the color from Tux Paint:
|
||||||
void perspective_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r, Uint8 g,
|
void perspective_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
Uint8 b)
|
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect)
|
||||||
{
|
{
|
||||||
if (r != perspective_r || g != perspective_g || b != perspective_b) {
|
if (r != perspective_r || g != perspective_g || b != perspective_b) {
|
||||||
perspective_r = r;
|
perspective_r = r;
|
||||||
perspective_g = g;
|
perspective_g = g;
|
||||||
perspective_b = b;
|
perspective_b = b;
|
||||||
|
|
||||||
/* FIXME: The API call to MAGIC_color() should allow us to update the canvas! */
|
perspective_release(api, which, canvas, last, latest_x, latest_y, update_rect);
|
||||||
// perspective_drag(api, which, canvas, last, click_x, click_y, click_x, click_y, update_rect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
June 14, 2002 - January 23, 2023
|
June 14, 2002 - January 25, 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
@ -1537,9 +1537,9 @@ typedef struct magic_funcs_s
|
||||||
char *(*get_description)(magic_api *, int, int);
|
char *(*get_description)(magic_api *, int, int);
|
||||||
int (*requires_colors)(magic_api *, int);
|
int (*requires_colors)(magic_api *, int);
|
||||||
int (*modes)(magic_api *, int);
|
int (*modes)(magic_api *, int);
|
||||||
void (*set_color)(magic_api *, Uint8, Uint8, Uint8);
|
void (*set_color)(magic_api *, int, SDL_Surface *, SDL_Surface *, Uint8, Uint8, Uint8, SDL_Rect *);
|
||||||
int (*init)(magic_api *);
|
int (*init)(magic_api *);
|
||||||
Uint32(*api_version) (void);
|
Uint32(*api_version) (void);
|
||||||
void (*shutdown)(magic_api *);
|
void (*shutdown)(magic_api *);
|
||||||
void (*click)(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int,
|
void (*click)(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int,
|
||||||
SDL_Rect *);
|
SDL_Rect *);
|
||||||
|
|
@ -2215,6 +2215,7 @@ static void draw_color_mix_undo_redo(void);
|
||||||
static void render_color_button(int the_color, SDL_Surface * decoration,
|
static void render_color_button(int the_color, SDL_Surface * decoration,
|
||||||
SDL_Surface * icon);
|
SDL_Surface * icon);
|
||||||
static void handle_color_changed(void);
|
static void handle_color_changed(void);
|
||||||
|
static void magic_set_color(void);
|
||||||
|
|
||||||
static void do_quick_eraser(void);
|
static void do_quick_eraser(void);
|
||||||
|
|
||||||
|
|
@ -3795,10 +3796,7 @@ static void mainloop(void)
|
||||||
draw_colors(magics[magic_group][cur_thing].colors);
|
draw_colors(magics[magic_group][cur_thing].colors);
|
||||||
|
|
||||||
if (magics[magic_group][cur_thing].colors)
|
if (magics[magic_group][cur_thing].colors)
|
||||||
magic_funcs[magics[magic_group][cur_thing].handle_idx].
|
magic_set_color();
|
||||||
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_ERASER)
|
else if (cur_tool == TOOL_ERASER)
|
||||||
{
|
{
|
||||||
|
|
@ -4471,10 +4469,7 @@ static void mainloop(void)
|
||||||
draw_colors(magics[magic_group][cur_thing].colors);
|
draw_colors(magics[magic_group][cur_thing].colors);
|
||||||
|
|
||||||
if (magics[magic_group][cur_thing].colors)
|
if (magics[magic_group][cur_thing].colors)
|
||||||
magic_funcs[magics[magic_group][cur_thing].handle_idx].
|
magic_set_color();
|
||||||
set_color(magic_api_struct, color_hexes[cur_color][0],
|
|
||||||
color_hexes[cur_color][1],
|
|
||||||
color_hexes[cur_color][2]);
|
|
||||||
|
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
|
|
||||||
|
|
@ -5239,10 +5234,7 @@ static void mainloop(void)
|
||||||
draw_colors(magics[grp][cur].colors);
|
draw_colors(magics[grp][cur].colors);
|
||||||
|
|
||||||
if (magics[grp][cur].colors)
|
if (magics[grp][cur].colors)
|
||||||
magic_funcs[magics[grp][cur].handle_idx].
|
magic_set_color();
|
||||||
set_color(magic_api_struct, color_hexes[cur_color][0],
|
|
||||||
color_hexes[cur_color][1],
|
|
||||||
color_hexes[cur_color][2]);
|
|
||||||
|
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
}
|
}
|
||||||
|
|
@ -26499,15 +26491,47 @@ static void handle_color_changed(void)
|
||||||
{
|
{
|
||||||
render_brush();
|
render_brush();
|
||||||
|
|
||||||
|
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) {
|
||||||
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
|
||||||
do_render_cur_text(0);
|
do_render_cur_text(0);
|
||||||
else if (cur_tool == TOOL_MAGIC)
|
} else if (cur_tool == TOOL_MAGIC) {
|
||||||
magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].
|
magic_set_color();
|
||||||
set_color(magic_api_struct, color_hexes[cur_color][0],
|
} else if (cur_tool == TOOL_STAMP) {
|
||||||
color_hexes[cur_color][1], color_hexes[cur_color][2]);
|
|
||||||
else if (cur_tool == TOOL_STAMP)
|
|
||||||
clear_cached_stamp();
|
clear_cached_stamp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void magic_set_color(void) {
|
||||||
|
int undo_ctr;
|
||||||
|
SDL_Surface *last;
|
||||||
|
SDL_Rect update_rect;
|
||||||
|
|
||||||
|
update_rect.x = 0;
|
||||||
|
update_rect.y = 0;
|
||||||
|
update_rect.w = 0;
|
||||||
|
update_rect.h = 0;
|
||||||
|
|
||||||
|
if (cur_undo > 0)
|
||||||
|
undo_ctr = cur_undo - 1;
|
||||||
|
else
|
||||||
|
undo_ctr = NUM_UNDO_BUFS - 1;
|
||||||
|
|
||||||
|
last = undo_bufs[undo_ctr];
|
||||||
|
|
||||||
|
magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].
|
||||||
|
set_color(magic_api_struct,
|
||||||
|
magics[magic_group][cur_magic[magic_group]].idx,
|
||||||
|
canvas,
|
||||||
|
last,
|
||||||
|
color_hexes[cur_color][0],
|
||||||
|
color_hexes[cur_color][1],
|
||||||
|
color_hexes[cur_color][2],
|
||||||
|
&update_rect);
|
||||||
|
|
||||||
|
if (update_rect.w > 0 && update_rect.h > 0) {
|
||||||
|
update_canvas(update_rect.x, update_rect.y,
|
||||||
|
update_rect.x + update_rect.w,
|
||||||
|
update_rect.y + update_rect.h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30043,7 +30067,7 @@ static void setup(void)
|
||||||
for (i = 0; i < num_displays; i++) {
|
for (i = 0; i < num_displays; i++) {
|
||||||
res = SDL_GetCurrentDisplayMode(i, &mode);
|
res = SDL_GetCurrentDisplayMode(i, &mode);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
fprintf(stderr, "Warning: SDL_GetCurrentDisplayMode() on display %d %d failed: %s\n", i, SDL_GetError());
|
fprintf(stderr, "Warning: SDL_GetCurrentDisplayMode() on display %d failed: %s\n", i, SDL_GetError());
|
||||||
} else {
|
} else {
|
||||||
if (mode.w >= WINDOW_WIDTH && mode.h >= WINDOW_HEIGHT) {
|
if (mode.w >= WINDOW_WIDTH && mode.h >= WINDOW_HEIGHT) {
|
||||||
/* Found a display capable of the chosen window size */
|
/* Found a display capable of the chosen window size */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue