api->retract_undo() added to Magic API; used by Filled Polygon

New API function which rolls back the Undo buffer (which is snapshotted
upon a mousedown event ahead of calling the Magic tool's `_click()`
function.)  Dangerous; use sparingly!

Filled Polygon uses this to prevent partially-created (aka unfinished
aka incomplete) polygons -- the preview lines and control points -- from
being recorded and wasting space in the Undo history, or reappearing
upon Redo.

TODO - Other tools (e.g., Clone) would certainly benefit from this.
TODO - Needs more testing to help identify any bugs/issues introduced
by this!
TODO - Magic API docs need updating.

This is probably a sufficient solution that will make
https://sourceforge.net/p/tuxpaint/feature-requests/246/,
'"Overlay" surface in Magic API', unnecessary.
This commit is contained in:
Bill Kendrick 2024-06-01 01:35:50 -07:00
parent 2e9f4b7f42
commit 01afb5846c
5 changed files with 63 additions and 20 deletions

View file

@ -6,7 +6,7 @@ Copyright (c) 2002-2024
Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/
2024.May.30 (0.9.33)
2024.June.1 (0.9.33)
* New Magic Tools:
----------------
* Dither & Dither (Keep Color): Replaces all or part of a drawing
@ -42,6 +42,12 @@ https://tuxpaint.org/
+ Idea from O'Hare The Rabbit
+ Coding by Bill Kendrick <bill@newbreedsoftware.com>
* Ability for Magic tools to retract an undo buffer snapshot
(`api->retract_undo()`).
+ Used by new Filled Polygon magic tool.
+ Note: `TP_MAGIC_API_VERSION` bumped to 0x0000000A.
+ Bill Kendrick <bill@newbreedsoftware.com>
* Improvements to Eraser tool:
----------------------------
* Transparent erasers