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
+55
View File
@@ -1,6 +1,7 @@
// data_table_types — types compartidos del stack TQL (Table Query Language).
// Promovido al registry desde cpp/apps/primitives_gallery/playground/tables/.
// Ver issue 0081 + docs/TQL.md. Pure value types + enums.
// Issue 0081-N: CellRenderer / ColumnSpec / BadgeRule / IconMapEntry (v1.1.0).
#pragma once
#include <string>
@@ -126,7 +127,55 @@ enum class ViewMode {
// ----------------------------------------------------------------------------
enum class JoinStrategy { Left, Inner, Right, Full };
// ----------------------------------------------------------------------------
// CellRenderer: declarative rendering mode per column (issue 0081-N, v1.1.0).
// ----------------------------------------------------------------------------
enum class CellRenderer : uint8_t {
Text = 0, // default — current behavior
Badge = 1, // colored badge per-value
Progress = 2, // progress bar (0..1 or 0..100)
Duration = 3, // milliseconds with color gradient
Icon = 4, // icon lookup by value string
// Future (Phase 2-3): Button=5, TextInput=6, Custom=7. IDs reserved.
};
// BadgeRule: maps a cell value to a colored badge label.
struct BadgeRule {
std::string value; // exact match (case-sensitive)
std::string color_hex; // "#rrggbb" or "rrggbb"
std::string label; // optional visual override; "" -> use value as-is
};
// IconMapEntry: maps a cell value to a Tabler icon macro name + optional color.
struct IconMapEntry {
std::string value;
std::string icon_name; // e.g. "TI_CHECK", "TI_X" — resolved via static map
std::string color_hex; // optional; "" -> default text color
};
// ColumnSpec: rendering spec for one column. Indexed by column position.
struct ColumnSpec {
std::string id; // stable id, used in TQL (future)
CellRenderer renderer = CellRenderer::Text;
// Badge
std::vector<BadgeRule> badges;
// Progress: cell value is float 0..1 (or 0..100 if progress_scale_100 = true)
bool progress_scale_100 = false;
std::string progress_color_hex; // override bar color; "" -> ImPlot auto
// Duration: cell value in milliseconds (float); gradient green<warn<yellow<error<red
float duration_warn_ms = 1000.0f;
float duration_error_ms = 5000.0f;
// Icon
std::vector<IconMapEntry> icon_map;
};
// ----------------------------------------------------------------------------
// Tabla extra pasada al render() para joins. Owner externo (caller).
// ----------------------------------------------------------------------------
struct TableInput {
std::string name; // identificador estable (matchea Join.source)
std::vector<std::string> headers;
@@ -134,6 +183,12 @@ struct TableInput {
const char* const* cells = nullptr; // row-major, headers.size() cols x rows filas
int rows = 0;
int cols = 0;
// NEW (issue 0081-N, v1.1.0): optional declarative renderers per column.
// empty -> all columns use default Text rendering (back-compat preserved).
// If non-empty, size must equal cols (or be 0 for "no specs").
// column_specs are caller-managed; not persisted in TQL yet (Phase 2).
std::vector<ColumnSpec> column_specs;
};
// Join clause: une la tabla actual con `source` por las parejas `on`,