From b71a4d2987b87f91ca7b0b2ff620ac93e00d0e76 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Wed, 19 Jul 2023 00:49:16 -0700 Subject: [PATCH] Avoid stamp & eraser XOR garbage when using quick eraser (Click+[X]) --- docs/CHANGES.txt | 5 +++-- src/tuxpaint.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index e4972ea46..36b8c99e5 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -6,7 +6,7 @@ Copyright (c) 2002-2023 Various contributors (see below, and AUTHORS.txt) https://tuxpaint.org/ -2023.July.17 (0.9.31) +2023.July.19 (0.9.31) * New Magic Tools: ---------------- * Loops - Draw loop-the-loops. @@ -120,7 +120,8 @@ https://tuxpaint.org/ Bill Kendrick * Improved Eraser XOR outline when using Ctrl-Z & Ctrl-R - for Undo/Redo. + for Undo/Redo, and Eraser and Stamp XOR outlines when + using click+X for quick eraser access. Bill Kendrick * When specifying "datadir", Tux Paint's "New" dialog diff --git a/src/tuxpaint.c b/src/tuxpaint.c index d45ab65b2..3722c34c0 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - July 8, 2023 + June 14, 2002 - July 19, 2023 */ #include "platform.h" @@ -5186,7 +5186,9 @@ static void mainloop(void) else if (cur_tool == TOOL_STAMP) { if (stamp_tool_mode == STAMP_TOOL_MODE_ROTATE) + { stamp_xor(stamp_place_x, stamp_place_y); + } else if (stamp_xored) { stamp_xor(canvas->w / 2, canvas->h / 2); @@ -5265,7 +5267,24 @@ static void mainloop(void) (cur_tool != TOOL_STAMP || stamp_tool_mode == STAMP_TOOL_MODE_PLACE) && cur_tool != TOOL_TEXT && cur_tool != TOOL_LABEL) { + /* Jump into quick eraser loop */ do_quick_eraser(); + + /* Avoid XOR outlines from getting drawn + at our initial "click + [X]" position */ + if (cur_tool == TOOL_STAMP) + { + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); + } + else if (cur_tool == TOOL_ERASER) + { + int mx, my; + + SDL_GetMouseState(&mx, &my); + old_x = mx - r_canvas.x; + old_y = my - r_canvas.y; + maybe_redraw_eraser_xor(); + } } } else @@ -23924,16 +23943,26 @@ static void do_quick_eraser(void) int val_x, val_y, motioner; int valhat_x, valhat_y, hatmotioner; int done, old_eraser; + int mx, my; val_x = val_y = motioner = 0; valhat_x = valhat_y = hatmotioner = 0; + /* Redraw canvas to zap any Stamps or Eraser XOR outlines */ + update_canvas(0, 0, canvas->w, canvas->h); + /* Remember current eraser & switch to a suitable default */ old_eraser = cur_eraser; cur_eraser = (NUM_ERASER_SIZES * 2) - 2; /* 2nd-smallest circle */ + /* Snapshot the canvas, so we can undo */ rec_undo_buffer(); + /* Do an initial erase at the click location */ + SDL_GetMouseState(&mx, &my); + eraser_draw(mx - r_canvas.x, my - r_canvas.y, + mx - r_canvas.x, my - r_canvas.y); + done = 0; do {