aboutsummaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
authorKrow Savcik <krow@savcik.xyz>2024-02-06 22:56:21 +0200
committerKrow Savcik <krow@savcik.xyz>2024-02-06 22:56:21 +0200
commitc918280fb5de6e6256cfd9a438b3578c04e3afc2 (patch)
treeba72e1464c487b61d4376647769c93cdbccf7a21 /src/ui.c
parent009a890482edfb2247da1d69b86f4d193699e3cb (diff)
feautre: added undo/redo buttons
The change history is kept in a ring buffer of definite size 2000.
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c11
1 files changed, 10 insertions, 1 deletions
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;