summaryrefslogtreecommitdiff
path: root/src/editor/toolview.cpp
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-02-25 06:07:38 +0100
committeraura <nw@moneybot.cc>2026-02-25 06:07:44 +0100
commit25da8e01a0499c273357cb2feb2825b53e86795b (patch)
tree0888d139edf274a59ab2561a655e8f5d4f0be185 /src/editor/toolview.cpp
parentd97e17b180257f3425574eb3ba4189d312eb590a (diff)
wip on toolview
Diffstat (limited to 'src/editor/toolview.cpp')
-rw-r--r--src/editor/toolview.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/editor/toolview.cpp b/src/editor/toolview.cpp
new file mode 100644
index 0000000..2853c48
--- /dev/null
+++ b/src/editor/toolview.cpp
@@ -0,0 +1,67 @@
+#include "editor.h"
+#include "../util/string.h"
+
+const U32 TOOLVIEW_TITLE_OFFSET = 15;
+
+void gui_editor_toolview_get_title( GUI_EDITOR_TOOLVIEW* view, char* out ) {
+ switch( editor->tool.type ) {
+ case EDITOR_TOOL_ENT: memcpy( out, "tool: entity", 12 ); break;
+ case EDITOR_TOOL_WALL: memcpy( out, "tool: wall", 10 ); break;
+ case EDITOR_TOOL_POLY: memcpy( out, "tool: polygon", 14 ); break;
+ case EDITOR_TOOL_SELECT: memcpy( out, "tool: select", 12 ); break;
+ case EDITOR_TOOL_SPRITE: memcpy( out, "tool: sprite", 12 ); break;
+ default: memcpy( out, "tool: none", 10 ); break;
+ }
+}
+
+void gui_editor_toolview_update( GUI_EDITOR_TOOLVIEW* view ) {
+
+}
+
+void gui_editor_toolview_draw_fn( void* ptr ) {
+ if( !editor->map ) return;
+
+ GUI_EDITOR_TOOLVIEW* view = (GUI_EDITOR_TOOLVIEW*)ptr;
+
+ I32 x = gui_relx( view );
+ I32 y = gui_rely( view );
+ I32 w = view->w;
+ I32 h = view->h;
+
+ STR<64> title{};
+ gui_editor_toolview_get_title( view, title );
+ gui_draw_str( x, y, ALIGN_L, FNT_JPN12, ui_clr.txt, title );
+ y += TOOLVIEW_TITLE_OFFSET;
+
+ CLR col = gui_is_fg_window( view )? ui_clr.border : ui_clr.border_inactive;
+ gui_draw_frect( x, y, w, h, col );
+ gui_draw_frect( x+1, y+1, w-2, h-2, ui_clr.bg_sec );
+
+ view->itemview->draw_fn( view->itemview );
+}
+
+GUI_EDITOR_TOOLVIEW* gui_editor_toolview( I32 x, I32 y, I32 w, I32 h ) {
+ if( !gui_check_target() ) return 0;
+
+ GUI_EDITOR_TOOLVIEW* view = new GUI_EDITOR_TOOLVIEW;
+ view->x = x;
+ view->y = y;
+ view->w = w;
+ view->h = h;
+ view->xbound = view->w;
+ view->ybound = view->h + TOOLVIEW_TITLE_OFFSET;
+ strcpy( view->name, "EDITOR_PROP_VIEW" );
+ view->draw_fn = gui_editor_toolview_draw_fn;
+ view->input_fn = gui_base_input_fn;
+
+ GUI_VIEW* parent = gui_get_view();
+ parent->children.push( view );
+ view->parent = parent;
+
+ gui_set_view( view );
+ view->itemview = gui_view( 0, TOOLVIEW_TITLE_OFFSET, w, h );
+
+ gui_set_view( parent );
+
+ return view;
+}