| @@ -251,6 +251,13 @@ void layout_window(int w, int h) { | |||||
| #define OUI_EXPORT | #define OUI_EXPORT | ||||
| #endif | #endif | ||||
| // some language bindings (e.g. terra) have no good support | |||||
| // for unions or unnamed structs; | |||||
| // #define OUI_USE_UNION_VECTORS 0 to disable. | |||||
| #ifndef OUI_USE_UNION_VECTORS | |||||
| #define OUI_USE_UNION_VECTORS 1 | |||||
| #endif | |||||
| // limits | // limits | ||||
| enum { | enum { | ||||
| @@ -407,18 +414,26 @@ typedef void (*UIhandler)(int item, UIevent event); | |||||
| // for cursor positions, mainly | // for cursor positions, mainly | ||||
| typedef struct UIvec2 { | typedef struct UIvec2 { | ||||
| #if OUI_USE_UNION_VECTORS || defined(OUI_IMPLEMENTATION) | |||||
| union { | union { | ||||
| int v[2]; | int v[2]; | ||||
| struct { int x, y; }; | struct { int x, y; }; | ||||
| }; | }; | ||||
| #else | |||||
| int x, y; | |||||
| #endif | |||||
| } UIvec2; | } UIvec2; | ||||
| // layout rectangle | // layout rectangle | ||||
| typedef struct UIrect { | typedef struct UIrect { | ||||
| #if OUI_USE_UNION_VECTORS || defined(OUI_IMPLEMENTATION) | |||||
| union { | union { | ||||
| int v[4]; | int v[4]; | ||||
| struct { int x, y, w, h; }; | struct { int x, y, w, h; }; | ||||
| }; | }; | ||||
| #else | |||||
| int x, y, w, h; | |||||
| #endif | |||||
| } UIrect; | } UIrect; | ||||
| // unless declared otherwise, all operations have the complexity O(1). | // unless declared otherwise, all operations have the complexity O(1). | ||||