From 5c4e9c8b140b14ba9671b8efcc47d71c6c4f2217 Mon Sep 17 00:00:00 2001 From: kasull Date: Tue, 3 Mar 2026 12:22:40 -0500 Subject: ui header/menu and add undo/redo for creation actions full-width toolbar/menubar layer move save into file menu and add edit menu actions for undo/redo menubar dropdown interaction modal update header/view-type labels and menu layout behavior creation-history tracking for walls and polygons undo (ctrl+z) and redo (ctrl+r) in 2d editor improve list/button visual states --- src/gui/list.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'src/gui/list.cpp') diff --git a/src/gui/list.cpp b/src/gui/list.cpp index 90f2f49..2feff47 100644 --- a/src/gui/list.cpp +++ b/src/gui/list.cpp @@ -10,18 +10,33 @@ void gui_list_draw_fn( void* ptr ) { I32 y = gui_rely( list ); gui_draw_str( x, y, ALIGN_L, FNT_JPN12, ui_clr.txt, list->name ); - y += LIST_TITLE_OFFSET; + I32 panel_y = y + LIST_TITLE_OFFSET; CLR col = gui_is_fg_window( list )? ui_clr.border : ui_clr.border_inactive; - gui_draw_frect( x, y, list->w, list->h, col ); - gui_draw_frect( x+1, y+1, list->w-2, list->h-2, ui_clr.bg_sec ); + gui_draw_frect( x, panel_y, list->w, list->h, col ); + gui_draw_frect( x + 1, panel_y + 1, list->w - 2, list->h - 2, ui_clr.bg_sec ); + + I32 txt_h = 12; + gui_draw_get_str_bounds( 0, &txt_h, FNT_JPN12, "ag" ); I32 yoff = 0; list->plist->each( fn( GUI_LIST_ENTRY* e ) { U8 selected = e->val == *list->pval; - CLR col = selected? ui_clr.txt : ui_clr.txt_inactive; + I32 row_x = x + 1; + I32 row_y = panel_y + 1 + yoff; + I32 row_w = list->w - 2; + if( row_w < 1 ) row_w = 1; + I32 row_h = LIST_ITEM_HEIGHT; + + if( selected ) { + CLR sel_bg = CLR::blend( ui_clr.border, ui_clr.bg, 0.70f ); + gui_draw_frect( row_x, row_y, row_w, row_h, sel_bg ); + } + + CLR col = selected ? ui_clr.txt : ui_clr.txt_inactive; + I32 txt_y = row_y + ( row_h - txt_h ) / 2; - gui_draw_str( x + 4, y + yoff + 6, ALIGN_L, FNT_JPN12, col, e->title ); + gui_draw_str( row_x + 3, txt_y, ALIGN_L, FNT_JPN12, col, e->title ); yoff += LIST_ITEM_HEIGHT; } ); } @@ -31,6 +46,7 @@ void gui_list_input_fn( void* ptr ) { I32 x = gui_relx( list ); I32 y = gui_rely( list ); + I32 panel_y = y + LIST_TITLE_OFFSET; I32 w = list->w; I32 h = list->h; @@ -38,12 +54,12 @@ void gui_list_input_fn( void* ptr ) { I32 mx, my; gui_cursor_pos( &mx, &my ); - U8 inbounds = mx >= x && mx <= x + w && my >= y && my <= y + h; + U8 inbounds = mx >= x && mx <= x + w && my >= panel_y && my <= panel_y + h; if( !inbounds ) return; - I32 diff = my - y; - I32 idx = diff / LIST_ITEM_HEIGHT - 1; + I32 diff = my - panel_y; + I32 idx = diff / LIST_ITEM_HEIGHT; if( idx >= list->plist->size ) idx = list->plist->size - 1; if( idx < 0 ) idx = 0; -- cgit v1.2.3