#include "core/app_menubar.h"
#include <imgui.h>

namespace fn_ui {

bool app_menubar(const PanelToggle* panels, std::size_t count,
                 LayoutCallbacks* layouts_cb) {
    if (!ImGui::BeginMainMenuBar()) return false;

    bool changed = false;

    // Menu "View" — solo si hay panels
    if (panels && count > 0) {
        changed |= panel_menu_items("View", panels, count);
    }

    // Menu "Layouts" — solo si hay callbacks
    if (layouts_cb) {
        changed |= layouts_menu_items("Layouts", *layouts_cb);
    }

    // Menu "Settings" — siempre. Submenus: Settings... y About...
    // Las ventanas se renderizan al final del frame en fn::run_app.
    if (ImGui::BeginMenu("Settings")) {
        changed |= settings_window_menu_item("Settings...");
        ImGui::Separator();
        changed |= about_window_menu_item("About...");
        ImGui::EndMenu();
    }

    ImGui::EndMainMenuBar();
    return changed;
}

} // namespace fn_ui
