]> git.lizzy.rs Git - nothing.git/blob - src/game/level/level_editor/rect_layer.h
Try to fix MSVC build
[nothing.git] / src / game / level / level_editor / rect_layer.h
1 #ifndef RECT_LAYER_H_
2 #define RECT_LAYER_H_
3
4 #include "layer.h"
5 #include "game/level/action.h"
6 #include "ui/cursor.h"
7 #include "dynarray.h"
8 #include "color_picker.h"
9 #include "ui/edit_field.h"
10
11 typedef struct RectLayer RectLayer;
12
13 typedef enum {
14     RECT_LAYER_IDLE = 0,
15     RECT_LAYER_CREATE,
16     RECT_LAYER_RESIZE,
17     RECT_LAYER_MOVE,
18     RECT_LAYER_ID_RENAME,
19     RECT_LAYER_RECOLOR
20 } RectLayerState;
21
22 struct RectLayer {
23     RectLayerState state;
24     int resize_mask;
25     Dynarray ids;
26     Dynarray rects;
27     Dynarray colors;
28     Dynarray actions;
29     ColorPicker color_picker;
30     Vec2f create_begin;
31     Vec2f create_end;
32     int selection;
33     Vec2f move_anchor;          // The mouse offset from the left-top
34                                 // corner of the rect during moving it
35     Edit_field id_edit_field;
36     Color inter_color;
37     Rect inter_rect;
38     int id_name_counter;
39     const char *id_name_prefix;
40     Cursor *cursor;
41
42     int snapping_enabled;
43 };
44
45 LayerPtr rect_layer_as_layer(RectLayer *layer);
46 // NOTE: create_rect_layer and create_rect_layer_from_line_stream does
47 // not own id_name_prefix
48 RectLayer create_rect_layer(const char *id_name_prefix,
49                             Cursor *cursor);
50 RectLayer chop_rect_layer(Memory *memory,
51                           String *input,
52                           const char *id_name_prefix,
53                           Cursor *cursor);
54
55 static inline
56 void destroy_rect_layer(RectLayer layer)
57 {
58     free(layer.ids.data);
59     free(layer.rects.data);
60     free(layer.colors.data);
61     free(layer.actions.data);
62 }
63
64
65 int rect_layer_render(const RectLayer *layer, const Camera *camera, int active);
66 int rect_layer_event(RectLayer *layer,
67                      const SDL_Event *event,
68                      const Camera *camera,
69                      UndoHistory *undo_history);
70
71 int rect_layer_dump_stream(const RectLayer *layer, FILE *filedump);
72
73 size_t rect_layer_count(const RectLayer *layer);
74 const Rect *rect_layer_rects(const RectLayer *layer);
75 const Color *rect_layer_colors(const RectLayer *layer);
76 const char *rect_layer_ids(const RectLayer *layer);
77 const Action *rect_layer_actions(const RectLayer *layer);
78
79 #endif  // RECT_LAYER_H_