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/ui.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/ui.c') diff --git a/src/ui.c b/src/ui.c index ccc2de9..28a54f6 100644 --- a/src/ui.c +++ b/src/ui.c @@ -6,6 +6,7 @@ #include "ui.h" #include "cdraw.h" #include "types.h" +#include "action.h" #include "canvas.h" #include "tools.h" #include "debug.h" @@ -37,6 +38,8 @@ static const SDL_Rect ui_buttons_rect[] = { {56, 54, 28, 28}, /* Zoom out */ {84, 54, 28, 28}, /* Clown */ {56, 82, 28, 28}, /* Color Picker */ + {84, 82, 28, 28}, /* Undo */ + {84, 110, 28, 28}, /* Redo */ }; struct UIPanel { @@ -272,6 +275,12 @@ ui_mousel_down(int x, int y) break; case TOOL_TYPE_EMPTY: break; + case TOOL_TYPE_UNDO: + user_canvas_undo(NULL); + break; + case TOOL_TYPE_REDO: + user_canvas_redo(NULL); + break; default: tool_change(col); break; @@ -369,7 +378,7 @@ ui_focus_panel_change(int x, int y) if (main_ui->focus_panel != NULL) { switch (main_ui->focus_panel->type) { case UI_PANELTYPE_CANVAS: - is_drawing = 0; + canvas_mousel_up(cur_canvas); main_ui->focus_panel = u; ui_redraw_panel(UI_PANELTYPE_CANVAS); break; -- cgit v1.2.3