Files
ui-library-playground/Core/Inc/graphics/menu.h
Dylan Smith b48cb11197 Menu work
2026-01-15 15:53:02 -05:00

50 lines
1.3 KiB
C

#ifndef MENU_H
#define MENU_H
#include "stdint.h"
#include "stdbool.h"
typedef void (*menu_callback_t)(void *args);
typedef struct _graphical_menu_layout_t graphical_menu_layout_t;
typedef struct _graphical_menu_t graphical_menu_t;
// TODO
// typedef struct {
// uint16_t x;
// uint16_t y;
// uint16_t width;
// uint16_t height;
// } graphical_menu_position_t;
typedef struct
{
const char *const title;
const bool enabled; // not enabled = grayed out, unhighlightable
const menu_callback_t highlighted_callback_function;
void *const highlighted_callback_function_args;
const menu_callback_t selected_callback_function;
void *const selected_callback_function_args;
} graphical_menu_entry_t;
struct _graphical_menu_layout_t {
graphical_menu_t *const parent_menu;
const uint8_t num_entries;
const graphical_menu_entry_t *const entries;
};
struct _graphical_menu_t {
const graphical_menu_layout_t *const layout;
uint8_t selected_entry_idx;
};
void draw_menu(const graphical_menu_t *const menu);
void select_menu_entry(graphical_menu_t *const menu);
uint8_t get_selected_menu_entry_idx(void);
void set_selected_menu_entry_idx(graphical_menu_t *const menu, int8_t idx);
void decrement_selected_menu_entry_idx(graphical_menu_t *const menu);
void increment_selected_menu_entry_idx(graphical_menu_t *const menu);
#endif