Compare commits

...

9 Commits

Author SHA1 Message Date
Joram Vandemoortele
10cbf8a0fd
Merge af3d63ad0f into 5009146c65 2025-03-05 08:33:28 +01:00
Nic Barker
5009146c65 [Bindings/Odin] Recompile odin bindings with -O3
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
2025-03-05 15:11:11 +13:00
Rico P
865b06d386
[Documentation] fix example in README (#307)
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-03-05 10:14:37 +13:00
__hexmaster111
12319fc240
Updated measure text to support the defualt raylib font if the user spesfied font failed to load. (#305) 2025-03-05 10:13:42 +13:00
Laytan
2d7d5bc082
[Bindings/Odin] fix CreateArenaWithCapacityAndMemory capacity type (#306) 2025-03-05 09:49:53 +13:00
Orcolom
af3d63ad0f added dll_export macro 2025-02-26 21:13:36 +01:00
Orcolom
0eb162e3a3 Merge branch 'main' into feature/get-pointer
# Conflicts:
#	clay.h
2025-02-26 21:12:35 +01:00
Orcolom
d1fd147b09 added getpointerstate to readme 2025-02-19 22:01:25 +01:00
Orcolom
13b588d8c1 added a pointer get method 2025-02-19 21:54:08 +01:00
10 changed files with 31 additions and 10 deletions

View File

@ -89,7 +89,7 @@ int main() {
CLAY({ CLAY({
.id = CLAY_ID("SideBar"), .id = CLAY_ID("SideBar"),
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16 }, .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16 },
.backgroundColor = COLOR_LIGHT } .backgroundColor = COLOR_LIGHT
}) { }) {
CLAY({ .id = CLAY_ID("ProfilePictureOuter"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .backgroundColor = COLOR_RED }) { CLAY({ .id = CLAY_ID("ProfilePictureOuter"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .backgroundColor = COLOR_RED }) {
CLAY({ .id = CLAY_ID("ProfilePicture"), .layout = { .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}, .image = { .imageData = &profilePicture, .sourceDimensions = {60, 60} } }) {} CLAY({ .id = CLAY_ID("ProfilePicture"), .layout = { .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}, .image = { .imageData = &profilePicture, .sourceDimensions = {60, 60} } }) {}
@ -169,6 +169,7 @@ For help starting out or to discuss clay, considering joining [the discord serve
- [Clay_SetCurrentContext](#clay_setcurrentcontext) - [Clay_SetCurrentContext](#clay_setcurrentcontext)
- [Clay_SetLayoutDimensions](#clay_setlayoutdimensions) - [Clay_SetLayoutDimensions](#clay_setlayoutdimensions)
- [Clay_SetPointerState](#clay_setpointerstate) - [Clay_SetPointerState](#clay_setpointerstate)
- [Clay_GetPointerState](#clay_getpointerstate)
- [Clay_UpdateScrollContainers](#clay_updatescrollcontainers) - [Clay_UpdateScrollContainers](#clay_updatescrollcontainers)
- [Clay_BeginLayout](#clay_beginlayout) - [Clay_BeginLayout](#clay_beginlayout)
- [Clay_EndLayout](#clay_endlayout) - [Clay_EndLayout](#clay_endlayout)
@ -646,6 +647,14 @@ Sets the internal pointer position and state (i.e. current mouse / touch positio
--- ---
### Clay_GetPointerState
`Clay_PointerData Clay_GetPointerState()`
Get the internal pointer position and state (i.e. current mouse / touch position). returns clay internal click start and stop state.
---
### Clay_UpdateScrollContainers ### Clay_UpdateScrollContainers
`void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime)` `void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime)`

View File

@ -1,13 +1,13 @@
cp ../../clay.h clay.c; cp ../../clay.h clay.c;
# Intel Mac # Intel Mac
clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-apple-darwin clay.c -fPIC && ar r clay-odin/macos/clay.a clay.o; clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-apple-darwin clay.c -fPIC -O3 && ar r clay-odin/macos/clay.a clay.o;
# ARM Mac # ARM Mac
clang -c -DCLAY_IMPLEMENTATION -g -o clay.o -static clay.c -fPIC && ar r clay-odin/macos-arm64/clay.a clay.o; clang -c -DCLAY_IMPLEMENTATION -g -o clay.o -static clay.c -fPIC -O3 && ar r clay-odin/macos-arm64/clay.a clay.o;
# x64 Windows # x64 Windows
clang -c -DCLAY_IMPLEMENTATION -o clay-odin/windows/clay.lib -ffreestanding -target x86_64-pc-windows-msvc -fuse-ld=llvm-lib -static clay.c; clang -c -DCLAY_IMPLEMENTATION -o clay-odin/windows/clay.lib -ffreestanding -target x86_64-pc-windows-msvc -fuse-ld=llvm-lib -static -O3 clay.c;
# Linux # Linux
clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-unknown-linux-gnu clay.c -fPIC && ar r clay-odin/linux/clay.a clay.o; clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-unknown-linux-gnu clay.c -fPIC -O3 && ar r clay-odin/linux/clay.a clay.o;
# WASM # WASM
clang -c -DCLAY_IMPLEMENTATION -o clay-odin/wasm/clay.o -target wasm32 -nostdlib -static clay.c; clang -c -DCLAY_IMPLEMENTATION -o clay-odin/wasm/clay.o -target wasm32 -nostdlib -static -O3 clay.c;
rm clay.o; rm clay.o;
rm clay.c; rm clay.c;

View File

@ -36,7 +36,7 @@ Dimensions :: struct {
Arena :: struct { Arena :: struct {
nextAllocation: uintptr, nextAllocation: uintptr,
capacity: uintptr, capacity: c.size_t,
memory: [^]c.char, memory: [^]c.char,
} }
@ -367,7 +367,7 @@ Context :: struct {} // opaque structure, only use as a pointer
@(link_prefix = "Clay_", default_calling_convention = "c") @(link_prefix = "Clay_", default_calling_convention = "c")
foreign Clay { foreign Clay {
MinMemorySize :: proc() -> u32 --- MinMemorySize :: proc() -> u32 ---
CreateArenaWithCapacityAndMemory :: proc(capacity: u32, offset: [^]u8) -> Arena --- CreateArenaWithCapacityAndMemory :: proc(capacity: c.size_t, offset: [^]u8) -> Arena ---
SetPointerState :: proc(position: Vector2, pointerDown: bool) --- SetPointerState :: proc(position: Vector2, pointerDown: bool) ---
Initialize :: proc(arena: Arena, layoutDimensions: Dimensions, errorHandler: ErrorHandler) -> ^Context --- Initialize :: proc(arena: Arena, layoutDimensions: Dimensions, errorHandler: ErrorHandler) -> ^Context ---
GetCurrentContext :: proc() -> ^Context --- GetCurrentContext :: proc() -> ^Context ---

Binary file not shown.

Binary file not shown.

Binary file not shown.

9
clay.h
View File

@ -796,6 +796,9 @@ CLAY_DLL_EXPORT Clay_Arena Clay_CreateArenaWithCapacityAndMemory(size_t capacity
// Sets the state of the "pointer" (i.e. the mouse or touch) in Clay's internal data. Used for detecting and responding to mouse events in the debug view, // Sets the state of the "pointer" (i.e. the mouse or touch) in Clay's internal data. Used for detecting and responding to mouse events in the debug view,
// as well as for Clay_Hovered() and scroll element handling. // as well as for Clay_Hovered() and scroll element handling.
CLAY_DLL_EXPORT void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown); CLAY_DLL_EXPORT void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown);
// Gets the state of the "pointer". This will return the position provided by `Clay_SetPointerState`
// and the frame pressed state.
CLAY_DLL_EXPORT Clay_PointerData Clay_GetPointerState();
// Initialize Clay's internal arena and setup required data before layout can begin. Only needs to be called once. // Initialize Clay's internal arena and setup required data before layout can begin. Only needs to be called once.
// - arena can be created using Clay_CreateArenaWithCapacityAndMemory() // - arena can be created using Clay_CreateArenaWithCapacityAndMemory()
// - layoutDimensions are the initial bounding dimensions of the layout (i.e. the screen width and height for a full screen layout) // - layoutDimensions are the initial bounding dimensions of the layout (i.e. the screen width and height for a full screen layout)
@ -3732,6 +3735,12 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
} }
} }
CLAY_WASM_EXPORT("Clay_GetPointerState")
Clay_PointerData Clay_GetPointerState() {
Clay_Context* context = Clay_GetCurrentContext();
return context->pointerInfo;
}
CLAY_WASM_EXPORT("Clay_Initialize") CLAY_WASM_EXPORT("Clay_Initialize")
Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) { Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) {
Clay_Context *context = Clay__Context_Allocate_Arena(&arena); Clay_Context *context = Clay__Context_Allocate_Arena(&arena);

View File

@ -91,8 +91,11 @@ static inline Clay_Dimensions Raylib_MeasureText(Clay_StringSlice text, Clay_Tex
float textHeight = config->fontSize; float textHeight = config->fontSize;
Font* fonts = (Font*)userData; Font* fonts = (Font*)userData;
Font fontToUse = fonts[config->fontId]; Font fontToUse = fonts[config->fontId];
// Font failed to load, likely the fonts are in the wrong place relative to the execution dir // Font failed to load, likely the fonts are in the wrong place relative to the execution dir.
if (!fontToUse.glyphs) return textSize; // RayLib ships with a default font, so we can continue with that built in one.
if (!fontToUse.glyphs) {
fontToUse = GetFontDefault();
}
float scaleFactor = config->fontSize/(float)fontToUse.baseSize; float scaleFactor = config->fontSize/(float)fontToUse.baseSize;