#ifndef OS_GFX_H
#define OS_GFX_H

typedef U32 OS_Window_Flags;

typedef struct OS_InitGfxReceipt OS_InitGfxReceipt;
struct OS_InitGfxReceipt 
{
  U64 u64[1];  
};

#include "os_gfx_meta.h"

////////////////////////////////
//~ Cursor Types

typedef enum OS_Cursor
{
  OS_Cursor_Pointer,
  OS_Cursor_IBar,
  OS_Cursor_LeftRight,
  OS_Cursor_UpDown,
  OS_Cursor_DownRight,
  OS_Cursor_UpRight,
  OS_Cursor_UpDownLeftRight,
  OS_Cursor_HandPoint,
  OS_Cursor_Disabled,
  OS_Cursor_COUNT,
}
OS_Cursor;

////////////////////////////////
//~ Events
typedef enum OS_EventKind
{
  OS_EventKind_Null,
  OS_EventKind_Press,
  OS_EventKind_Release,
  OS_EventKind_MouseMove,
  OS_EventKind_Text,
  OS_EventKind_Scroll,
  OS_EventKind_WindowLoseFocus,
  OS_EventKind_WindowClose,
  OS_EventKind_FileDrop,
  OS_EventKind_Wakeup,
  OS_EventKind_COUNT
}
OS_EventKind;


typedef struct OS_Event OS_Event;
struct OS_Event
{
  OS_Event *next;
  OS_Event *prev;
  OS_Handle window;
  OS_EventKind kind;
  //OS_Modifiers modifiers;
  OS_Key key;
  U32 character;
  Vec2_F32 position;
  Vec2_F32 scroll;
  String8 path;
};

typedef struct OS_EventList OS_EventList;
struct OS_EventList
{
  OS_Event *first;
  OS_Event *last;
  U64 count;
};

////////////////////////////////
//~ Event Helpers
root_function U64           OS_character_from_key(OS_Key key);
root_function String8       OS_string_from_event(Arena *arena, OS_Event *event);
root_function B32           OS_key_press(OS_EventList *events, OS_Handle window, OS_Key key);
root_function B32           OS_key_release(OS_EventList *events, OS_Handle window);
root_function B32           OS_text_codepoint(OS_EventList *events, OS_Handle window, U32 codepoint);
root_function Vec2_F32      OS_mouse_from_window(OS_Handle handle);

////////////////////////////////
//~ @os_per_backend Init and windowing
root_function OS_InitGfxReceipt OS_gfx_init(OS_InitReceipt os_init_receipt);
root_function OS_Handle OS_window_open(OS_Window_Flags flags, Vec2_S64 size, String8 title);
root_function Rng2_F32 OS_client_rect_from_window(OS_Handle window_handle);

////////////////////////////////
//~ @os_per_backend Events
root_function OS_EventList OS_get_events(Arena *arena);
root_function void OS_consume_event(OS_EventList *events, OS_Event *event);

#endif /* OS_GFX_H */
