mirror of
				https://github.com/nicbarker/clay.git
				synced 2025-11-04 00:26:17 +00:00 
			
		
		
		
	Fixup C++
This commit is contained in:
		
							parent
							
								
									3d5dad7bee
								
							
						
					
					
						commit
						1aaf6df33a
					
				
							
								
								
									
										30
									
								
								clay.h
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								clay.h
									
									
									
									
									
								
							| 
						 | 
					@ -44,21 +44,21 @@
 | 
				
			||||||
#define CLAY__MAX(x, y) (((x) > (y)) ? (x) : (y))
 | 
					#define CLAY__MAX(x, y) (((x) > (y)) ? (x) : (y))
 | 
				
			||||||
#define CLAY__MIN(x, y) (((x) < (y)) ? (x) : (y))
 | 
					#define CLAY__MIN(x, y) (((x) < (y)) ? (x) : (y))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_LAYOUT(...) Clay__AttachLayoutConfig(Clay__StoreLayoutConfig(CLAY__INIT(Clay_LayoutConfig) __VA_ARGS__))
 | 
					#define CLAY_LAYOUT(...) Clay__AttachLayoutConfig(Clay__StoreLayoutConfig(CLAY__CONFIG_WRAPPER(Clay_LayoutConfig, __VA_ARGS__)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_RECTANGLE(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .rectangleElementConfig = Clay__StoreRectangleElementConfig(CLAY__INIT(Clay_RectangleElementConfig) __VA_ARGS__) }, CLAY__ELEMENT_CONFIG_TYPE_RECTANGLE)
 | 
					#define CLAY_RECTANGLE(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .rectangleElementConfig = Clay__StoreRectangleElementConfig(CLAY__CONFIG_WRAPPER(Clay_RectangleElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_RECTANGLE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_TEXT_CONFIG(...) Clay__StoreTextElementConfig(CLAY__INIT(Clay_TextElementConfig) __VA_ARGS__)
 | 
					#define CLAY_TEXT_CONFIG(...) Clay__StoreTextElementConfig(CLAY__CONFIG_WRAPPER(Clay_TextElementConfig, __VA_ARGS__))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_IMAGE(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .imageElementConfig = Clay__StoreImageElementConfig(CLAY__INIT(Clay_ImageElementConfig) __VA_ARGS__) }, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)
 | 
					#define CLAY_IMAGE(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .imageElementConfig = Clay__StoreImageElementConfig(CLAY__CONFIG_WRAPPER(Clay_ImageElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_FLOATING(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .floatingElementConfig = Clay__StoreFloatingElementConfig(CLAY__INIT(Clay_FloatingElementConfig) __VA_ARGS__) }, CLAY__ELEMENT_CONFIG_TYPE_FLOATING_CONTAINER)
 | 
					#define CLAY_FLOATING(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .floatingElementConfig = Clay__StoreFloatingElementConfig(CLAY__CONFIG_WRAPPER(Clay_FloatingElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_FLOATING_CONTAINER)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_CUSTOM_ELEMENT(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(CLAY__INIT(Clay_CustomElementConfig) __VA_ARGS__))}, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM)
 | 
					#define CLAY_CUSTOM_ELEMENT(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(CLAY__INIT(Clay_CustomElementConfig, __VA_ARGS__)))}, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_SCROLL(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .scrollElementConfig = Clay__StoreScrollElementConfig(CLAY__INIT(Clay_ScrollElementConfig) __VA_ARGS__) }, CLAY__ELEMENT_CONFIG_TYPE_SCROLL_CONTAINER)
 | 
					#define CLAY_SCROLL(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .scrollElementConfig = Clay__StoreScrollElementConfig(CLAY__CONFIG_WRAPPER(Clay_ScrollElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_SCROLL_CONTAINER)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_BORDER(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .borderElementConfig = Clay__StoreBorderElementConfig(CLAY__INIT(Clay_BorderElementConfig) __VA_ARGS__) }, CLAY__ELEMENT_CONFIG_TYPE_BORDER_CONTAINER)
 | 
					#define CLAY_BORDER(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .borderElementConfig = Clay__StoreBorderElementConfig(CLAY__CONFIG_WRAPPER(Clay_BorderElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_BORDER_CONTAINER)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CLAY_BORDER_OUTSIDE(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .borderElementConfig = Clay__StoreBorderElementConfig(CLAY__INIT(Clay_BorderElementConfig) { .left = __VA_ARGS__, .right = __VA_ARGS__, .top = __VA_ARGS__, .bottom = __VA_ARGS__ }) }, CLAY__ELEMENT_CONFIG_TYPE_BORDER_CONTAINER)
 | 
					#define CLAY_BORDER_OUTSIDE(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .borderElementConfig = Clay__StoreBorderElementConfig(CLAY__INIT(Clay_BorderElementConfig) { .left = __VA_ARGS__, .right = __VA_ARGS__, .top = __VA_ARGS__, .bottom = __VA_ARGS__ }) }, CLAY__ELEMENT_CONFIG_TYPE_BORDER_CONTAINER)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -292,6 +292,8 @@ typedef struct {
 | 
				
			||||||
    Clay_LayoutDirection layoutDirection;
 | 
					    Clay_LayoutDirection layoutDirection;
 | 
				
			||||||
} Clay_LayoutConfig;
 | 
					} Clay_LayoutConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLAY__WRAPPER_STRUCT(Clay_LayoutConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern Clay_LayoutConfig CLAY_LAYOUT_DEFAULT;
 | 
					extern Clay_LayoutConfig CLAY_LAYOUT_DEFAULT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Rectangle
 | 
					// Rectangle
 | 
				
			||||||
| 
						 | 
					@ -304,6 +306,8 @@ typedef struct {
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
} Clay_RectangleElementConfig;
 | 
					} Clay_RectangleElementConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLAY__WRAPPER_STRUCT(Clay_RectangleElementConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Text
 | 
					// Text
 | 
				
			||||||
typedef enum {
 | 
					typedef enum {
 | 
				
			||||||
    CLAY_TEXT_WRAP_WORDS,
 | 
					    CLAY_TEXT_WRAP_WORDS,
 | 
				
			||||||
| 
						 | 
					@ -323,6 +327,8 @@ typedef struct {
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
} Clay_TextElementConfig;
 | 
					} Clay_TextElementConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLAY__WRAPPER_STRUCT(Clay_TextElementConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Image
 | 
					// Image
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    void *imageData;
 | 
					    void *imageData;
 | 
				
			||||||
| 
						 | 
					@ -365,6 +371,8 @@ typedef struct {
 | 
				
			||||||
    Clay_PointerCaptureMode pointerCaptureMode;
 | 
					    Clay_PointerCaptureMode pointerCaptureMode;
 | 
				
			||||||
} Clay_FloatingElementConfig;
 | 
					} Clay_FloatingElementConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLAY__WRAPPER_STRUCT(Clay_FloatingElementConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Custom
 | 
					// Custom
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    #ifndef CLAY_EXTEND_CONFIG_CUSTOM
 | 
					    #ifndef CLAY_EXTEND_CONFIG_CUSTOM
 | 
				
			||||||
| 
						 | 
					@ -374,12 +382,16 @@ typedef struct {
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
} Clay_CustomElementConfig;
 | 
					} Clay_CustomElementConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLAY__WRAPPER_STRUCT(Clay_CustomElementConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Scroll
 | 
					// Scroll
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    bool horizontal;
 | 
					    bool horizontal;
 | 
				
			||||||
    bool vertical;
 | 
					    bool vertical;
 | 
				
			||||||
} Clay_ScrollElementConfig;
 | 
					} Clay_ScrollElementConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLAY__WRAPPER_STRUCT(Clay_ScrollElementConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Border
 | 
					// Border
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    uint32_t width;
 | 
					    uint32_t width;
 | 
				
			||||||
| 
						 | 
					@ -398,6 +410,8 @@ typedef struct {
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
} Clay_BorderElementConfig;
 | 
					} Clay_BorderElementConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLAY__WRAPPER_STRUCT(Clay_BorderElementConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef union {
 | 
					typedef union {
 | 
				
			||||||
    Clay_RectangleElementConfig *rectangleElementConfig;
 | 
					    Clay_RectangleElementConfig *rectangleElementConfig;
 | 
				
			||||||
    Clay_TextElementConfig *textElementConfig;
 | 
					    Clay_TextElementConfig *textElementConfig;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,9 @@ int main(void) {
 | 
				
			||||||
    Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, (char *)malloc(totalMemorySize));
 | 
					    Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, (char *)malloc(totalMemorySize));
 | 
				
			||||||
    Clay_Initialize(clayMemory, Clay_Dimensions {1024,768}, Clay_ErrorHandler { HandleClayErrors });
 | 
					    Clay_Initialize(clayMemory, Clay_Dimensions {1024,768}, Clay_ErrorHandler { HandleClayErrors });
 | 
				
			||||||
    Clay_BeginLayout();
 | 
					    Clay_BeginLayout();
 | 
				
			||||||
    CLAY(CLAY_RECTANGLE({ .color = {255,255,255,0} }), CLAY_LAYOUT(layoutElement)) {}
 | 
					    CLAY(CLAY_RECTANGLE({ .color = {255,255,255,0} }), CLAY_LAYOUT(layoutElement)) {
 | 
				
			||||||
 | 
					        CLAY_TEXT(CLAY_STRING(""), CLAY_TEXT_CONFIG({ .fontId = 0 }));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    Clay_EndLayout();
 | 
					    Clay_EndLayout();
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue