merge: issue/0043-cpp-apps-standardize-shell — implementación paralela

This commit is contained in:
2026-04-29 00:09:43 +02:00
4 changed files with 41 additions and 29 deletions
+8 -1
View File
@@ -77,5 +77,12 @@ static void render() {
}
int main() {
return fn::run_app({.title = "fn_registry — Chart Demo", .width = 1400, .height = 900}, render);
return fn::run_app({
.title = "fn_registry — Chart Demo",
.width = 1400,
.height = 900,
.about = {.name = "chart demo",
.version = "0.1.0",
.description = "Demo de primitivos viz: line, scatter, bar, heatmap"}
}, render);
}
+10 -12
View File
@@ -14,7 +14,6 @@
#include "core/page_header.h"
#include "core/toast.h"
#include "core/app_menubar.h"
#include "gfx/gl_loader.h"
#include "demos.h"
#include "demo.h"
@@ -124,15 +123,8 @@ static void draw_sidebar() {
}
static void render() {
static bool init_done = false;
if (!init_done) {
fn_tokens::apply_dark_theme();
// En Linux es no-op; en Windows resuelve los punteros GL via wglGetProcAddress.
// Imprescindible antes de invocar primitivos que usen OpenGL 2.0+ (graph_viewport,
// shader_canvas, etc).
fn::gfx::gl_loader_init();
init_done = true;
}
// Theme y gl_loader gestionados por fn::run_app (theme=FnDark por defecto,
// init_gl_loader=true en AppConfig).
// MainMenuBar (solo Settings — la gallery no tiene paneles toggleables ni layouts)
fn_ui::app_menubar(nullptr, 0, nullptr);
@@ -171,8 +163,14 @@ static void render() {
int main(int /*argc*/, char** /*argv*/) {
return fn::run_app(
{.title = "fn_registry · Primitives Gallery",
.width = 1400, .height = 900, .viewports = true},
{.title = "fn_registry · Primitives Gallery",
.width = 1400,
.height = 900,
.viewports = true,
.about = {.name = "Primitives Gallery",
.version = "0.1.0",
.description = "Visual catalog of fn_registry C++ UI primitives"},
.init_gl_loader = true},
render
);
}
+23 -16
View File
@@ -16,7 +16,6 @@
#include "gfx/shaderlab_db.h"
#include "core/panel_menu.h"
#include "core/layouts_menu.h"
#include "core/app_menubar.h"
#include "core/layout_storage.h"
#include "compiler.h"
@@ -24,7 +23,6 @@
#include <chrono>
#include <cctype>
#include <cstring>
#include <iterator>
#include <string>
#include <utility>
#include <vector>
@@ -73,6 +71,18 @@ static bool g_show_controls = true;
static bool g_show_functions = true;
static bool g_show_generated = true;
// Tabla de paneles toggleables que fn::run_app pasa a app_menubar cada frame.
// Vive en el ambito del archivo para poder referenciarse desde main().
static constexpr fn_ui::PanelToggle k_panels[] = {
{"Code", "Ctrl+1", &g_show_code},
{"DAG Pipeline", "Ctrl+2", &g_show_dag},
{"Canvas Code", "Ctrl+3", &g_show_canvas_c},
{"Canvas DAG", "Ctrl+4", &g_show_canvas_d},
{"Controls", "Ctrl+5", &g_show_controls},
{"Functions", "Ctrl+6", &g_show_functions},
{"Generated GLSL","Ctrl+7", &g_show_generated},
};
// ── Layouts (named ImGui ini snapshots persisted in shaders_lab.db) ───────
// El storage opaco encapsula la BD y el blob pendiente. Los callbacks
// envuelven save/apply/delete/reset y se pasan a app_menubar tal cual.
@@ -220,17 +230,8 @@ static void render() {
ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport());
// --- Menubar (View + Layouts) ---
fn_ui::PanelToggle toggles[] = {
{"Code", "Ctrl+1", &g_show_code},
{"DAG Pipeline", "Ctrl+2", &g_show_dag},
{"Canvas Code", "Ctrl+3", &g_show_canvas_c},
{"Canvas DAG", "Ctrl+4", &g_show_canvas_d},
{"Controls", "Ctrl+5", &g_show_controls},
{"Functions", "Ctrl+6", &g_show_functions},
{"Generated GLSL","Ctrl+7", &g_show_generated},
};
fn_ui::app_menubar(toggles, std::size(toggles), &g_layout_cb);
// Menubar (View + Layouts + Settings + About) la invoca fn::run_app a
// partir de AppConfig::panels y AppConfig::layouts_cb.
// --- Code window ---
if (g_show_code) {
@@ -402,9 +403,15 @@ int main() {
};
fn::AppConfig cfg;
cfg.title = "shaders_lab";
cfg.width = 1600;
cfg.height = 900;
cfg.title = "shaders_lab";
cfg.width = 1600;
cfg.height = 900;
cfg.about = {.name = "shaders_lab",
.version = "0.1.0",
.description = "Live GLSL shader playground with DAG pipeline"};
cfg.panels = k_panels;
cfg.panel_count = sizeof(k_panels) / sizeof(k_panels[0]);
cfg.layouts_cb = &g_layout_cb;
int rc = fn::run_app(cfg, render);
fn::gfx::canvas_destroy(g_canvas_code);