#include "background_layer.h"
#include "undo_history.h"
-
BackgroundLayer create_background_layer(Color color)
{
BackgroundLayer layer = {
typedef struct {
BackgroundLayer *layer;
Color color;
-} UndoContext;
+} BackgroundUndoContext;
static
void background_undo_color(void *context, size_t context_size)
{
trace_assert(context);
- trace_assert(sizeof(UndoContext) == context_size);
+ trace_assert(sizeof(BackgroundUndoContext) == context_size);
- UndoContext *undo_context = context;
+ BackgroundUndoContext *undo_context = context;
BackgroundLayer *background_layer = undo_context->layer;
background_layer->color_picker = create_color_picker_from_rgba(undo_context->color);
}
if (selected && !color_picker_drag(&layer->color_picker)) {
- UndoContext context = {
+ BackgroundUndoContext context = {
.layer = layer,
.color = layer->prev_color
};
LABEL_LAYER_RECOLOR
} LabelLayerState;
-static int clipboard;
-static char clipboard_text[LABEL_LAYER_TEXT_MAX_SIZE];
-static Color clipboard_color;
+static int label_clipboard = 0;
+static char label_clipboard_text[LABEL_LAYER_TEXT_MAX_SIZE];
+static Color label_clipboard_color;
struct LabelLayer {
Lt *lt;
};
typedef enum {
- UNDO_ADD,
- UNDO_DELETE,
- UNDO_UPDATE,
- UNDO_SWAP
-} UndoType;
+ LABEL_UNDO_ADD,
+ LABEL_UNDO_DELETE,
+ LABEL_UNDO_UPDATE,
+ LABEL_UNDO_SWAP
+} LabelUndoType;
typedef struct {
- UndoType type;
+ LabelUndoType type;
LabelLayer *layer;
char id[LABEL_LAYER_ID_MAX_SIZE];
Vec2f position;
char text[LABEL_LAYER_TEXT_MAX_SIZE];
size_t index;
size_t index2;
-} UndoContext;
+} LabelUndoContext;
static
-UndoContext create_undo_swap_context(LabelLayer *label_layer,
+LabelUndoContext create_label_undo_swap_context(LabelLayer *label_layer,
size_t index, size_t index2)
{
trace_assert(label_layer);
trace_assert(index < dynarray_count(label_layer->positions));
trace_assert(index2 < dynarray_count(label_layer->positions));
- UndoContext undo_context;
- undo_context.type = UNDO_SWAP;
+ LabelUndoContext undo_context;
+ undo_context.type = LABEL_UNDO_SWAP;
undo_context.layer = label_layer;
undo_context.index = index;
undo_context.index2 = index2;
}
static
-UndoContext create_undo_context(LabelLayer *label_layer, UndoType type)
+LabelUndoContext create_label_undo_context(LabelLayer *label_layer, LabelUndoType type)
{
trace_assert(label_layer);
- trace_assert(type != UNDO_SWAP);
+ trace_assert(type != LABEL_UNDO_SWAP);
- UndoContext undo_context;
+ LabelUndoContext undo_context;
- size_t index = type == UNDO_ADD
+ size_t index = type == LABEL_UNDO_ADD
? dynarray_count(label_layer->positions) - 1
: (size_t)label_layer->selection;
void label_layer_undo(void *context, size_t context_size)
{
trace_assert(context);
- trace_assert(sizeof(UndoContext) == context_size);
+ trace_assert(sizeof(LabelUndoContext) == context_size);
- UndoContext *undo_context = context;
+ LabelUndoContext *undo_context = context;
LabelLayer *label_layer = undo_context->layer;
switch (undo_context->type) {
- case UNDO_ADD: {
+ case LABEL_UNDO_ADD: {
dynarray_delete_at(label_layer->ids, undo_context->index);
dynarray_delete_at(label_layer->positions, undo_context->index);
dynarray_delete_at(label_layer->colors, undo_context->index);
dynarray_delete_at(label_layer->texts, undo_context->index);
} break;
- case UNDO_DELETE: {
+ case LABEL_UNDO_DELETE: {
dynarray_insert_before(label_layer->ids, undo_context->index, &undo_context->id);
dynarray_insert_before(label_layer->positions, undo_context->index, &undo_context->position);
dynarray_insert_before(label_layer->colors, undo_context->index, &undo_context->color);
dynarray_insert_before(label_layer->texts, undo_context->index, &undo_context->text);
} break;
- case UNDO_UPDATE: {
+ case LABEL_UNDO_UPDATE: {
dynarray_replace_at(label_layer->ids, undo_context->index, &undo_context->id);
dynarray_replace_at(label_layer->positions, undo_context->index, &undo_context->position);
dynarray_replace_at(label_layer->colors, undo_context->index, &undo_context->color);
dynarray_replace_at(label_layer->texts, undo_context->index, &undo_context->text);
} break;
- case UNDO_SWAP: {
+ case LABEL_UNDO_SWAP: {
dynarray_swap(label_layer->ids, undo_context->index, undo_context->index2);
dynarray_swap(label_layer->positions, undo_context->index, undo_context->index2);
dynarray_swap(label_layer->colors, undo_context->index, undo_context->index2);
}
}
-#define UNDO_PUSH(HISTORY, CONTEXT) \
+#define LABEL_UNDO_PUSH(HISTORY, CONTEXT) \
do { \
- UndoContext context = (CONTEXT); \
+ LabelUndoContext context = (CONTEXT); \
undo_history_push( \
HISTORY, \
label_layer_undo, \
trace_assert(label_layer);
trace_assert(label_layer->selection >= 0);
- UNDO_PUSH(undo_history, create_undo_context(label_layer, UNDO_DELETE));
+ LABEL_UNDO_PUSH(undo_history, create_label_undo_context(label_layer, LABEL_UNDO_DELETE));
dynarray_delete_at(label_layer->ids, (size_t)label_layer->selection);
dynarray_delete_at(label_layer->positions, (size_t)label_layer->selection);
text,
min_size_t(LABEL_LAYER_ID_MAX_SIZE - 1, strlen(text)));
- UNDO_PUSH(undo_history, create_undo_context(label_layer, UNDO_ADD));
+ LABEL_UNDO_PUSH(undo_history, create_label_undo_context(label_layer, LABEL_UNDO_ADD));
return (int) n;
}
dynarray_swap(label_layer->colors, a, b);
dynarray_swap(label_layer->texts, a, b);
- UNDO_PUSH(undo_history, create_undo_swap_context(label_layer, a, b));
+ LABEL_UNDO_PUSH(undo_history, create_label_undo_swap_context(label_layer, a, b));
}
static
case SDLK_c: {
if ((event->key.keysym.mod & KMOD_LCTRL) && label_layer->selection >= 0) {
- clipboard = 1;
- dynarray_copy_to(label_layer->texts, clipboard_text, (size_t)label_layer->selection);
- dynarray_copy_to(label_layer->colors, &clipboard_color, (size_t)label_layer->selection);
+ label_clipboard = 1;
+ dynarray_copy_to(label_layer->texts, label_clipboard_text, (size_t)label_layer->selection);
+ dynarray_copy_to(label_layer->colors, &label_clipboard_color, (size_t)label_layer->selection);
}
} break;
case SDLK_v: {
- if ((event->key.keysym.mod & KMOD_LCTRL) && clipboard) {
+ if ((event->key.keysym.mod & KMOD_LCTRL) && label_clipboard) {
int x, y;
SDL_GetMouseState(&x, &y);
Vec2f position = camera_map_screen(camera, x, y);
label_layer_add_label(
label_layer,
position,
- clipboard_color,
- clipboard_text,
+ label_clipboard_color,
+ label_clipboard_text,
undo_history);
}
} break;
positions[label_layer->selection]));
if (distance > 1e-6) {
- UNDO_PUSH(undo_history, create_undo_context(label_layer, UNDO_UPDATE));
+ LABEL_UNDO_PUSH(undo_history, create_label_undo_context(label_layer, LABEL_UNDO_UPDATE));
dynarray_replace_at(
label_layer->positions,
case SDL_KEYDOWN: {
switch (event->key.keysym.sym) {
case SDLK_RETURN: {
- UNDO_PUSH(undo_history, create_undo_context(label_layer, UNDO_UPDATE));
+ LABEL_UNDO_PUSH(undo_history, create_label_undo_context(label_layer, LABEL_UNDO_UPDATE));
char *text =
(char*)dynarray_data(label_layer->texts) + label_layer->selection * LABEL_LAYER_TEXT_MAX_SIZE;
case SDL_KEYDOWN: {
switch (event->key.keysym.sym) {
case SDLK_RETURN: {
- UNDO_PUSH(undo_history, create_undo_context(label_layer, UNDO_UPDATE));
+ LABEL_UNDO_PUSH(undo_history, create_label_undo_context(label_layer, LABEL_UNDO_UPDATE));
char *id =
(char*)dynarray_data(label_layer->ids) + label_layer->selection * LABEL_LAYER_ID_MAX_SIZE;
color_picker_rgba(&label_layer->color_picker);
if (!color_picker_drag(&label_layer->color_picker)) {
- UNDO_PUSH(undo_history, create_undo_context(label_layer, UNDO_UPDATE));
+ LABEL_UNDO_PUSH(undo_history, create_label_undo_context(label_layer, LABEL_UNDO_UPDATE));
dynarray_replace_at(
label_layer->colors,
PlayerLayer *layer;
Vec2f position;
Color color;
-} UndoContext;
+} PlayerUndoContext;
static
-UndoContext player_layer_create_undo_context(PlayerLayer *player_layer)
+PlayerUndoContext player_layer_create_undo_context(PlayerLayer *player_layer)
{
- UndoContext context = {
+ PlayerUndoContext context = {
.layer = player_layer,
.position = player_layer->position,
.color = player_layer->prev_color
void player_layer_undo(void *context, size_t context_size)
{
trace_assert(context);
- trace_assert(sizeof(UndoContext) == context_size);
+ trace_assert(sizeof(PlayerUndoContext) == context_size);
- UndoContext *undo_context = context;
+ PlayerUndoContext *undo_context = context;
PlayerLayer *player_layer = undo_context->layer;
player_layer->position = undo_context->position;
}
if (selected && !color_picker_drag(&player_layer->color_picker)) {
- UndoContext context =
+ PlayerUndoContext context =
player_layer_create_undo_context(player_layer);
undo_history_push(
undo_history,
event->type == SDL_MOUSEBUTTONDOWN &&
event->button.button == SDL_BUTTON_LEFT) {
- UndoContext context =
+ PlayerUndoContext context =
player_layer_create_undo_context(player_layer);
undo_history_push(
#define POINT_LAYER_ID_TEXT_SIZE vec(2.0f, 2.0f)
#define POINT_LAYER_ID_TEXT_COLOR COLOR_BLACK
-static int clipboard = 0;
-static Color clipboard_color;
+static int point_clipboard = 0;
+static Color point_clipboard_color;
// TODO(#1140): PointLayer does not support snapping
};
typedef enum {
- UNDO_ADD,
- UNDO_DELETE,
- UNDO_UPDATE,
- UNDO_SWAP
-} UndoType;
+ POINT_UNDO_ADD,
+ POINT_UNDO_DELETE,
+ POINT_UNDO_UPDATE,
+ POINT_UNDO_SWAP
+} PointUndoType;
typedef struct {
- UndoType type;
+ PointUndoType type;
PointLayer *layer;
Vec2f position;
Color color;
char id[ID_MAX_SIZE];
size_t index;
size_t index2;
-} UndoContext;
+} PointUndoContext;
static
-UndoContext create_undo_swap_context(PointLayer *point_layer,
+PointUndoContext create_point_undo_swap_context(PointLayer *point_layer,
size_t index, size_t index2)
{
trace_assert(point_layer);
trace_assert(index < dynarray_count(point_layer->positions));
trace_assert(index2 < dynarray_count(point_layer->positions));
- UndoContext undo_context;
- undo_context.type = UNDO_SWAP;
+ PointUndoContext undo_context;
+ undo_context.type = POINT_UNDO_SWAP;
undo_context.layer = point_layer;
undo_context.index = index;
undo_context.index2 = index2;
}
static
-UndoContext create_undo_context(PointLayer *point_layer,
- UndoType type)
+PointUndoContext create_point_undo_context(PointLayer *point_layer,
+ PointUndoType type)
{
- trace_assert(type != UNDO_SWAP);
+ trace_assert(type != POINT_UNDO_SWAP);
- (void) create_undo_swap_context;
+ (void) create_point_undo_swap_context;
- UndoContext undo_context;
+ PointUndoContext undo_context;
size_t index =
- type == UNDO_ADD
+ type == POINT_UNDO_ADD
? dynarray_count(point_layer->positions) - 1
: (size_t) point_layer->selection;
void point_layer_undo(void *context, size_t context_size)
{
trace_assert(context);
- trace_assert(sizeof(UndoContext) == context_size);
+ trace_assert(sizeof(PointUndoContext) == context_size);
- UndoContext *undo_context = context;
+ PointUndoContext *undo_context = context;
PointLayer *point_layer = undo_context->layer;
switch (undo_context->type) {
- case UNDO_ADD: {
+ case POINT_UNDO_ADD: {
dynarray_pop(point_layer->positions, NULL);
dynarray_pop(point_layer->colors, NULL);
dynarray_pop(point_layer->ids, NULL);
point_layer->selection = -1;
} break;
- case UNDO_DELETE: {
+ case POINT_UNDO_DELETE: {
dynarray_insert_before(point_layer->positions, undo_context->index, &undo_context->position);
dynarray_insert_before(point_layer->colors, undo_context->index, &undo_context->color);
dynarray_insert_before(point_layer->ids, undo_context->index, &undo_context->id);
point_layer->selection = -1;
} break;
- case UNDO_UPDATE: {
+ case POINT_UNDO_UPDATE: {
dynarray_replace_at(point_layer->positions, undo_context->index, &undo_context->position);
dynarray_replace_at(point_layer->colors, undo_context->index, &undo_context->color);
dynarray_replace_at(point_layer->ids, undo_context->index, &undo_context->id);
} break;
- case UNDO_SWAP: {
+ case POINT_UNDO_SWAP: {
dynarray_swap(point_layer->positions, undo_context->index, undo_context->index2);
dynarray_swap(point_layer->colors, undo_context->index, undo_context->index2);
dynarray_swap(point_layer->ids, undo_context->index, undo_context->index2);
}
}
-#define UNDO_PUSH(HISTORY, CONTEXT) \
+#define POINT_UNDO_PUSH(HISTORY, CONTEXT) \
do { \
- UndoContext context = (CONTEXT); \
+ PointUndoContext context = (CONTEXT); \
undo_history_push( \
HISTORY, \
point_layer_undo, \
dynarray_push(point_layer->colors, &color);
dynarray_push(point_layer->ids, id);
- UNDO_PUSH(
+ POINT_UNDO_PUSH(
undo_history,
- create_undo_context(point_layer, UNDO_ADD));
+ create_point_undo_context(point_layer, POINT_UNDO_ADD));
return 0;
}
dynarray_swap(point_layer->colors, a, b);
dynarray_swap(point_layer->ids, a, b);
- UNDO_PUSH(
+ POINT_UNDO_PUSH(
undo_history,
- create_undo_swap_context(point_layer, a, b));
+ create_point_undo_swap_context(point_layer, a, b));
}
static
{
trace_assert(point_layer);
- UNDO_PUSH(
+ POINT_UNDO_PUSH(
undo_history,
- create_undo_context(
+ create_point_undo_context(
point_layer,
- UNDO_DELETE));
+ POINT_UNDO_DELETE));
dynarray_delete_at(point_layer->positions, i);
dynarray_delete_at(point_layer->colors, i);
case SDLK_c: {
if ((event->key.keysym.mod & KMOD_LCTRL) && point_layer->selection >= 0) {
- clipboard = 1;
- dynarray_copy_to(point_layer->colors, &clipboard_color, (size_t)point_layer->selection);
+ point_clipboard = 1;
+ dynarray_copy_to(point_layer->colors, &point_clipboard_color, (size_t)point_layer->selection);
}
} break;
case SDLK_v: {
- if ((event->key.keysym.mod & KMOD_LCTRL) && clipboard) {
+ if ((event->key.keysym.mod & KMOD_LCTRL) && point_clipboard) {
int x, y;
SDL_GetMouseState(&x, &y);
Vec2f position = camera_map_screen(camera, x, y);
point_layer_add_element(
point_layer,
position,
- clipboard_color,
+ point_clipboard_color,
undo_history);
}
} break;
case SDL_KEYDOWN: {
switch(event->key.keysym.sym) {
case SDLK_RETURN: {
- UNDO_PUSH(
+ POINT_UNDO_PUSH(
undo_history,
- create_undo_context(
+ create_point_undo_context(
point_layer,
- UNDO_UPDATE));
+ POINT_UNDO_UPDATE));
char *id = dynarray_pointer_at(point_layer->ids, (size_t) point_layer->selection);
const char *text = edit_field_as_text(point_layer->edit_field);
positions[point_layer->selection]));
if (distance > 1e-6) {
- UNDO_PUSH(
+ POINT_UNDO_PUSH(
undo_history,
- create_undo_context(
+ create_point_undo_context(
point_layer,
- UNDO_UPDATE));
+ POINT_UNDO_UPDATE));
dynarray_replace_at(
point_layer->positions,
point_layer->inter_color = color_picker_rgba(&point_layer->color_picker);
if (!color_picker_drag(&point_layer->color_picker)) {
- UNDO_PUSH(
+ POINT_UNDO_PUSH(
undo_history,
- create_undo_context(
+ create_point_undo_context(
point_layer,
- UNDO_UPDATE));
+ POINT_UNDO_UPDATE));
dynarray_replace_at(
point_layer->colors,
#define RECT_LAYER_GRID_ROWS 3
#define RECT_LAYER_GRID_COLUMNS 4
-static int clipboard = 0;
-static Rect clipboard_rect;
-static Color clipboard_color;
+static int rect_clipboard = 0;
+static Rect rect_clipboard_rect;
+static Color rect_clipboard_color;
static Cursor_Style resize_styles[1 << RECT_SIDE_N] = {
0, // [0]
};
typedef enum {
- UNDO_ADD,
- UNDO_DELETE,
- UNDO_UPDATE,
- UNDO_SWAP
-} UndoType;
+ RECT_UNDO_ADD,
+ RECT_UNDO_DELETE,
+ RECT_UNDO_UPDATE,
+ RECT_UNDO_SWAP
+} RectUndoType;
// Delete, Update
typedef struct {
- UndoType type;
+ RectUndoType type;
RectLayer *layer;
size_t index;
Rect rect;
// Add
typedef struct {
- UndoType type;
+ RectUndoType type;
RectLayer *layer;
size_t index;
} UndoAddContext;
// Swap
typedef struct {
- UndoType type;
+ RectUndoType type;
RectLayer *layer;
size_t index1;
size_t index2;
} UndoSwapContext;
typedef union {
- UndoType type;
+ RectUndoType type;
UndoAddContext add;
UndoElementContext element;
UndoSwapContext swap;
-} UndoContext;
+} RectUndoContext;
static
-UndoContext create_undo_add_context(RectLayer *layer, size_t index)
+RectUndoContext create_rect_undo_add_context(RectLayer *layer, size_t index)
{
trace_assert(layer);
trace_assert(index < dynarray_count(layer->rects));
- UndoContext undo_context;
- undo_context.add.type = UNDO_ADD;
+ RectUndoContext undo_context;
+ undo_context.add.type = RECT_UNDO_ADD;
undo_context.add.layer = layer;
undo_context.add.index = index;
return undo_context;
}
static
-UndoContext create_undo_element_context(RectLayer *layer)
+RectUndoContext create_rect_undo_element_context(RectLayer *layer)
{
trace_assert(layer);
size_t index = (size_t) layer->selection;
trace_assert(index < dynarray_count(layer->rects));
- UndoContext undo_context;
+ RectUndoContext undo_context;
undo_context.element.layer = layer;
undo_context.element.index = index;
dynarray_copy_to(layer->rects, &undo_context.element.rect, index);
}
static
-UndoContext create_undo_update_context(RectLayer *rect_layer)
+RectUndoContext create_rect_undo_update_context(RectLayer *rect_layer)
{
- UndoContext undo_context = create_undo_element_context(rect_layer);
- undo_context.type = UNDO_UPDATE;
+ RectUndoContext undo_context = create_rect_undo_element_context(rect_layer);
+ undo_context.type = RECT_UNDO_UPDATE;
return undo_context;
}
static
-UndoContext create_undo_delete_context(RectLayer *rect_layer)
+RectUndoContext create_rect_undo_delete_context(RectLayer *rect_layer)
{
- UndoContext undo_context = create_undo_element_context(rect_layer);
- undo_context.type = UNDO_DELETE;
+ RectUndoContext undo_context = create_rect_undo_element_context(rect_layer);
+ undo_context.type = RECT_UNDO_DELETE;
return undo_context;
}
static
-UndoContext create_undo_swap_context(RectLayer *rect_layer, size_t index1, size_t index2)
+RectUndoContext create_rect_undo_swap_context(RectLayer *rect_layer, size_t index1, size_t index2)
{
- UndoContext undo_context;
- undo_context.swap.type = UNDO_SWAP;
+ RectUndoContext undo_context;
+ undo_context.swap.type = RECT_UNDO_SWAP;
undo_context.swap.layer = rect_layer;
undo_context.swap.index1 = index1;
undo_context.swap.index2 = index2;
void rect_layer_undo(void *context, size_t context_size)
{
trace_assert(context);
- trace_assert(sizeof(UndoContext) == context_size);
+ trace_assert(sizeof(RectUndoContext) == context_size);
- UndoContext *undo_context = context;
+ RectUndoContext *undo_context = context;
switch (undo_context->type) {
- case UNDO_ADD: {
+ case RECT_UNDO_ADD: {
RectLayer *layer = undo_context->add.layer;
dynarray_delete_at(layer->rects, undo_context->add.index);
dynarray_delete_at(layer->colors, undo_context->add.index);
layer->selection = -1;
} break;
- case UNDO_DELETE: {
+ case RECT_UNDO_DELETE: {
RectLayer *layer = undo_context->element.layer;
dynarray_insert_before(layer->rects, undo_context->element.index, &undo_context->element.rect);
dynarray_insert_before(layer->colors, undo_context->element.index, &undo_context->element.color);
layer->selection = -1;
} break;
- case UNDO_UPDATE: {
+ case RECT_UNDO_UPDATE: {
RectLayer *layer = undo_context->element.layer;
dynarray_replace_at(layer->rects, undo_context->element.index, &undo_context->element.rect);
dynarray_replace_at(layer->colors, undo_context->element.index, &undo_context->element.color);
dynarray_replace_at(layer->actions, undo_context->element.index, &undo_context->element.action);
} break;
- case UNDO_SWAP: {
+ case RECT_UNDO_SWAP: {
RectLayer *layer = undo_context->element.layer;
dynarray_swap(layer->rects, undo_context->swap.index1, undo_context->swap.index2);
dynarray_swap(layer->colors, undo_context->swap.index1, undo_context->swap.index2);
}
}
-#define UNDO_PUSH(HISTORY, CONTEXT) \
+#define RECT_UNDO_PUSH(HISTORY, CONTEXT) \
do { \
- UndoContext context = (CONTEXT); \
+ RectUndoContext context = (CONTEXT); \
undo_history_push( \
HISTORY, \
rect_layer_undo, \
dynarray_push_empty(layer->actions);
- UNDO_PUSH(
+ RECT_UNDO_PUSH(
undo_history,
- create_undo_add_context(
+ create_rect_undo_add_context(
layer,
dynarray_count(layer->rects) - 1));
dynarray_swap(layer->ids, a, b);
dynarray_swap(layer->actions, a, b);
- UNDO_PUSH(undo_history, create_undo_swap_context(layer, a, b));
+ RECT_UNDO_PUSH(undo_history, create_rect_undo_swap_context(layer, a, b));
}
static int rect_layer_delete_rect_at(RectLayer *layer,
{
trace_assert(layer);
- UNDO_PUSH(undo_history, create_undo_delete_context(layer));
+ RECT_UNDO_PUSH(undo_history, create_rect_undo_delete_context(layer));
dynarray_delete_at(layer->rects, i);
dynarray_delete_at(layer->colors, i);
case SDLK_c: {
if ((event->key.keysym.mod & KMOD_LCTRL) && layer->selection >= 0) {
- clipboard = 1;
- dynarray_copy_to(layer->rects, &clipboard_rect, (size_t)layer->selection);
- dynarray_copy_to(layer->colors, &clipboard_color, (size_t)layer->selection);
+ rect_clipboard = 1;
+ dynarray_copy_to(layer->rects, &rect_clipboard_rect, (size_t)layer->selection);
+ dynarray_copy_to(layer->colors, &rect_clipboard_color, (size_t)layer->selection);
}
} break;
case SDLK_v: {
- if ((event->key.keysym.mod & KMOD_LCTRL) && clipboard) {
+ if ((event->key.keysym.mod & KMOD_LCTRL) && rect_clipboard) {
int x, y;
SDL_GetMouseState(&x, &y);
Vec2f position = camera_map_screen(camera, x, y);
rect_layer_add_rect(
layer,
rect(position.x, position.y,
- clipboard_rect.w, clipboard_rect.h),
- clipboard_color,
+ rect_clipboard_rect.w, rect_clipboard_rect.h),
+ rect_clipboard_color,
undo_history);
}
} break;
case SDL_MOUSEBUTTONUP: {
layer->state = RECT_LAYER_IDLE;
- UNDO_PUSH(undo_history, create_undo_update_context(layer));
+ RECT_UNDO_PUSH(undo_history, create_rect_undo_update_context(layer));
dynarray_replace_at(layer->rects, (size_t) layer->selection, &layer->inter_rect);
} break;
}
rect_position(rects[layer->selection])));
if (distance > 1e-6) {
- UNDO_PUSH(undo_history, create_undo_update_context(layer));
+ RECT_UNDO_PUSH(undo_history, create_rect_undo_update_context(layer));
dynarray_replace_at(layer->rects, (size_t) layer->selection, &layer->inter_rect);
}
} break;
case SDL_KEYDOWN: {
switch (event->key.keysym.sym) {
case SDLK_RETURN: {
- UNDO_PUSH(undo_history, create_undo_update_context(layer));
+ RECT_UNDO_PUSH(undo_history, create_rect_undo_update_context(layer));
char *id = dynarray_pointer_at(layer->ids, (size_t)layer->selection);
memset(id, 0, ENTITY_MAX_ID_SIZE);
layer->inter_color = color_picker_rgba(&layer->color_picker);
if (!color_picker_drag(&layer->color_picker)) {
- UNDO_PUSH(undo_history, create_undo_update_context(layer));
+ RECT_UNDO_PUSH(undo_history, create_rect_undo_update_context(layer));
dynarray_replace_at(layer->colors, (size_t) layer->selection, &layer->inter_color);
layer->state = RECT_LAYER_IDLE;
}