From c918280fb5de6e6256cfd9a438b3578c04e3afc2 Mon Sep 17 00:00:00 2001 From: Krow Savcik Date: Tue, 6 Feb 2024 22:56:21 +0200 Subject: feautre: added undo/redo buttons The change history is kept in a ring buffer of definite size 2000. --- src/canvas.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/canvas.h') diff --git a/src/canvas.h b/src/canvas.h index 104f130..bc96ab9 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -1,5 +1,10 @@ +/* Should include action.h before it */ + +/* TODO: move to config.h */ +#define HISTLENGTH 2000 + struct Layer { - unsigned int *pix; + unsigned int *pix; }; struct Canvas { @@ -10,8 +15,11 @@ struct Canvas { struct Layer **layers; int x, y; void *back, *pres, *half_pres; - void *temp_pix; + struct action_pixcol *temp_pix; + int temp_cnt; uint *pres_pix; + Action history[HISTLENGTH]; + int hist_s, hist_e, hist_i, hist_isend; }; typedef struct Layer Layer; @@ -38,3 +46,5 @@ void canvas_move_y(Canvas *, long int); void canvas_refresh(Canvas *); unsigned char canvas_save(Canvas *, const char *, short int); unsigned char canvas_export_png(Canvas *, const char *, void *); +void action_undo(Canvas *); +void action_redo(Canvas *); -- cgit v1.2.3