data_table: declarative cell renderers Phase 1 (Badge/Progress/Duration/Icon)

Adds TableInput.column_specs sidecar field enabling apps to declare Badge,
Progress, Duration and Icon renderers per column without writing ImGui inline.
Back-compat: apps without column_specs compile and behave identically.

- data_table_types.h: CellRenderer enum, BadgeRule, IconMapEntry, ColumnSpec types
- data_table.cpp: hex_to_imcolor helper, icon_name_to_glyph static map (~30 Tabler icons),
  draw_cell_custom dispatcher, integration in Stage-0 and Stage-N cell loops and draw_extra_panel
- Bump version 1.0.0 -> 1.1.0 with capability growth log
- cpp/tests/test_column_specs.cpp: 5 smoke/linker tests (back-compat + 4 renderer types)
- cpp/tests/CMakeLists.txt: register test_column_specs target linked against fn_table_viz
- types/core/{cell_renderer,badge_rule,icon_map_entry,column_spec}.md: registry type mds
- docs/capabilities/data_table_renderers.md: canonical doc with end-to-end examples
- docs/capabilities/INDEX.md: added data-table-renderers group

All tests green: test_column_specs 5/5, test_fn_table_viz_smoke 8/8,
tql_emit 41/41, tql_apply 88/88, Wave-1 tests 8/8.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 16:38:24 +02:00
parent 110791ff45
commit 7e2fb05144
11 changed files with 4924 additions and 5 deletions
+22
View File
@@ -0,0 +1,22 @@
---
name: BadgeRule
lang: cpp
domain: core
version: "1.0.0"
algebraic: product
definition: |
struct BadgeRule {
std::string value;
std::string color_hex;
std::string label;
};
description: "Regla de badge para CellRenderer::Badge. Mapea un valor exacto de celda a un color hex y un label visual opcional. Si label vacio, se usa value. Issue 0081-N."
tags: [tables, tql, types, cpp-tables]
uses_types: []
file_path: "cpp/functions/core/data_table_types.h"
---
## Notas
`color_hex` acepta `"#rrggbb"` o `"rrggbb"`. Sin alpha — siempre opaco.
`value` es exact match case-sensitive. Sin wildcards ni regex en Phase 1.
+24
View File
@@ -0,0 +1,24 @@
---
name: CellRenderer
lang: cpp
domain: core
version: "1.0.0"
algebraic: sum
definition: |
enum class CellRenderer : uint8_t {
Text = 0,
Badge = 1,
Progress = 2,
Duration = 3,
Icon = 4,
};
description: "Enum declarativo de modo de render por columna para data_table. Text = comportamiento actual (back-compat). Badge/Progress/Duration/Icon activan renderizado visual via TableInput.column_specs. Issue 0081-N."
tags: [tables, tql, types, cpp-tables]
uses_types: []
file_path: "cpp/functions/core/data_table_types.h"
---
## Notas
Sum type (enum). Valores futuros reservados: Button=5, TextInput=6, Custom=7.
El renderer se usa via `ColumnSpec.renderer` dentro de `TableInput.column_specs`.
+32
View File
@@ -0,0 +1,32 @@
---
name: ColumnSpec
lang: cpp
domain: core
version: "1.0.0"
algebraic: product
definition: |
struct ColumnSpec {
std::string id;
CellRenderer renderer = CellRenderer::Text;
std::vector<BadgeRule> badges;
bool progress_scale_100 = false;
std::string progress_color_hex;
float duration_warn_ms = 1000.0f;
float duration_error_ms = 5000.0f;
std::vector<IconMapEntry> icon_map;
};
description: "Spec declarativa de render para una columna de data_table. Indexada por posicion en TableInput.column_specs. Activa Badge/Progress/Duration/Icon sin escribir ImGui inline. Issue 0081-N."
tags: [tables, tql, types, cpp-tables]
uses_types:
- CellRenderer_cpp_core
- BadgeRule_cpp_core
- IconMapEntry_cpp_core
file_path: "cpp/functions/core/data_table_types.h"
---
## Notas
`id` es un identificador estable para uso futuro en TQL roundtrip (Phase 2).
En Phase 1 no se serializa — el caller construye `column_specs` cada frame.
Los campos de renderer no activo se ignoran: si `renderer=Badge`, solo se leen
`badges`; si `renderer=Duration`, solo `duration_warn_ms` y `duration_error_ms`.
+24
View File
@@ -0,0 +1,24 @@
---
name: IconMapEntry
lang: cpp
domain: core
version: "1.0.0"
algebraic: product
definition: |
struct IconMapEntry {
std::string value;
std::string icon_name;
std::string color_hex;
};
description: "Entrada de mapa de iconos para CellRenderer::Icon. Mapea un valor de celda a un nombre de icono Tabler (ej. 'TI_BOLT') y un color opcional. Issue 0081-N."
tags: [tables, tql, types, cpp-tables]
uses_types: []
file_path: "cpp/functions/core/data_table_types.h"
---
## Notas
`icon_name` debe coincidir con un macro de `cpp/functions/core/icons_tabler.h`.
Lookup estatico en `data_table.cpp` cubre ~30 iconos frecuentes. Si el nombre
no esta en la tabla, la celda se renderiza como texto plano.
`color_hex` vacio -> color de texto por defecto.