From 08cb8d6a585dd552b69a488d9db1be123f01467a Mon Sep 17 00:00:00 2001 From: tech kaczynski Date: Tue, 22 Sep 2026 22:38:57 +1000 Subject: initial commit. --- editor.h | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 editor.h (limited to 'editor.h') 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 -- cgit v1.2.3