#pragma once

#include "pxl8_gfx.h"
#include "pxl8_types.h"

typedef struct {
    i32 cursor_x;
    i32 cursor_y;
    bool cursor_down;
    bool cursor_clicked;
    u32 hot_id;
    u32 active_id;
} pxl8_gui_state;

#ifdef __cplusplus
extern "C" {
#endif

pxl8_gui_state* pxl8_gui_state_create(void);
void pxl8_gui_state_destroy(pxl8_gui_state* state);

void pxl8_gui_get_cursor_pos(const pxl8_gui_state* state, i32* x, i32* y);
bool pxl8_gui_is_hovering(const pxl8_gui_state* state);

void pxl8_gui_begin_frame(pxl8_gui_state* state, pxl8_gfx* gfx);
void pxl8_gui_end_frame(pxl8_gui_state* state, pxl8_gfx* gfx);

void pxl8_gui_cursor_down(pxl8_gui_state* state);
void pxl8_gui_cursor_move(pxl8_gui_state* state, i32 x, i32 y);
void pxl8_gui_cursor_up(pxl8_gui_state* state);

bool pxl8_gui_button(pxl8_gui_state* state, pxl8_gfx* gfx, u32 id, i32 x, i32 y, i32 w, i32 h, const char* label);
void pxl8_gui_label(pxl8_gfx* gfx, i32 x, i32 y, const char* text, u8 color);
void pxl8_gui_window(pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h, const char* title);

#ifdef __cplusplus
}
#endif
