1 #ifndef _MENU_H_ 2 #define _MENU_H_ 3 4 #include <SDL2/SDL.h> 5 #include <SDL2/SDL_ttf.h> 6 7 #include <stdbool.h> 8 #include <stdlib.h> 9 10 #include "util.h" 11 12 #define FONT_COLOR 0xFFFCF9FF 13 #define SHADOW_COLOR 0x000000FF 14 15 #define BAR_H 14 16 #define BAR_BORDER 2 17 18 #define TOTAL_ENTRIES 19 19 #define ELEMENTS_PADDING 3 20 21 #define NORM_COLOR 0x010101FF 22 #define SEL_COLOR 0xEE0000FF 23 #define HOVER_COLOR 0x444444FF 24 25 #define WIN_DEFAULT_W 800 26 #define WIN_DEFAULT_H 600 27 28 #define UNHEX(color) \ 29 ((color) >> (8 * 3)) & 0xFF, \ 30 ((color) >> (8 * 2)) & 0xFF, \ 31 ((color) >> (8 * 1)) & 0xFF, \ 32 ((color) >> (8 * 0)) & 0xFF 33 34 typedef struct Entry { 35 char *text; 36 bool selected, hover; 37 size_t index; 38 Coord pos; 39 } Entry; 40 41 void select_prev(Entry *); 42 void select_next(Entry *); 43 void select_index(Entry *, size_t i); 44 void draw_entry(SDL_Renderer *, TTF_Font *, int, int, const Entry); 45 46 void Entry_new(Entry *); 47 size_t entry_at(Entry *, int, int); 48 void hover_at(Entry *, int, int); 49 void hover_entry(Entry *, size_t); 50 void compute_entries_pos(Entry *, int, int); 51 52 53 #endif