feat(filter): tag chips + FTS5 search en toolbar (issue 0009)

- entity_ops: entity_search_fts (bm25, prefix tokens) + entity_list_by_tags (AND).
- AppState: filter_query_buf, filter_tags, filter_mode (highlight/hide), hits cache.
- views_filter_apply: combina tipos visibles + match-set (FTS query AND tags),
  highlight = color_override con alpha=0x40, hide = clear NF_VISIBLE.
- toolbar: input search + dropdown (max 20, click centra y selecciona),
  chips de tags con boton X, input para anadir tag, combo Highlight/Hide,
  Clear filter.
- Inspector: right-click sobre tag chip lo anade al filtro.
- main.cpp: reapply en cada frame si filter_dirty; cam_x/y al focus_target.
This commit is contained in:
2026-05-01 00:23:26 +02:00
parent e49cef5cb3
commit 54aba71bf5
6 changed files with 440 additions and 14 deletions
+31
View File
@@ -136,6 +136,18 @@ struct AppState {
// Caches refrescadas tras cargar grafo o tras Save.
std::vector<std::string> insp_tag_suggestions;
std::vector<std::string> insp_type_options;
// ---- Filtros y busqueda FTS5 (issue 0009) ------------------------------
// Modos: 0 = highlight (no-match dimmed), 1 = hide (no-match invisible).
enum FilterMode { FM_HIGHLIGHT = 0, FM_HIDE = 1 };
int filter_mode = FM_HIGHLIGHT;
char filter_query_buf[128] = {};
std::vector<std::string> filter_tags; // chips activos
std::vector<EntityHit> filter_hits; // dropdown FTS (max 20)
bool filter_dropdown_open = false;
bool filter_dirty = false; // pide reapply
int filter_focus_target = -1; // node_idx a centrar
char filter_tag_input[64] = {}; // input de chip nuevo
};
// Toolbar superior (Open file, Layout selector, Filters..., Fit, Save layout).
@@ -193,4 +205,23 @@ EntityRecord views_inspector_build_record(const AppState& app);
// al cambiar de proyecto.
void views_inspector_clear_draft(AppState& app);
// ---- Filter helpers (issue 0009) -----------------------------------------
// True si el filtro tiene query no vacia o al menos un tag activo.
bool views_filter_active(const AppState& app);
// Anade un tag como chip si no existe ya. Marca filter_dirty = true.
void views_filter_add_tag(AppState& app, const char* tag);
// Limpia query + tags y marca filter_dirty.
void views_filter_clear(AppState& app);
// Reaplica el filtro al grafo: recompute la mascara de visibilidad/alpha
// segun filter_query, filter_tags, filter_mode. Llama a la BD si hace
// falta (FTS + tags). Resetea color_override a 0 en los nodos que pasan
// el filtro y aplica un alpha bajo en los que no (modo highlight) o limpia
// NF_VISIBLE (modo hide). Tambien refresca filter_hits para el dropdown
// con max 20 resultados ordenados por rank.
void views_filter_apply(AppState& app);
} // namespace ge