From e640ab3bc9486d4ae8897d54c621fc53153fcd63 Mon Sep 17 00:00:00 2001 From: Nic Barker Date: Wed, 28 Aug 2024 20:39:08 +1200 Subject: [PATCH] More progress on odin bindings --- bindings/odin/build-clay-lib.sh | 5 +- bindings/odin/clay-odin/clay.a | Bin 55568 -> 55464 bytes bindings/odin/clay-odin/clay.odin | 148 +++++++++++++++++++++++------- bindings/odin/main.odin | 23 ++++- 4 files changed, 140 insertions(+), 36 deletions(-) diff --git a/bindings/odin/build-clay-lib.sh b/bindings/odin/build-clay-lib.sh index 0f36f27..fb75c53 100755 --- a/bindings/odin/build-clay-lib.sh +++ b/bindings/odin/build-clay-lib.sh @@ -1 +1,4 @@ -cp ../../clay.h clay.c; clang -c -o clay.o -static clay.c -fPIC; rm clay.c \ No newline at end of file +cp ../../clay.h clay.c; +clang -c -o clay.o -static clay.c -fPIC && ar r clay-odin/clay.a clay.o; +rm clay.o; +rm clay.c; \ No newline at end of file diff --git a/bindings/odin/clay-odin/clay.a b/bindings/odin/clay-odin/clay.a index 1bf6422f3d6bf0e84b480e93c3f4ce4e249e425e..d1ab8f6af74257fe34fce749700008044794a027 100644 GIT binary patch delta 6113 zcmY+I4N#R;8pqESkb4nC^y&oz?p0Bsyuu|2Y8{Pz=r%f8qdPW}wg2ayKec;C?(hE3^PJ~- z-gD0T-q+J|Af$7DNJ~QK{plGQ+UIhGW@S%);EmiQ|Fuy{jZ{hrQ^`_t1KCcVBL7W> z+swH8$%W*Lk0V7CD!!BQ?2)JWYN}4h=JLEb?)(mTV?>k)Qeb9^a>03W%4^phWuePpP^_}@z|Bwrvq$bRx?^4`qi84I80t5Z<9lZFd;deoJX!CUn6&tpORmaKafKrO}vaCvHq3pSWkA6|0IV* znE?-xPmx>5Zt@IygNz<(#^sVFWIfp=^y9YM&5je~SLBame6$IaNfwY57`yl78}S@*vquUM2q%qXq}>e|z9^ zX!{`jb$GHPe??_M#dCG5SLu)J_?DsAt)o`lKUYcSOYKl@Y~y z!jLRI_)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q7{*E-0^E^&!znkbrcfEWy!*zubTr-(%$=h@}rJ>-|Ltj%6fm4qpvwi;!%kl zy!5kwUp?Uj%|Xmhk50zK4%S0r-TLr}VK|~m2~~8R57Uud{Udos6UsQ5<_JA`${l8( z^&CAnSdNo!pZEOYoJ!8FetuYlzT4+ka$a>Uc4VmW><L-czC;`FWl{X)eTO2e>D>VE`4>|_7{ diff --git a/bindings/odin/clay-odin/clay.odin b/bindings/odin/clay-odin/clay.odin index bb3089a..febc994 100644 --- a/bindings/odin/clay-odin/clay.odin +++ b/bindings/odin/clay-odin/clay.odin @@ -1,7 +1,6 @@ package clay import "core:c" -import "core:fmt" foreign import Clay "clay.a" String :: struct { @@ -125,11 +124,11 @@ FloatingElementConfig :: struct { } ElementConfigUnion :: struct #raw_union { - rectangleElementConfig: ^ImageElementConfig, - textElementConfig: ^TextElementConfig, - imageElementConfig: ^ImageElementConfig, - customElementConfig: ^CustomElementConfig, - borderContainerElementConfig: ^BorderElementConfig, + rectangleElementConfig: ^RectangleElementConfig, + textElementConfig: ^TextElementConfig, + imageElementConfig: ^ImageElementConfig, + customElementConfig: ^CustomElementConfig, + borderElementConfig: ^BorderElementConfig, } RenderCommand :: struct { @@ -140,12 +139,6 @@ RenderCommand :: struct { commandType: RenderCommandType, } -RenderCommandArray :: struct { - capacity: c.uint32_t, - length: c.uint32_t, - internalArray: [^]RenderCommand, -} - ScrollContainerData :: struct { // Note: This is a pointer to the real internal scroll position, mutating it may cause a change in final layout. // Intended for use with external functionality that modifies scroll position, such as scroll bars or auto scrolling. @@ -210,6 +203,12 @@ LayoutConfig :: struct { childAlignment: ChildAlignment, } +ClayArray :: struct($type: typeid) { + capacity: c.uint32_t, + length: c.uint32_t, + internalArray: [^]type, +} + foreign Clay { Clay_MinMemorySize :: proc() -> c.uint32_t --- Clay_CreateArenaWithCapacityAndMemory :: proc(capacity: c.uint32_t, offset: [^]u8) -> Arena --- @@ -217,20 +216,37 @@ foreign Clay { Clay_Initialize :: proc(arena: Arena) --- Clay_UpdateScrollContainers :: proc(isPointerActive: c.bool, scrollDelta: Vector2, deltaTime: c.float) --- Clay_BeginLayout :: proc(screenWidth: c.int, screenHeight: c.int) --- - Clay_EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> RenderCommandArray --- + Clay_EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> ClayArray(RenderCommand) --- Clay_PointerOver :: proc(id: c.uint32_t) -> c.bool --- Clay_GetScrollContainerData :: proc(id: c.uint32_t) -> ScrollContainerData --- + Clay_SetMeasureTextFunction :: proc(measureTextFunction: proc(text: [^]String, config: [^]TextElementConfig) -> Dimensions) --- Clay__OpenContainerElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig) --- Clay__OpenRectangleElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, rectangleConfig: ^RectangleElementConfig) --- Clay__OpenTextElement :: proc(id: c.uint32_t, text: String, textConfig: ^TextElementConfig) --- - Clay__OpenImageContainerElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^ImageElementConfig) --- - Clay__OpenScrollContainerElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^ScrollElementConfig) --- - Clay__OpenFloatingContainerElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^FloatingElementConfig) --- - Clay__OpenBorderContainerElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^BorderElementConfig) --- + Clay__OpenImageElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^ImageElementConfig) --- + Clay__OpenScrollElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^ScrollElementConfig) --- + Clay__OpenFloatingElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^FloatingElementConfig) --- + Clay__OpenBorderElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^BorderElementConfig) --- Clay__OpenCustomElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^CustomElementConfig) --- - Clay__CloseContainerElement :: proc() --- - Clay__CloseScrollContainerElement :: proc() --- - Clay__CloseFloatingContainerElement :: proc() --- + Clay__CloseElementWithChildren :: proc() --- + Clay__CloseScrollElement :: proc() --- + Clay__CloseFloatingElement :: proc() --- + Clay__layoutConfigs: ClayArray(LayoutConfig) + Clay__LayoutConfigArray_Add :: proc(array: ^ClayArray(LayoutConfig), config: LayoutConfig) -> ^LayoutConfig --- + Clay__rectangleElementConfigs: ClayArray(RectangleElementConfig) + Clay__RectangleElementConfigArray_Add :: proc(array: ^ClayArray(RectangleElementConfig), config: RectangleElementConfig) -> ^RectangleElementConfig --- + Clay__textElementConfigs: ClayArray(TextElementConfig) + Clay__TextElementConfigArray_Add :: proc(array: ^ClayArray(TextElementConfig), config: TextElementConfig) -> ^TextElementConfig --- + Clay__imageElementConfigs: ClayArray(ImageElementConfig) + Clay__ImageElementConfigArray_Add :: proc(array: ^ClayArray(ImageElementConfig), config: ImageElementConfig) -> ^ImageElementConfig --- + Clay__floatingElementConfigs: ClayArray(FloatingElementConfig) + Clay__FloatingElementConfigArray_Add :: proc(array: ^ClayArray(FloatingElementConfig), config: FloatingElementConfig) -> ^FloatingElementConfig --- + Clay__customElementConfigs: ClayArray(CustomElementConfig) + Clay__CustomElementConfigArray_Add :: proc(array: ^ClayArray(CustomElementConfig), config: CustomElementConfig) -> ^CustomElementConfig --- + Clay__scrollElementConfigs: ClayArray(ScrollElementConfig) + Clay__ScrollElementConfigArray_Add :: proc(array: ^ClayArray(ScrollElementConfig), config: ScrollElementConfig) -> ^ScrollElementConfig --- + Clay__borderElementConfigs: ClayArray(BorderElementConfig) + Clay__BorderElementConfigArray_Add :: proc(array: ^ClayArray(BorderElementConfig), config: BorderElementConfig) -> ^BorderElementConfig --- } MinMemorySize :: proc() -> c.uint32_t { @@ -257,7 +273,7 @@ BeginLayout :: proc(screenWidth: c.int, screenHeight: c.int) { Clay_BeginLayout(screenWidth, screenHeight) } -EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> RenderCommandArray { +EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> ClayArray(RenderCommand) { return Clay_EndLayout(screenWidth, screenHeight) } @@ -269,13 +285,13 @@ GetScrollContainerData :: proc(id: c.uint32_t) -> ScrollContainerData { return Clay_GetScrollContainerData(id) } -@(deferred_none = Clay__CloseContainerElement) +@(deferred_none = Clay__CloseElementWithChildren) Container :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig) -> bool { Clay__OpenContainerElement(id, layoutConfig) return true } -@(deferred_none = Clay__CloseContainerElement) +@(deferred_none = Clay__CloseElementWithChildren) Rectangle :: proc( id: c.uint32_t, layoutConfig: ^LayoutConfig, @@ -290,47 +306,47 @@ Text :: proc(id: c.uint32_t, text: String, textConfig: ^TextElementConfig) -> bo return true } -@(deferred_none = Clay__CloseContainerElement) +@(deferred_none = Clay__CloseElementWithChildren) Image :: proc( id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^ImageElementConfig, ) -> bool { - Clay__OpenImageContainerElement(id, layoutConfig, imageConfig) + Clay__OpenImageElement(id, layoutConfig, imageConfig) return true } -@(deferred_none = Clay__CloseContainerElement) +@(deferred_none = Clay__CloseScrollElement) Scroll :: proc( id: c.uint32_t, layoutConfig: ^LayoutConfig, scrollConfig: ^ScrollElementConfig, ) -> bool { - Clay__OpenScrollContainerElement(id, layoutConfig, scrollConfig) + Clay__OpenScrollElement(id, layoutConfig, scrollConfig) return true } -@(deferred_none = Clay__CloseFloatingContainerElement) +@(deferred_none = Clay__CloseFloatingElement) Floating :: proc( id: c.uint32_t, layoutConfig: ^LayoutConfig, floatingConfig: ^FloatingElementConfig, ) -> bool { - Clay__OpenFloatingContainerElement(id, layoutConfig, floatingConfig) + Clay__OpenFloatingElement(id, layoutConfig, floatingConfig) return true } -@(deferred_none = Clay__CloseContainerElement) +@(deferred_none = Clay__CloseElementWithChildren) Border :: proc( id: c.uint32_t, layoutConfig: ^LayoutConfig, borderConfig: ^BorderElementConfig, ) -> bool { - Clay__OpenBorderContainerElement(id, layoutConfig, borderConfig) + Clay__OpenBorderElement(id, layoutConfig, borderConfig) return true } -@(deferred_none = Clay__CloseContainerElement) +@(deferred_none = Clay__CloseElementWithChildren) Custom :: proc( id: c.uint32_t, layoutConfig: ^LayoutConfig, @@ -339,3 +355,71 @@ Custom :: proc( Clay__OpenCustomElement(id, layoutConfig, customConfig) return true } + +Layout :: proc(config: LayoutConfig) -> ^LayoutConfig { + return Clay__LayoutConfigArray_Add(&Clay__layoutConfigs, config) +} + +RectangleConfig :: proc(config: RectangleElementConfig) -> ^RectangleElementConfig { + return Clay__RectangleElementConfigArray_Add(&Clay__rectangleElementConfigs, config) +} + +TextConfig :: proc(config: TextElementConfig) -> ^TextElementConfig { + return Clay__TextElementConfigArray_Add(&Clay__textElementConfigs, config) +} + +ImageConfig :: proc(config: ImageElementConfig) -> ^ImageElementConfig { + return Clay__ImageElementConfigArray_Add(&Clay__imageElementConfigs, config) +} + +FloatingConfig :: proc(config: FloatingElementConfig) -> ^FloatingElementConfig { + return Clay__FloatingElementConfigArray_Add(&Clay__floatingElementConfigs, config) +} + +Custom_elementConfig :: proc(config: CustomElementConfig) -> ^CustomElementConfig { + return Clay__CustomElementConfigArray_Add(&Clay__customElementConfigs, config) +} + +ScrollConfig :: proc(config: ScrollElementConfig) -> ^ScrollElementConfig { + return Clay__ScrollElementConfigArray_Add(&Clay__scrollElementConfigs, config) +} + +BorderConfig :: proc(config: BorderElementConfig) -> ^BorderElementConfig { + return Clay__BorderElementConfigArray_Add(&Clay__borderElementConfigs, config) +} + +BorderConfigOutside :: proc(outsideBorders: BorderData) -> ^BorderElementConfig { + return Clay__BorderElementConfigArray_Add( + &Clay__borderElementConfigs, + (BorderElementConfig) { + left = outsideBorders, + right = outsideBorders, + top = outsideBorders, + bottom = outsideBorders, + }, + ) +} + +// BorderConfig_outside_radius :: proc(width, color, radius) Clay_BorderElementConfigArray_Add(&Clay__borderElementConfigs, (Clay_BorderElementConfig ) { .left = { width, color }, .right = { width, color }, .top = { width, color }, .bottom = { width, color }, .cornerRadius = { radius, radius, radius, radius } })) -> CLAY_BORDER_CONFIG_OUTSIDE_RADIUS + +// BorderConfig_all :: proc(...) Clay_BorderElementConfigArray_Add(&Clay__borderElementConfigs, (Clay_BorderElementConfig ) { .left = { __VA_ARGS__ }, .right = { __VA_ARGS__ }, .top = { __VA_ARGS__ }, .bottom = { __VA_ARGS__ }, .betweenChildren = { __VA_ARGS__ } })) -> CLAY_BORDER_CONFIG_ALL + +// BorderConfig_all_radius :: proc(width, color, radius) Clay_BorderElementConfigArray_Add(&Clay__borderElementConfigs, (Clay_BorderElementConfig ) { .left = { __VA_ARGS__ }, .right = { __VA_ARGS__ }, .top = { __VA_ARGS__ }, .bottom = { __VA_ARGS__ }, .betweenChildren = { __VA_ARGS__ }, .cornerRadius = { radius, radius, radius, radius }})) -> CLAY_BORDER_CONFIG_ALL_RADIUS + +// Corner_radius :: proc(radius) (Clay_CornerRadius) { radius, radius, radius, radius }) -> CLAY_CORNER_RADIUS + +// Sizing_fit :: proc(...) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_FIT, .sizeMinMax = (Clay_SizingMinMax) {__VA_ARGS__} }) -> CLAY_SIZING_FIT + +// Sizing_grow :: proc(...) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_GROW, .sizeMinMax = (Clay_SizingMinMax) {__VA_ARGS__} }) -> CLAY_SIZING_GROW + +// Sizing_fixed :: proc(fixedSize) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_GROW, .sizeMinMax = { fixedSize, fixedSize } }) -> CLAY_SIZING_FIXED + +// Sizing_percent :: proc(percentOfParent) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_PERCENT, .sizePercent = percentOfParent }) -> CLAY_SIZING_PERCENT + +// Id :: proc(label) Clay__HashString(CLAY_STRING(label), 0)) -> CLAY_ID + +// Idi :: proc(label, index) Clay__HashString(CLAY_STRING(label), index)) -> CLAY_IDI + +// _string_length :: proc(s) ((sizeof(s) / sizeof(s[0])) - sizeof(s[0]))) -> CLAY__STRING_LENGTH + +// String :: proc(string) (Clay_String) { .length = CLAY__STRING_LENGTH(string), .chars = string }) -> CLAY_STRING diff --git a/bindings/odin/main.odin b/bindings/odin/main.odin index 3cc3c97..72d1202 100644 --- a/bindings/odin/main.odin +++ b/bindings/odin/main.odin @@ -4,6 +4,10 @@ import clay "clay-odin" import "core:c" import "core:fmt" +measureText :: proc(text: [^]clay.String, config: [^]clay.TextElementConfig) -> clay.Dimensions { + return clay.Dimensions{20, 20} +} + main :: proc() { minMemorySize: c.uint32_t = clay.MinMemorySize() memory := make([^]u8, minMemorySize) @@ -14,15 +18,28 @@ main :: proc() { sizing = {width = {type = clay.SizingType.GROW}, height = {type = clay.SizingType.GROW}}, padding = {16, 16}, } - rectangleConfig: clay.ImageElementConfig = clay.ImageElementConfig { + rectangleConfig: clay.RectangleElementConfig = clay.RectangleElementConfig { cornerRadius = {topLeft = 5}, } - if clay.Rectangle(1, &layoutConfig, &rectangleConfig) { + if clay.Rectangle( + 1, + clay.Layout( + { + sizing = { + width = {type = clay.SizingType.GROW}, + height = {type = clay.SizingType.GROW}, + }, + padding = {16, 16}, + }, + ), + clay.RectangleConfig({cornerRadius = {topLeft = 5}}), + ) { if clay.Rectangle(1, &layoutConfig, &rectangleConfig) { } } - renderCommands: clay.RenderCommandArray = clay.EndLayout(1024, 768) + renderCommands: clay.ClayArray(clay.RenderCommand) = clay.EndLayout(1024, 768) + x: int = 5 }