mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-20 05:08:04 +00:00
More odin bindings
This commit is contained in:
parent
4efd7c5651
commit
91ff9d9d86
1
bindings/odin/build-clay-lib.sh
Executable file
1
bindings/odin/build-clay-lib.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
cp ../../clay.h clay.c; clang -c -o clay.o -static clay.c -fPIC; rm clay.c
|
@ -47,7 +47,7 @@ CornerRadius :: struct {
|
|||||||
bottomRight: c.float,
|
bottomRight: c.float,
|
||||||
}
|
}
|
||||||
|
|
||||||
Border :: struct {
|
BorderData :: struct {
|
||||||
width: c.uint32_t,
|
width: c.uint32_t,
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
@ -85,26 +85,51 @@ CustomElementConfig :: struct {
|
|||||||
customData: rawptr,
|
customData: rawptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
BorderContainerElementConfig :: struct {
|
BorderElementConfig :: struct {
|
||||||
left: Border,
|
left: BorderData,
|
||||||
right: Border,
|
right: BorderData,
|
||||||
top: Border,
|
top: BorderData,
|
||||||
bottom: Border,
|
bottom: BorderData,
|
||||||
betweenChildren: Border,
|
betweenChildren: BorderData,
|
||||||
cornerRadius: CornerRadius,
|
cornerRadius: CornerRadius,
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollContainerElementConfig :: struct {
|
ScrollElementConfig :: struct {
|
||||||
horizontal: c.bool,
|
horizontal: c.bool,
|
||||||
vertical: c.bool,
|
vertical: c.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FloatingAttachPointType :: enum u8 {
|
||||||
|
LEFT_TOP,
|
||||||
|
LEFT_CENTER,
|
||||||
|
LEFT_BOTTOM,
|
||||||
|
CENTER_TOP,
|
||||||
|
CENTER_CENTER,
|
||||||
|
CENTER_BOTTOM,
|
||||||
|
RIGHT_TOP,
|
||||||
|
RIGHT_CENTER,
|
||||||
|
RIGHT_BOTTOM,
|
||||||
|
}
|
||||||
|
|
||||||
|
FloatingAttachPoints :: struct {
|
||||||
|
element: FloatingAttachPointType,
|
||||||
|
parent: FloatingAttachPointType,
|
||||||
|
}
|
||||||
|
|
||||||
|
FloatingElementConfig :: struct {
|
||||||
|
offset: Vector2,
|
||||||
|
expand: Dimensions,
|
||||||
|
zIndex: c.uint16_t,
|
||||||
|
parentId: c.uint32_t,
|
||||||
|
attachment: FloatingAttachPoints,
|
||||||
|
}
|
||||||
|
|
||||||
ElementConfigUnion :: struct #raw_union {
|
ElementConfigUnion :: struct #raw_union {
|
||||||
rectangleElementConfig: ^RectangleElementConfig,
|
rectangleElementConfig: ^ImageElementConfig,
|
||||||
textElementConfig: ^TextElementConfig,
|
textElementConfig: ^TextElementConfig,
|
||||||
imageElementConfig: ^ImageElementConfig,
|
imageElementConfig: ^ImageElementConfig,
|
||||||
customElementConfig: ^CustomElementConfig,
|
customElementConfig: ^CustomElementConfig,
|
||||||
borderContainerElementConfig: ^BorderContainerElementConfig,
|
borderContainerElementConfig: ^BorderElementConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderCommand :: struct {
|
RenderCommand :: struct {
|
||||||
@ -127,7 +152,7 @@ ScrollContainerData :: struct {
|
|||||||
scrollPosition: ^Vector2,
|
scrollPosition: ^Vector2,
|
||||||
scrollContainerDimensions: Dimensions,
|
scrollContainerDimensions: Dimensions,
|
||||||
contentDimensions: Dimensions,
|
contentDimensions: Dimensions,
|
||||||
config: ScrollContainerElementConfig,
|
config: ScrollElementConfig,
|
||||||
// Indicates whether an actual scroll container matched the provided ID or if the default struct was returned.
|
// Indicates whether an actual scroll container matched the provided ID or if the default struct was returned.
|
||||||
found: c.bool,
|
found: c.bool,
|
||||||
}
|
}
|
||||||
@ -195,8 +220,17 @@ foreign Clay {
|
|||||||
Clay_EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> RenderCommandArray ---
|
Clay_EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> RenderCommandArray ---
|
||||||
Clay_PointerOver :: proc(id: c.uint32_t) -> c.bool ---
|
Clay_PointerOver :: proc(id: c.uint32_t) -> c.bool ---
|
||||||
Clay_GetScrollContainerData :: proc(id: c.uint32_t) -> ScrollContainerData ---
|
Clay_GetScrollContainerData :: proc(id: c.uint32_t) -> ScrollContainerData ---
|
||||||
Clay__CloseContainerElement :: proc() ---
|
Clay__OpenContainerElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig) ---
|
||||||
Clay__OpenRectangleElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, rectangleConfig: ^RectangleElementConfig) ---
|
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__OpenCustomElement :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig, imageConfig: ^CustomElementConfig) ---
|
||||||
|
Clay__CloseContainerElement :: proc() ---
|
||||||
|
Clay__CloseScrollContainerElement :: proc() ---
|
||||||
|
Clay__CloseFloatingContainerElement :: proc() ---
|
||||||
}
|
}
|
||||||
|
|
||||||
MinMemorySize :: proc() -> c.uint32_t {
|
MinMemorySize :: proc() -> c.uint32_t {
|
||||||
@ -235,6 +269,12 @@ GetScrollContainerData :: proc(id: c.uint32_t) -> ScrollContainerData {
|
|||||||
return Clay_GetScrollContainerData(id)
|
return Clay_GetScrollContainerData(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(deferred_none = Clay__CloseContainerElement)
|
||||||
|
Container :: proc(id: c.uint32_t, layoutConfig: ^LayoutConfig) -> bool {
|
||||||
|
Clay__OpenContainerElement(id, layoutConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
@(deferred_none = Clay__CloseContainerElement)
|
@(deferred_none = Clay__CloseContainerElement)
|
||||||
Rectangle :: proc(
|
Rectangle :: proc(
|
||||||
id: c.uint32_t,
|
id: c.uint32_t,
|
||||||
@ -244,3 +284,58 @@ Rectangle :: proc(
|
|||||||
Clay__OpenRectangleElement(id, layoutConfig, rectangleConfig)
|
Clay__OpenRectangleElement(id, layoutConfig, rectangleConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text :: proc(id: c.uint32_t, text: String, textConfig: ^TextElementConfig) -> bool {
|
||||||
|
Clay__OpenTextElement(id, text, textConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deferred_none = Clay__CloseContainerElement)
|
||||||
|
Image :: proc(
|
||||||
|
id: c.uint32_t,
|
||||||
|
layoutConfig: ^LayoutConfig,
|
||||||
|
imageConfig: ^ImageElementConfig,
|
||||||
|
) -> bool {
|
||||||
|
Clay__OpenImageContainerElement(id, layoutConfig, imageConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deferred_none = Clay__CloseContainerElement)
|
||||||
|
Scroll :: proc(
|
||||||
|
id: c.uint32_t,
|
||||||
|
layoutConfig: ^LayoutConfig,
|
||||||
|
scrollConfig: ^ScrollElementConfig,
|
||||||
|
) -> bool {
|
||||||
|
Clay__OpenScrollContainerElement(id, layoutConfig, scrollConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deferred_none = Clay__CloseFloatingContainerElement)
|
||||||
|
Floating :: proc(
|
||||||
|
id: c.uint32_t,
|
||||||
|
layoutConfig: ^LayoutConfig,
|
||||||
|
floatingConfig: ^FloatingElementConfig,
|
||||||
|
) -> bool {
|
||||||
|
Clay__OpenFloatingContainerElement(id, layoutConfig, floatingConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deferred_none = Clay__CloseContainerElement)
|
||||||
|
Border :: proc(
|
||||||
|
id: c.uint32_t,
|
||||||
|
layoutConfig: ^LayoutConfig,
|
||||||
|
borderConfig: ^BorderElementConfig,
|
||||||
|
) -> bool {
|
||||||
|
Clay__OpenBorderContainerElement(id, layoutConfig, borderConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deferred_none = Clay__CloseContainerElement)
|
||||||
|
Custom :: proc(
|
||||||
|
id: c.uint32_t,
|
||||||
|
layoutConfig: ^LayoutConfig,
|
||||||
|
customConfig: ^CustomElementConfig,
|
||||||
|
) -> bool {
|
||||||
|
Clay__OpenCustomElement(id, layoutConfig, customConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
@ -14,7 +14,7 @@ main :: proc() {
|
|||||||
sizing = {width = {type = clay.SizingType.GROW}, height = {type = clay.SizingType.GROW}},
|
sizing = {width = {type = clay.SizingType.GROW}, height = {type = clay.SizingType.GROW}},
|
||||||
padding = {16, 16},
|
padding = {16, 16},
|
||||||
}
|
}
|
||||||
rectangleConfig: clay.RectangleElementConfig = clay.RectangleElementConfig {
|
rectangleConfig: clay.ImageElementConfig = clay.ImageElementConfig {
|
||||||
cornerRadius = {topLeft = 5},
|
cornerRadius = {topLeft = 5},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user