From fdc5e8760fb7ac0af8e7ebb98a2076db15e31082 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 10:15:01 +0100 Subject: giga refactor, fix ALL the leaks --- src/editor/editor_menubar.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/editor/editor_menubar.cpp') diff --git a/src/editor/editor_menubar.cpp b/src/editor/editor_menubar.cpp index b89d1c6..cfb12a3 100644 --- a/src/editor/editor_menubar.cpp +++ b/src/editor/editor_menubar.cpp @@ -66,7 +66,7 @@ void editor_raise_header_toolbar( GAME_EDITOR* e ) { parent->children.push( bar ); } -static void editor_contextmenu_set_item( +void editor_contextmenu_set_item( EDITOR_CONTEXTMENU_ITEM* item, const char* text, EDITOR_CONTEXTMENU_CALLBACK cb = 0, @@ -84,38 +84,38 @@ static void editor_contextmenu_set_item( item->enabled_cb = enabled_cb; } -static void editor_contextmenu_save_cb( void* ) { +void editor_contextmenu_save_cb( void* ) { if( editor ) editor_save_map( editor ); } -static void editor_contextmenu_undo_cb( void* ) { +void editor_contextmenu_undo_cb( void* ) { if( editor ) editor_undo( editor ); } -static void editor_contextmenu_redo_cb( void* ) { +void editor_contextmenu_redo_cb( void* ) { if( editor ) editor_redo( editor ); } -static void editor_contextmenu_set_view_mode_cb( void* data ) { +void editor_contextmenu_set_view_mode_cb( void* data ) { editor_set_view_mode( (I32)(I64)data ); } -static void editor_contextmenu_set_tool_cb( void* data ) { +void editor_contextmenu_set_tool_cb( void* data ) { editor_settool( (U8)(I64)data ); } -static U8 editor_contextmenu_undo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) { +U8 editor_contextmenu_undo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) { return editor && editor->undo_actions.size > 0; } -static U8 editor_contextmenu_redo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) { +U8 editor_contextmenu_redo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) { return editor && editor->redo_actions.size > 0; } -static void editor_toolbar_init_entries( GUI_EDITOR_TOOLBAR* bar ) { +void editor_toolbar_init_entries( GUI_EDITOR_TOOLBAR* bar ) { if( !bar ) return; @@ -146,7 +146,7 @@ static void editor_toolbar_init_entries( GUI_EDITOR_TOOLBAR* bar ) { editor_contextmenu_set_item( &bar->entries[3].items[4], "object", editor_contextmenu_set_tool_cb, (void*)(I64)EDITOR_TOOL_OBJECT ); } -static I32 editor_toolbar_root_width( const EDITOR_CONTEXTMENU_ITEM* entry ) { +I32 editor_toolbar_root_width( const EDITOR_CONTEXTMENU_ITEM* entry ) { if( !entry ) return 44; @@ -155,7 +155,7 @@ static I32 editor_toolbar_root_width( const EDITOR_CONTEXTMENU_ITEM* entry ) { return max( 44, text_w + 16 ); } -static void editor_toolbar_root_rect( GUI_EDITOR_TOOLBAR* bar, I32 idx, I32* rx, I32* ry, I32* rw, I32* rh ) { +void editor_toolbar_root_rect( GUI_EDITOR_TOOLBAR* bar, I32 idx, I32* rx, I32* ry, I32* rw, I32* rh ) { I32 x = gui_relx( bar ); I32 y = gui_rely( bar ); I32 cx = x + 8; @@ -172,11 +172,11 @@ struct EDITOR_TOOLBAR_HIT { I32 root{-1}; }; -static U8 editor_toolbar_pt_in_rect( I32 mx, I32 my, I32 x, I32 y, I32 w, I32 h ) { +U8 editor_toolbar_pt_in_rect( I32 mx, I32 my, I32 x, I32 y, I32 w, I32 h ) { return mx >= x && mx < x + w && my >= y && my < y + h; } -static EDITOR_TOOLBAR_HIT editor_toolbar_hit_test( GUI_EDITOR_TOOLBAR* bar, I32 mx, I32 my ) { +EDITOR_TOOLBAR_HIT editor_toolbar_hit_test( GUI_EDITOR_TOOLBAR* bar, I32 mx, I32 my ) { EDITOR_TOOLBAR_HIT hit{}; for( I32 i = 0; i < (I32)bar->entries.size; ++i ) { I32 x = 0, y = 0, w = 0, h = 0; @@ -190,7 +190,7 @@ static EDITOR_TOOLBAR_HIT editor_toolbar_hit_test( GUI_EDITOR_TOOLBAR* bar, I32 return hit; } -static void gui_editor_toolbar_draw_fn( void* ptr ) { +void gui_editor_toolbar_draw_fn( void* ptr ) { GUI_EDITOR_TOOLBAR* bar = (GUI_EDITOR_TOOLBAR*)ptr; I32 x = gui_relx( bar ); I32 y = gui_rely( bar ); @@ -229,7 +229,7 @@ static void gui_editor_toolbar_draw_fn( void* ptr ) { } } -static void gui_editor_toolbar_input_fn( void* ptr ) { +void gui_editor_toolbar_input_fn( void* ptr ) { GUI_EDITOR_TOOLBAR* bar = (GUI_EDITOR_TOOLBAR*)ptr; I32 mx = 0, my = 0; gui_cursor_pos( &mx, &my ); -- cgit v1.2.3 From f1882249843caa8bd931ecb76bb489615e079b10 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 12:51:06 +0100 Subject: editor work --- src/editor/editor_menubar.cpp | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'src/editor/editor_menubar.cpp') diff --git a/src/editor/editor_menubar.cpp b/src/editor/editor_menubar.cpp index cfb12a3..cef2650 100644 --- a/src/editor/editor_menubar.cpp +++ b/src/editor/editor_menubar.cpp @@ -66,24 +66,6 @@ void editor_raise_header_toolbar( GAME_EDITOR* e ) { parent->children.push( bar ); } -void editor_contextmenu_set_item( - EDITOR_CONTEXTMENU_ITEM* item, - const char* text, - EDITOR_CONTEXTMENU_CALLBACK cb = 0, - void* data = 0, - EDITOR_CONTEXTMENU_ENABLED_CALLBACK enabled_cb = 0 -) { - if( !item ) - return; - - item->items.clear(); - snprintf( item->text, sizeof( item->text ), "%s", text ? text : "" ); - item->cb = cb; - item->data = data; - item->enabled = 1; - item->enabled_cb = enabled_cb; -} - void editor_contextmenu_save_cb( void* ) { if( editor ) editor_save_map( editor ); @@ -107,11 +89,11 @@ void editor_contextmenu_set_tool_cb( void* data ) { editor_settool( (U8)(I64)data ); } -U8 editor_contextmenu_undo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) { +U8 editor_contextmenu_undo_enabled( EDITOR_CONTEXTMENU_ITEM* ) { return editor && editor->undo_actions.size > 0; } -U8 editor_contextmenu_redo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) { +U8 editor_contextmenu_redo_enabled( EDITOR_CONTEXTMENU_ITEM* ) { return editor && editor->redo_actions.size > 0; } -- cgit v1.2.3