From ab63d5a7f87115cee0593b396b727d3b6726d266 Mon Sep 17 00:00:00 2001 From: reugenio Date: Thu, 18 Dec 2025 23:04:11 +0100 Subject: [PATCH] =?UTF-8?q?feat(AdvancedTable):=20Color=20selecci=C3=B3n?= =?UTF-8?q?=20seg=C3=BAn=20focus=20del=20panel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cambios: - Añadir selected_row_unfocus a TableColors - drawRow ahora recibe has_focus para elegir color - Con focus: usa selected_row (color accent) - Sin focus: usa selected_row_unfocus (gris sutil) BasicColors ahora acepta selected_row y selected_row_unfocus opcionales para permitir override desde PanelColorScheme. Esto permite que el usuario vea claramente: - Qué panel tiene focus (fila con color accent) - Qué fila está seleccionada en panel sin focus (gris) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/widgets/advanced_table/advanced_table.zig | 8 +++++--- src/widgets/advanced_table/types.zig | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/widgets/advanced_table/advanced_table.zig b/src/widgets/advanced_table/advanced_table.zig index 831fa2d..736a90a 100644 --- a/src/widgets/advanced_table/advanced_table.zig +++ b/src/widgets/advanced_table/advanced_table.zig @@ -143,7 +143,7 @@ pub fn advancedTableRect( config.row_height, ); - drawRow(ctx, row_bounds, table_state, table_schema, row_idx, state_col_w, colors, &result); + drawRow(ctx, row_bounds, table_state, table_schema, row_idx, state_col_w, colors, has_focus, &result); } // End clipping @@ -354,6 +354,7 @@ fn drawRow( row_idx: usize, state_col_w: u32, colors: *const TableColors, + has_focus: bool, result: *AdvancedTableResult, ) void { const config = table_schema.config; @@ -375,9 +376,10 @@ fn drawRow( .normal => row_bg, }; - // Selection overlay + // Selection overlay - color depende de si la tabla tiene focus if (is_selected_row) { - row_bg = blendColor(row_bg, colors.selected_row, 0.4); + const selection_color = if (has_focus) colors.selected_row else colors.selected_row_unfocus; + row_bg = blendColor(row_bg, selection_color, 0.5); } // Draw row background diff --git a/src/widgets/advanced_table/types.zig b/src/widgets/advanced_table/types.zig index 3191255..c5f1c2b 100644 --- a/src/widgets/advanced_table/types.zig +++ b/src/widgets/advanced_table/types.zig @@ -219,6 +219,10 @@ pub const BasicColors = struct { header_bg: ?Style.Color = null, row_alternate: ?Style.Color = null, border: ?Style.Color = null, + /// Color de fila seleccionada cuando tiene focus + selected_row: ?Style.Color = null, + /// Color de fila seleccionada cuando NO tiene focus + selected_row_unfocus: ?Style.Color = null, /// Convierte cualquier tipo con campos r,g,b (y opcionalmente a) a Style.Color. /// Útil para convertir desde otros tipos Color (ej: zcatconfig.Color). @@ -257,6 +261,7 @@ pub const TableColors = struct { // Selection selected_cell: Style.Color = Style.Color.rgb(66, 135, 245), selected_row: Style.Color = Style.Color.rgb(50, 80, 120), + selected_row_unfocus: Style.Color = Style.Color.rgb(60, 60, 70), // State colors state_modified: Style.Color = Style.Color.rgb(255, 255, 100), // Yellow @@ -318,9 +323,10 @@ pub const TableColors = struct { .row_alternate = opts.row_alternate orelse (if (is_dark) bg.lighten(5) else bg.darken(3)), .row_hover = if (is_dark) bg.lighten(15) else bg.darken(8), - // Selection - basada en acento + // Selection - basada en acento (o valores explícitos) .selected_cell = accent, - .selected_row = accent.darken(30), + .selected_row = opts.selected_row orelse accent.darken(30), + .selected_row_unfocus = opts.selected_row_unfocus orelse (if (is_dark) bg.lighten(25) else bg.darken(15)), // States - colores estándar universales .state_modified = Style.Color.rgb(255, 255, 100),