]> git.lizzy.rs Git - nothing.git/blob - src/game/level/level_editor/undo_history.h
(#1010) define COLOR_PICKER_HEIGHT in terms of COLOR_SLIDER_HEIGHT
[nothing.git] / src / game / level / level_editor / undo_history.h
1 #ifndef UNDO_HISTORY_H_
2 #define UNDO_HISTORY_H_
3
4 #include "layer.h"
5
6 #define CONTEXT_SIZE 256
7
8 #define ASSERT_CONTEXT_SIZE(context)               \
9     trace_assert(sizeof(context) <= CONTEXT_SIZE)
10
11 typedef struct {
12     char data[CONTEXT_SIZE];
13 } Context;
14
15 typedef void (*RevertAction)(void *layer, Context context);
16
17 typedef struct {
18     void *layer;
19     Context context;
20     RevertAction revert;
21 } Action;
22
23 typedef struct UndoHistory UndoHistory;
24
25 UndoHistory *create_undo_history(void);
26 void destroy_undo_history(UndoHistory *undo_history);
27
28 void undo_history_push(UndoHistory *undo_history, Action action);
29 void undo_history_pop(UndoHistory *undo_history);
30
31 #endif  // UNDO_HISTORY_H_