mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-20 21:28:03 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
99775ace5e
@ -1,7 +1,13 @@
|
||||
cp ../../clay.h clay.c;
|
||||
# Intel Mac
|
||||
clang -c -o clay.o -static -target x86_64-apple-darwin clay.c -fPIC && ar r clay-odin/macos/clay.a clay.o;
|
||||
# ARM Mac
|
||||
clang -c -o clay.o -static clay.c -fPIC && ar r clay-odin/macos-arm64/clay.a clay.o;
|
||||
# x64 Windows
|
||||
clang -c -o clay-odin/windows/clay.lib -target x86_64-pc-windows-msvc -fuse-ld=llvm-lib -static clay.c;
|
||||
# Linux
|
||||
clang -c -o clay.o -static -target x86_64-unknown-linux-gnu clay.c -fPIC && ar r clay-odin/linux/clay.a clay.o;
|
||||
# WASM
|
||||
clang -c -o clay-odin/wasm/clay.o -target wasm32 -nostdlib -static clay.c;
|
||||
rm clay.o;
|
||||
rm clay.c;
|
||||
|
@ -6,7 +6,7 @@ import "core:strings"
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import Clay "windows/clay.lib"
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import Clay "linux/libclay.a"
|
||||
foreign import Clay "linux/clay.a"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
foreign import Clay "macos-arm64/clay.a"
|
||||
@ -57,7 +57,13 @@ BorderData :: struct {
|
||||
color: Color,
|
||||
}
|
||||
|
||||
RenderCommandType :: enum u8 {
|
||||
when ODIN_OS == .Windows {
|
||||
EnumBackingType :: u32
|
||||
} else {
|
||||
EnumBackingType :: u8
|
||||
}
|
||||
|
||||
RenderCommandType :: enum EnumBackingType {
|
||||
None,
|
||||
Rectangle,
|
||||
Border,
|
||||
@ -104,7 +110,7 @@ ScrollElementConfig :: struct {
|
||||
vertical: bool,
|
||||
}
|
||||
|
||||
FloatingAttachPointType :: enum u8 {
|
||||
FloatingAttachPointType :: enum EnumBackingType {
|
||||
LEFT_TOP,
|
||||
LEFT_CENTER,
|
||||
LEFT_BOTTOM,
|
||||
@ -156,7 +162,7 @@ ScrollContainerData :: struct {
|
||||
found: bool,
|
||||
}
|
||||
|
||||
SizingType :: enum u8 {
|
||||
SizingType :: enum EnumBackingType {
|
||||
FIT,
|
||||
GROW,
|
||||
PERCENT,
|
||||
@ -188,18 +194,18 @@ Padding :: struct {
|
||||
y: u16,
|
||||
}
|
||||
|
||||
LayoutDirection :: enum u8 {
|
||||
LayoutDirection :: enum EnumBackingType {
|
||||
LEFT_TO_RIGHT,
|
||||
TOP_TO_BOTTOM,
|
||||
}
|
||||
|
||||
LayoutAlignmentX :: enum u8 {
|
||||
LayoutAlignmentX :: enum EnumBackingType {
|
||||
LEFT,
|
||||
RIGHT,
|
||||
CENTER,
|
||||
}
|
||||
|
||||
LayoutAlignmentY :: enum u8 {
|
||||
LayoutAlignmentY :: enum EnumBackingType {
|
||||
TOP,
|
||||
BOTTOM,
|
||||
CENTER,
|
||||
@ -240,7 +246,7 @@ foreign Clay {
|
||||
}
|
||||
|
||||
@(private, link_prefix = "Clay_", default_calling_convention = "c")
|
||||
foreign {
|
||||
foreign _ {
|
||||
_layoutConfigs: ClayArray(LayoutConfig)
|
||||
_rectangleElementConfigs: ClayArray(RectangleElementConfig)
|
||||
_textElementConfigs: ClayArray(TextElementConfig)
|
||||
|
BIN
bindings/odin/clay-odin/linux/clay.a
Normal file
BIN
bindings/odin/clay-odin/linux/clay.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -229,14 +229,14 @@ DeclarativeSyntaxPageDesktop :: proc() {
|
||||
clay.Layout({sizing = {clay.SizingGrow({}), clay.SizingGrow({})}, childAlignment = {y = .CENTER}, padding = {32, 32}, childGap = 32}),
|
||||
clay.BorderConfig({left = {2, COLOR_RED}, right = {2, COLOR_RED}}),
|
||||
) {
|
||||
DeclarativeSyntaxPage({fontSize = 48, fontId = FONT_ID_TITLE_48, textColor = COLOR_LIGHT}, clay.SizingGrow({}))
|
||||
DeclarativeSyntaxPage({fontSize = 52, fontId = FONT_ID_TITLE_52, textColor = COLOR_RED}, clay.SizingPercent(0.5))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeclarativeSyntaxPageMobile :: proc() {
|
||||
if clay.Container(
|
||||
clay.ID("SyntaxPageDesktop"),
|
||||
clay.ID("SyntaxPageMobile"),
|
||||
clay.Layout(
|
||||
{
|
||||
layoutDirection = .TOP_TO_BOTTOM,
|
||||
@ -247,7 +247,7 @@ DeclarativeSyntaxPageMobile :: proc() {
|
||||
},
|
||||
),
|
||||
) {
|
||||
DeclarativeSyntaxPage({fontSize = 52, fontId = FONT_ID_TITLE_52, textColor = COLOR_LIGHT}, clay.SizingGrow({}))
|
||||
DeclarativeSyntaxPage({fontSize = 48, fontId = FONT_ID_TITLE_48, textColor = COLOR_RED}, clay.SizingGrow({}))
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,6 +534,8 @@ main :: proc() {
|
||||
checkImage5 = raylib.LoadTextureFromImage(raylib.LoadImage("resources/check_5.png"))
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
defer free_all(context.temp_allocator)
|
||||
|
||||
animationLerpValue += raylib.GetFrameTime()
|
||||
if animationLerpValue > 1 {
|
||||
animationLerpValue = animationLerpValue - 2
|
||||
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import clay "../../clay-odin"
|
||||
import "core:math"
|
||||
import "core:strings"
|
||||
import "vendor:raylib"
|
||||
|
||||
RaylibFont :: struct {
|
||||
@ -47,7 +48,7 @@ measureText :: proc "c" (text: ^clay.String, config: ^clay.TextElementConfig) ->
|
||||
return textSize
|
||||
}
|
||||
|
||||
clayRaylibRender :: proc(renderCommands: ^clay.ClayArray(clay.RenderCommand)) {
|
||||
clayRaylibRender :: proc(renderCommands: ^clay.ClayArray(clay.RenderCommand), allocator := context.temp_allocator) {
|
||||
for i in 0..<int(renderCommands.length) {
|
||||
renderCommand := clay.RenderCommandArray_Get(renderCommands, cast(i32)i)
|
||||
boundingBox := renderCommand.boundingBox
|
||||
@ -56,15 +57,12 @@ clayRaylibRender :: proc(renderCommands: ^clay.ClayArray(clay.RenderCommand)) {
|
||||
{}
|
||||
case clay.RenderCommandType.Text:
|
||||
// Raylib uses standard C strings so isn't compatible with cheap slices, we need to clone the string to append null terminator
|
||||
text := renderCommand.text
|
||||
cloned := make([]u8, text.length + 1, context.temp_allocator)
|
||||
copy(cloned[:text.length], text.chars[:text.length])
|
||||
cloned[text.length] = 0
|
||||
|
||||
text := string(renderCommand.text.chars[:renderCommand.text.length])
|
||||
cloned := strings.clone_to_cstring(text, allocator)
|
||||
fontToUse: raylib.Font = raylibFonts[renderCommand.config.textElementConfig.fontId].font
|
||||
raylib.DrawTextEx(
|
||||
fontToUse,
|
||||
cstring(raw_data(cloned)),
|
||||
cloned,
|
||||
raylib.Vector2{boundingBox.x, boundingBox.y},
|
||||
cast(f32)renderCommand.config.textElementConfig.fontSize,
|
||||
cast(f32)renderCommand.config.textElementConfig.letterSpacing,
|
||||
|
Loading…
Reference in New Issue
Block a user