#ifndef PTK_PTK_H_ #define PTK_PTK_H_ #include #include #include #include #include #include typedef struct { uint32_t major; uint32_t minor; uint32_t patch; } PtkVersion; bool ptk_init(const size_t width, const size_t height, const char *title, const PtkVersion application_version); typedef struct PtkComponent *PtkHandle; #define PTK_NULL_HANDLE (void *)0 typedef enum { PTK_COMPONENT_TYPE_BOX = 0, PTK_COMPONENT_TYPE_TRIANGLE = 1, PTK_COMPONENT_TYPE_RECT = 2, PTK_COMPONENT_TYPE_ELLIPSE = 3, PTK_COMPONENT_TYPE_CLICKABLE = 4, } PtkComponentType; const char *ptk_component_type_to_str(PtkComponentType type); PTK_LIST_DEFINE(PtkHandle); #define PTK_COMPONENT_DEFINE(name, ...) \ typedef struct name {\ uint64_t id;\ PtkComponentType type;\ PtkHandle parent;\ PTK_LIST(PtkHandle) children;\ __VA_ARGS__\ } name PTK_COMPONENT_DEFINE(PtkComponent, ); PTK_COMPONENT_DEFINE(PtkTriangle, PtkPos vertices[3]; PtkRGB color; ); PTK_COMPONENT_DEFINE(PtkRect, PtkPos top_left; PtkSize size; PtkRGB color; ); PTK_COMPONENT_DEFINE(PtkEllipse, PtkPos center; PtkSize radii; PtkRGB color; ); typedef struct PtkClickable PtkClickable; typedef void (*MouseButtonCallback)(PtkClickable *self, const int button, const int mods); PTK_COMPONENT_DEFINE(PtkClickable, MouseButtonCallback on_press; ); PtkHandle ptk_box(const size_t child_count, PtkHandle *children); PtkHandle ptk_triangle(const PtkPos vertices[3], const PtkRGB color); PtkHandle ptk_rect(const PtkPos top_left, const PtkSize size, const PtkRGB color); PtkHandle ptk_square(const PtkPos top_left, const float size, const PtkRGB color); PtkHandle ptk_ellipse(const PtkPos center, const PtkSize radii, const PtkRGB color); PtkHandle ptk_circle(const PtkPos center, const float radius, const PtkRGB color); PtkHandle ptk_clickable(PtkHandle hitbox, const MouseButtonCallback on_press); #define PTK_BOX(...) ptk_box(sizeof((PtkHandle []){ __VA_ARGS__ }) / sizeof(PtkHandle), (PtkHandle []) { __VA_ARGS__ }) int ptk_run(PtkHandle root); #endif // PTK_PTK_H_