#include "platform/platform.h"

typedef enum MenuCmd {
    MENU_NONE = 0,
    MENU_FILE_NEW,
    MENU_FILE_OPEN,
    MENU_FILE_SAVE,
    MENU_FILE_SAVE_AS,
    MENU_FILE_EXIT,
    MENU_IMPORT_AUDIO,
    MENU_IMPORT_MIDI,
    MENU_VIEW_BROWSER,
    MENU_VIEW_PROPERTIES,
    MENU_VIEW_LOG,
    MENU_VIEW_DEMO,
    MENU_VIEW_MIDI_DEVICES,
    MENU_PREFERENCES_EDIT,
} MenuCmd;

static void setup_menus(PlatformWindow *window) {
    PlatformMenuItem file_items[] = {
        { "New",        MENU_FILE_NEW },
        { "Open...",    MENU_FILE_OPEN },
        { "Save",       MENU_FILE_SAVE },
        { "Save As...", MENU_FILE_SAVE_AS },
        { NULL,         0 },
        { "Exit",       MENU_FILE_EXIT },
    };

    PlatformMenuItem import_items[] = {
        { "Audio...",   MENU_IMPORT_AUDIO },
        { "MIDI...",    MENU_IMPORT_MIDI },
    };

    PlatformMenuItem view_items[] = {
        { "Browser",    MENU_VIEW_BROWSER },
        { "Properties", MENU_VIEW_PROPERTIES },
        { "Log",        MENU_VIEW_LOG },
        { NULL,         0 },
        { "Demo",         MENU_VIEW_DEMO },
        { "MIDI Devices", MENU_VIEW_MIDI_DEVICES },
    };

    PlatformMenuItem prefs_items[] = {
        { "Edit Preferences", MENU_PREFERENCES_EDIT },
    };

    PlatformMenu menus[] = {
        { "File",        file_items,   sizeof(file_items)   / sizeof(file_items[0]) },
        { "Import",      import_items, sizeof(import_items)  / sizeof(import_items[0]) },
        { "View",        view_items,   sizeof(view_items)   / sizeof(view_items[0]) },
        { "Preferences", prefs_items,  sizeof(prefs_items)  / sizeof(prefs_items[0]) },
    };

    platform_set_menu(window, menus, sizeof(menus) / sizeof(menus[0]));
}
