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

namespace fn_ui {

bool panel_menu_items(const char* menu_label,
                      const PanelToggle* items, std::size_t count) {
    if (!items) count = 0;

    bool changed = false;

    if (ImGui::BeginMenu(menu_label)) {
        for (std::size_t i = 0; i < count; ++i) {
            const PanelToggle& item = items[i];
            if (!item.open) continue;
            bool clicked = ImGui::MenuItem(item.label, item.shortcut, item.open);
            changed |= clicked;
        }
        ImGui::EndMenu();
    }

    return changed;
}

bool panel_menu(const char* menu_label,
                const PanelToggle* items, std::size_t count) {
    if (!ImGui::BeginMainMenuBar()) return false;
    bool changed = panel_menu_items(menu_label, items, count);
    ImGui::EndMainMenuBar();
    return changed;
}

} // namespace fn_ui
