techkaczynski.dev / code

summaryrefslogtreecommitdiff
path: root/editor.h
diff options
context:
space:
mode:
authortech kaczynski <tk@techkaczynski.dev>2026-09-22 22:38:57 +1000
committertech kaczynski <tk@techkaczynski.dev>2026-09-22 22:38:57 +1000
commit08cb8d6a585dd552b69a488d9db1be123f01467a (patch)
tree77d50ce30bbc102b08486929ba654b5bef70af43 /editor.h
initial commit.
Diffstat (limited to 'editor.h')
-rw-r--r--editor.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/editor.h b/editor.h
new file mode 100644
index 0000000..f18cae0
--- /dev/null
+++ b/editor.h
@@ -0,0 +1,99 @@
+#ifndef EDITOR_H
+#define EDITOR_H
+
+#include "common.h"
+#include "ent.h"
+
+typedef enum {
+ ED_ACTION_TRANSFORM,
+ ED_ACTION_CREATE,
+ ED_ACTION_DELETE,
+ ED_ACTION_RENAME,
+} EditorActionTag;
+
+typedef union {
+ struct {
+ Vec3 pos, scale;
+ Quaternion rot;
+ } transform;
+
+ /* stored meaning 'stored entity', shared by creation/deletion */
+ struct {
+ Entity ent;
+ u64 parent, prev, next;
+ } stored;
+
+ struct {
+ char *name;
+ } rename;
+} EditorActionData;
+
+typedef struct {
+ EditorActionTag tag;
+ u32 item_cnt;
+ struct {
+ u64 pid;
+ EditorActionData before, after;
+ } *item;
+} EditorAction;
+
+typedef enum {
+ ED_PNL_NULL,
+ ED_PNL_LEFT,
+ ED_PNL_RIGHT,
+ ED_PNL_CENTER,
+ ED_PNL_CNT,
+} EditorPanelContainer;
+
+typedef enum {
+ ED_PNL_TYPE_SCENE,
+ ED_PNL_TYPE_PROPERTIES,
+ ED_PNL_TYPE_SPACE,
+ ED_PNL_TYPE_CMD,
+} EditorPanelType;
+
+typedef struct {
+ Vec3 sel_point;
+ Quaternion sel_rot;
+ int sel_cnt;
+
+ f32 grid_sz;
+
+ EditorPanelContainer focus;
+ bool focus_captured;
+ struct {
+ EditorPanelType type;
+ Rect bounds;
+ Vec2 scroll;
+ bool enabled;
+ } panel[ED_PNL_CNT];
+
+ EditorAction *history;
+
+ // history_save_csr UINT32_MAX means no saved position and marks file
+ // as having unsaved changes.
+ u32 history_cnt, history_cap, history_csr, history_save_csr;
+} EditorInfo;
+
+extern EditorInfo ed;
+
+void editor_init(void);
+void editor_exit(void);
+void editor_update(void);
+
+/* tools */
+void editor_select(void);
+void editor_move(void);
+void editor_rotate(void);
+
+/* draw */
+void editor_draw_ui(void);
+void editor_draw_3d(void);
+
+/* utils */
+f32 editor_label_w(cstr);
+void editor_rename_selected(cstr);
+
+
+
+#endif