feat(table-node): DuckDB foundation + render colapsado (issue 0010)
- tableview.{h,cpp}: capa C sobre DuckDB v1.1.3.
* tableview_smoke_test (SELECT 42).
* tableview_count (con sql_filter opcional).
* tableview_page (LEFT JOIN sobre ops.entities via ATTACH para flag promoted).
* tableview_create (inserta entidad type_ref='Table' con metadata pointer).
* tableview_refresh_counts (lee Table entities, count cada DuckDB y cachea
por user_data hash).
* tableview_resolve_path (rel a dirname(ops_db) o absoluto).
- AppState::table_node_counts cache, refrescado tras load_input y mutaciones.
- views_table_overlay: rectangulo redondeado overlay ("Table N") encima
de cada nodo type_ref='Table'. Sigue camara via cam_x/cam_y/zoom.
- main.cpp:
* --test-duckdb <path> smoke (SELECT 42).
* --test-tableview <path> bulk test (1M rows count + page offset).
* Refresh de counts tras load + reload_after_mutation.
* Llamada a views_table_overlay despues de graph_labels_draw.
- CMakeLists.txt: link DuckDB::DuckDB + duckdb_copy_runtime.
Smoke tests:
- 1M rows count + page(offset=500k, limit=10) en 0.65 s end-to-end.
- Operations.db con un nodo Table apuntando a duckdb 1M filas: refresh
reporta correctamente "1 tables, 1000000 total rows".
This commit is contained in:
@@ -1599,6 +1599,71 @@ void views_table(AppState& app) {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Table node overlay (issue 0010)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void views_table_overlay(AppState& app) {
|
||||
if (!app.graph || !app.viewport) return;
|
||||
GraphData& g = *app.graph;
|
||||
if (g.type_count == 0) return;
|
||||
|
||||
const ImVec2 wmin = ImGui::GetItemRectMin();
|
||||
const ImVec2 wmax = ImGui::GetItemRectMax();
|
||||
const float cx = (wmin.x + wmax.x) * 0.5f;
|
||||
const float cy = (wmin.y + wmax.y) * 0.5f;
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
if (!dl) return;
|
||||
ImFont* font = ImGui::GetFont();
|
||||
|
||||
for (int i = 0; i < g.node_count; ++i) {
|
||||
const GraphNode& n = g.nodes[i];
|
||||
if (!(n.flags & NF_VISIBLE)) continue;
|
||||
if (n.type_id >= (uint16_t)g.type_count) continue;
|
||||
const EntityType& t = g.types[n.type_id];
|
||||
if (!t.name || std::strcmp(t.name, "Table") != 0) continue;
|
||||
|
||||
const float vx = (n.x - app.viewport->cam_x) * app.viewport->zoom + cx;
|
||||
const float vy = (n.y - app.viewport->cam_y) * app.viewport->zoom + cy;
|
||||
if (vx < wmin.x - 200 || vx > wmax.x + 200) continue;
|
||||
if (vy < wmin.y - 100 || vy > wmax.y + 100) continue;
|
||||
|
||||
int64_t count = -1;
|
||||
auto it = app.table_node_counts.find(n.user_data);
|
||||
if (it != app.table_node_counts.end()) count = it->second;
|
||||
|
||||
char buf[96];
|
||||
if (count >= 0) std::snprintf(buf, sizeof(buf), TI_TABLE " Table %lld", (long long)count);
|
||||
else std::snprintf(buf, sizeof(buf), TI_TABLE " Table");
|
||||
|
||||
const float font_size = 13.0f;
|
||||
ImVec2 ts = font ? font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, buf)
|
||||
: ImVec2(60.0f, 14.0f);
|
||||
const float pad_x = 10.0f, pad_y = 6.0f;
|
||||
const float w = std::max(96.0f, ts.x + pad_x * 2.0f);
|
||||
const float h = ts.y + pad_y * 2.0f;
|
||||
ImVec2 a(vx - w * 0.5f, vy - h * 0.5f);
|
||||
ImVec2 b(vx + w * 0.5f, vy + h * 0.5f);
|
||||
|
||||
// Sombra ligera
|
||||
dl->AddRectFilled(ImVec2(a.x + 1, a.y + 2), ImVec2(b.x + 1, b.y + 2),
|
||||
IM_COL32(0, 0, 0, 80), 6.0f);
|
||||
// Cuerpo
|
||||
dl->AddRectFilled(a, b, IM_COL32(38, 56, 92, 240), 6.0f);
|
||||
// Borde
|
||||
uint32_t border = (n.flags & NF_SELECTED)
|
||||
? IM_COL32(180, 200, 255, 255)
|
||||
: IM_COL32(120, 160, 220, 220);
|
||||
dl->AddRect(a, b, border, 6.0f, 0, (n.flags & NF_SELECTED) ? 2.0f : 1.5f);
|
||||
|
||||
if (font) {
|
||||
dl->AddText(font, font_size,
|
||||
ImVec2(vx - ts.x * 0.5f, vy - ts.y * 0.5f),
|
||||
IM_COL32(230, 240, 255, 255), buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Type Editor (issue 0007)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user