Files
fn_registry/cpp/functions/viz/data_table.h
T
egutierrez 97bd5ea056 data_table: Phase 2 — Button + events + tooltip + RightClick + TQL persist column_specs (issue 0081-O)
- CellRenderer::Button=5: renders SmallButton per cell; emits TableEvent::ButtonClick on click
- TableEventKind enum (ButtonClick/RowDoubleClick/RowRightClick/CellEdit) + TableEvent struct
- render() extended overload: adds events_out parameter (nullptr = back-compat, no events)
- RowDoubleClick and RowRightClick detection in raw table loop (stage 0)
- RowRightClick also detected in aggregated stage table (stage 1+)
- Tooltip per cell: tooltip_on_hover + tooltip fields on ColumnSpec; "auto" = show cell value
- State::aux_column_specs: TQL-persisted column specs sidecar per table
- tql_emit: serializes aux_column_specs[0] as column_specs block (badge/progress/duration/icon/button/tooltip)
- tql_apply: parses column_specs block back into state.aux_column_specs[0]
- render() merges aux_column_specs into TableInput when caller passes empty column_specs
- test_column_specs: 5->8 tests (Button struct, tooltip fields, both render() signatures link)
- tql_emit_test: 3 new tests (column_specs badge/button/tooltip emit) — 52 passed
- tql_apply_test: 3 new tests (column_specs badge/button/tooltip roundtrip) — 106 passed
- Back-compat: existing apps (graph_explorer, registry_dashboard) unchanged
- Version bump: data_table v1.1.0 -> v1.2.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 16:59:26 +02:00

59 lines
2.5 KiB
C++

#pragma once
// data_table — render UI completa de tabla TQL.
// Entry-point publica del stack data_table del registry.
// Issue 0081-H. Promovido desde cpp/apps/primitives_gallery/playground/tables/data_table.h
// Phase 2 (issue 0081-O, v1.2.0): Button renderer + event sink + tooltip + RightClick.
//
// Uso basico (back-compat, sin events):
// data_table::State st; // persistir entre frames
// ImGui::Begin("Window"); ImGui::BeginChild("tbl", {-1,-1});
// data_table::render("my_table", {table1, table2}, st);
// ImGui::EndChild(); ImGui::End();
//
// Uso con events (Phase 2):
// std::vector<data_table::TableEvent> events;
// data_table::render("my_table", {table1, table2}, st, &events);
// for (auto& ev : events) {
// if (ev.kind == data_table::TableEventKind::ButtonClick &&
// ev.action_id == "cancel") { ... }
// }
//
// Requiere ImGui context + ImPlot context activos.
// Namespace identico al playground para facilitar migracion (solo cambiar include path).
#include "core/data_table_types.h"
#include <vector>
namespace data_table {
// render — Render barra-de-chips + tabla + panels de visualizacion.
// Mutates `st` en respuesta a la interaccion del usuario.
//
// `id` — ID unico de ImGui para esta instancia (ej. "##my_table").
// `tables` — lista de TableInput. tables[0] es la main por defecto;
// si State.main_source no-vacio se usa por nombre.
// Tablas extra se exponen como joinables en la UI.
// `st` — estado mutable. Debe persistir entre frames (no stack-local).
// `events_out` — if non-null, populated with UI events (ButtonClick,
// RowDoubleClick, RowRightClick) fired this frame. The caller
// clears/reads the vector after each render call.
// Pass nullptr to disable event collection (back-compat).
// `show_chrome` — si false, oculta la barra de chips + breadcrumb por defecto.
// El usuario puede reactivarla via el boton "Show UI".
void render(const char* id,
const std::vector<TableInput>& tables,
State& st,
std::vector<TableEvent>* events_out,
bool show_chrome = true);
// Overload for back-compat: same as render(..., nullptr, show_chrome).
inline void render(const char* id,
const std::vector<TableInput>& tables,
State& st,
bool show_chrome = true)
{
render(id, tables, st, nullptr, show_chrome);
}
} // namespace data_table