refactor(shaders_lab): usar modal_dialog en save-as (issue 0046)

El modal Save-as-generator usaba BeginPopupModal + InputText + Button
crudo. Ahora usa fn_ui::modal_dialog_begin/end + fn_ui::text_input +
fn_ui::button del registry. El error inline usa fn_tokens::colors::error
en vez de ImVec4(1, 0.4, 0.4, 1). Anade modal_dialog.cpp, text_input.cpp
y button.cpp al CMakeLists del app.

Raw ImGui::Begin*/Selectable/BeginPopupModal: 11 -> 8.
This commit is contained in:
2026-04-29 00:29:50 +02:00
parent cd445d8e1a
commit 2aceccfd7e
2 changed files with 26 additions and 18 deletions
+22 -18
View File
@@ -17,6 +17,10 @@
#include "core/panel_menu.h"
#include "core/layouts_menu.h"
#include "core/layout_storage.h"
#include "core/modal_dialog.h"
#include "core/text_input.h"
#include "core/button.h"
#include "core/tokens.h"
#include "compiler.h"
@@ -236,41 +240,41 @@ static void render() {
// --- Code window ---
if (g_show_code) {
if (ImGui::Begin("Code", &g_show_code)) {
if (ImGui::Button("Save as generator...")) {
if (fn_ui::button("Save as generator...", fn_ui::ButtonVariant::Secondary)) {
g_save_modal_open = true;
g_save_err.clear();
ImGui::OpenPopup("save_as_generator");
}
if (ImGui::BeginPopupModal("save_as_generator", &g_save_modal_open,
ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("Guardar shader actual como nodo Gen del DAG.");
if (fn_ui::modal_dialog_begin("Save as generator", &g_save_modal_open,
ImVec2(420, 0))) {
ImGui::TextUnformatted("Guardar shader actual como nodo Gen del DAG.");
ImGui::Spacing();
ImGui::InputText("name (snake_case)", g_save_name, sizeof(g_save_name));
ImGui::InputText("label", g_save_label, sizeof(g_save_label));
fn_ui::text_input("name (snake_case)", g_save_name, sizeof(g_save_name),
"ej: my_shader");
fn_ui::text_input("label", g_save_label, sizeof(g_save_label));
ImGui::InputTextMultiline("description", g_save_desc, sizeof(g_save_desc),
ImVec2(380, 60));
ImGui::InputText("tags (CSV)", g_save_tags, sizeof(g_save_tags));
fn_ui::text_input("tags (CSV)", g_save_tags, sizeof(g_save_tags));
if (!g_save_err.empty()) {
ImGui::TextColored(ImVec4(1, 0.4f, 0.4f, 1), "%s", g_save_err.c_str());
ImGui::PushStyleColor(ImGuiCol_Text, fn_tokens::colors::error);
ImGui::TextWrapped("%s", g_save_err.c_str());
ImGui::PopStyleColor();
}
ImGui::Spacing();
if (ImGui::Button("Save", ImVec2(120, 0))) {
ImGui::Separator();
if (fn_ui::button("Cancel", fn_ui::ButtonVariant::Subtle)) {
g_save_modal_open = false;
}
ImGui::SameLine();
if (fn_ui::button("Save", fn_ui::ButtonVariant::Primary)) {
g_save_err = save_current_as_generator();
if (g_save_err.empty()) {
g_save_modal_open = false;
ImGui::CloseCurrentPopup();
}
}
ImGui::SameLine();
if (ImGui::Button("Cancel", ImVec2(120, 0))) {
g_save_modal_open = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
fn_ui::modal_dialog_end();
ImVec2 avail = ImGui::GetContentRegionAvail();
float footer_h = g_code_err.empty() ? 0.0f : ImGui::GetTextLineHeightWithSpacing() + 8.0f;