// Playground tables: visor de la funcion table_view_cpp_viz tal cual existe // hoy en el registry. Iteraremos mejoras encima hasta promover una API v2 // que sustituya a los `ImGui::BeginTable` raw de las apps C++. #include "app_base.h" #include "imgui.h" #include "viz/table_view.h" #include "core/logger.h" #include #include #include namespace { struct Row { const char* name; const char* lang; const char* domain; const char* purity; const char* description; }; // Dataset de muestra inspirado en el registry. Filas reales-ish para // hacer obvias las limitaciones actuales (sin sort, sin filter, sin // per-cell render, alto fijo, etc.). const std::vector& sample_rows() { static const std::vector rows = { {"filter_slice", "go", "core", "pure", "Filtra slice con predicado"}, {"map_slice", "go", "core", "pure", "Aplica f a cada elemento"}, {"reduce_slice", "go", "core", "pure", "Fold con acumulador"}, {"sma", "py", "finance", "pure", "Simple moving average"}, {"ema", "py", "finance", "pure", "Exponential moving average"}, {"rsi", "py", "finance", "pure", "Relative strength index"}, {"table_view", "cpp", "viz", "pure", "Tabla ImGui actual del registry"}, {"line_plot", "cpp", "viz", "pure", "ImPlot line wrapper"}, {"scatter_plot", "cpp", "viz", "pure", "ImPlot scatter wrapper"}, {"bar_chart", "cpp", "viz", "pure", "ImPlot bar wrapper"}, {"heatmap", "cpp", "viz", "pure", "ImPlot heatmap wrapper"}, {"sqlite_open", "go", "infra", "impure", "Open SQLite con WAL+FK"}, {"http_json_response", "go", "infra", "impure", "Helper JSON response"}, {"http_parse_body", "go", "infra", "impure", "Parse JSON body"}, {"rsync_deploy", "bash", "infra", "impure", "rsync local -> remoto"}, {"systemd_install", "go", "infra", "impure", "Sube unit + enable + start"}, {"systemd_restart", "go", "infra", "impure", "Restart servicio remoto"}, {"jupyter_discover", "py", "notebook", "impure", "Descubre instancias Jupyter"}, {"jupyter_exec", "py", "notebook", "impure", "Ejecuta celda y vuelca output"}, {"docker_pull_image", "go", "infra", "impure", "docker pull con timeout"}, {"graph_force_layout", "cpp", "viz", "pure", "Force-directed CPU"}, {"graph_force_layout_gpu","cpp", "viz", "pure", "Force-directed GPU (compute)"}, {"sql_workbench", "cpp", "core", "impure", "Workbench SQL embebido"}, {"text_editor", "cpp", "core", "impure", "Editor de texto con highlighting"}, {"icon_font", "cpp", "core", "impure", "Carga tabler-icons.ttf"}, }; return rows; } // Aplanado row-major para alimentar table_view_cpp_viz (firma `const char* const*`). const char* const* flatten_cells(int& out_rows, int& out_cols) { static std::vector flat; static bool built = false; if (!built) { const auto& rows = sample_rows(); flat.reserve(rows.size() * 5); for (const auto& r : rows) { flat.push_back(r.name); flat.push_back(r.lang); flat.push_back(r.domain); flat.push_back(r.purity); flat.push_back(r.description); } built = true; } out_rows = static_cast(sample_rows().size()); out_cols = 5; return flat.data(); } } // namespace void render() { if (ImGui::Begin("Tables Playground - table_view actual")) { ImGui::TextWrapped( "Esta es la funcion `table_view_cpp_viz` del registry hoy. " "Capacidades: borders, sortable (solo indicador, no sort real), " "rowBg, resizable, scrollY (alto fijo 300px), reorderable. " "Sin filter, sin selection, sin per-cell render, sin export. " "Iteraremos mejoras encima de esto."); ImGui::Separator(); static const char* headers[] = {"name", "lang", "domain", "purity", "description"}; int rows = 0, cols = 0; const char* const* cells = flatten_cells(rows, cols); ImGui::Text("Filas: %d Columnas: %d", rows, cols); ImGui::Spacing(); table_view("##registry_sample", headers, cols, cells, rows); } ImGui::End(); } #ifndef FN_TEST_BUILD int main() { return fn::run_app({ .title = "Tables Playground", .width = 1280, .height = 800, .about = {.name = "tables_playground", .version = "0.1.0", .description = "Playground para iterar mejoras sobre table_view_cpp_viz antes de promover a registry y migrar apps C++."}, .log = {.file_path = "tables_playground.log", .level = static_cast(fn_log::Level::Info)} }, render); } #endif