summaryrefslogtreecommitdiffhomepage
path: root/src/ui.h
blob: d6d0b2411235434e122725f50ecffebe5e187681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once

/* ui.h — rendering and input contract.
 *
 * Owns: font/color initialization, all drawing, all mouse/keyboard input
 * for the player tab, the smart-play hold button, study-mode checkbox.
 * Does NOT own: tab bar (drawn by main via raygui), layout editor tab,
 * drag-drop file loading (main), config save on tab switch (main). */

#include "types.h"
#include "config.h"

/* ------------------------------------------------------------------ */
/* UI state — fonts, colors, interaction flags.                       */
/* ------------------------------------------------------------------ */

typedef struct {
    /* Fonts (loaded in ui_init, unloaded in ui_destroy) */
    Font fontSmall, font, fontMed, fontLarge, fontHelp;
    float szSmall, szHelp, szFont, szMed, szLarge;

    /* Colors */
    Color bgColor;
    Color textColor;
    Color accentColor;
    Color mutedColor;
    Color barBgColor;
    Color btnHoverColor;

    /* Interaction state */
    bool smartPlayHeld;
} UIState;

/* ------------------------------------------------------------------ */
/* Lifecycle                                                          */
/* ------------------------------------------------------------------ */

/* Load fonts (embedded or default) and set colors. Call after InitWindow. */
void ui_init(UIState *ui);

/* Unload fonts (embedded only). Call before CloseWindow. */
void ui_destroy(UIState *ui);

/* ------------------------------------------------------------------ */
/* Input — call once per frame BEFORE player_update, only on tab 0.   */
/* Processes button clicks, keyboard, click-to-seek, smart-play hold, */
/* study-mode checkbox toggle. Mutates state and ui->smartPlayHeld.   */
/* ------------------------------------------------------------------ */

void ui_handle_input(UIState *ui, PlayerState *state, const UILayout *layout);

/* ------------------------------------------------------------------ */
/* Rendering — call inside BeginDrawing/EndDrawing, only on tab 0.    */
/* ------------------------------------------------------------------ */

/* Draw the player UI (filename, progress bar, buttons, help, checkbox).
 * Call when state->loaded is true. */
void ui_render_player(const UIState *ui, const PlayerState *state,
                      const UILayout *layout);

/* Draw the "no file loaded" splash screen. */
void ui_render_empty(const UIState *ui, const UILayout *layout);

/* Draw the help text and study-mode checkbox (always visible on tab 0).
 * Call after ui_render_player or ui_render_empty. */
void ui_render_overlay(const UIState *ui, const PlayerState *state,
                       const UILayout *layout);