refactor(shaders_lab): usar AppConfig.panels + layouts_cb (issue 0043)
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
#include "gfx/shaderlab_db.h"
|
#include "gfx/shaderlab_db.h"
|
||||||
#include "core/panel_menu.h"
|
#include "core/panel_menu.h"
|
||||||
#include "core/layouts_menu.h"
|
#include "core/layouts_menu.h"
|
||||||
#include "core/app_menubar.h"
|
|
||||||
#include "core/layout_storage.h"
|
#include "core/layout_storage.h"
|
||||||
|
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
@@ -24,7 +23,6 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iterator>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -73,6 +71,18 @@ static bool g_show_controls = true;
|
|||||||
static bool g_show_functions = true;
|
static bool g_show_functions = true;
|
||||||
static bool g_show_generated = 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) ───────
|
// ── Layouts (named ImGui ini snapshots persisted in shaders_lab.db) ───────
|
||||||
// El storage opaco encapsula la BD y el blob pendiente. Los callbacks
|
// 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.
|
// 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());
|
ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport());
|
||||||
|
|
||||||
// --- Menubar (View + Layouts) ---
|
// Menubar (View + Layouts + Settings + About) la invoca fn::run_app a
|
||||||
fn_ui::PanelToggle toggles[] = {
|
// partir de AppConfig::panels y AppConfig::layouts_cb.
|
||||||
{"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);
|
|
||||||
|
|
||||||
// --- Code window ---
|
// --- Code window ---
|
||||||
if (g_show_code) {
|
if (g_show_code) {
|
||||||
@@ -402,9 +403,15 @@ int main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fn::AppConfig cfg;
|
fn::AppConfig cfg;
|
||||||
cfg.title = "shaders_lab";
|
cfg.title = "shaders_lab";
|
||||||
cfg.width = 1600;
|
cfg.width = 1600;
|
||||||
cfg.height = 900;
|
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);
|
int rc = fn::run_app(cfg, render);
|
||||||
|
|
||||||
fn::gfx::canvas_destroy(g_canvas_code);
|
fn::gfx::canvas_destroy(g_canvas_code);
|
||||||
|
|||||||
Reference in New Issue
Block a user