ptk/include/ptk.h

70 lines
1.6 KiB
C
Raw Normal View History

2024-08-08 14:38:43 +02:00
#ifndef _PTK_PTK_H
#define _PTK_PTK_H
#include <ptk_vec.h>
2024-08-08 14:38:43 +02:00
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
typedef struct {
uint32_t major;
uint32_t minor;
uint32_t patch;
} PtkVersion;
bool ptk_init(size_t width, size_t height, const char *title, 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,
} PtkComponentType;
typedef struct PtkComponent {
PtkComponentType type;
} PtkComponent;
typedef struct PtkBox {
PtkComponentType type;
size_t child_count;
PtkHandle *children;
} PtkBox;
typedef struct PtkTriangle {
PtkComponentType type;
PtkPos vertices[3];
PtkColor color;
2024-08-08 14:38:43 +02:00
} PtkTriangle;
typedef struct PtkRect {
PtkComponentType type;
PtkPos top_left;
PtkSize size;
PtkColor color;
2024-08-08 14:38:43 +02:00
} PtkRect;
typedef struct PtkEllipse {
PtkComponentType type;
PtkPos center;
PtkSize radii;
PtkColor color;
2024-08-08 14:38:43 +02:00
} PtkEllipse;
PtkHandle ptk_box(size_t child_count, PtkHandle *children);
PtkHandle ptk_triangle(PtkPos vertices[3], PtkColor color);
PtkHandle ptk_rect(PtkPos top_left, PtkSize size, PtkColor color);
PtkHandle ptk_square(PtkPos top_left, float size, PtkColor color);
PtkHandle ptk_ellipse(PtkPos center, PtkSize radii, PtkColor color);
PtkHandle ptk_circle(PtkPos center, float radius, PtkColor color);
2024-08-08 14:38:43 +02:00
#define PTK_BOX(...) ptk_box(sizeof((PtkHandle []){ __VA_ARGS__ }) / sizeof(PtkHandle), (PtkHandle []) { __VA_ARGS__ })
int ptk_run(PtkHandle root);
#endif // _PTK_PTK_H