mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-18 20:28:01 +00:00
uintptr_t to void*
This commit is contained in:
parent
9e36d370eb
commit
e8fe2e5270
30
clay.h
30
clay.h
@ -376,7 +376,7 @@ CLAY__WRAPPER_STRUCT(Clay_ScrollElementConfig);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
Clay_Color backgroundColor;
|
Clay_Color backgroundColor;
|
||||||
Clay_CornerRadius cornerRadius;
|
Clay_CornerRadius cornerRadius;
|
||||||
uintptr_t userData;
|
void* userData;
|
||||||
} Clay_SharedElementConfig;
|
} Clay_SharedElementConfig;
|
||||||
|
|
||||||
CLAY__WRAPPER_STRUCT(Clay_SharedElementConfig);
|
CLAY__WRAPPER_STRUCT(Clay_SharedElementConfig);
|
||||||
@ -472,7 +472,7 @@ typedef struct {
|
|||||||
Clay_BoundingBox boundingBox;
|
Clay_BoundingBox boundingBox;
|
||||||
Clay_RenderData renderData;
|
Clay_RenderData renderData;
|
||||||
// A pointer passed through from the element declaration
|
// A pointer passed through from the element declaration
|
||||||
uintptr_t userData;
|
void *userData;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
int16_t zIndex;
|
int16_t zIndex;
|
||||||
Clay_RenderCommandType commandType;
|
Clay_RenderCommandType commandType;
|
||||||
@ -507,7 +507,7 @@ typedef struct {
|
|||||||
Clay_ScrollElementConfig scroll;
|
Clay_ScrollElementConfig scroll;
|
||||||
Clay_BorderElementConfig border;
|
Clay_BorderElementConfig border;
|
||||||
// A pointer that will be transparently passed through to resulting render commands.
|
// A pointer that will be transparently passed through to resulting render commands.
|
||||||
uintptr_t userData;
|
void *userData;
|
||||||
} Clay_ElementDeclaration;
|
} Clay_ElementDeclaration;
|
||||||
|
|
||||||
CLAY__WRAPPER_STRUCT(Clay_ElementDeclaration);
|
CLAY__WRAPPER_STRUCT(Clay_ElementDeclaration);
|
||||||
@ -525,12 +525,12 @@ typedef CLAY_PACKED_ENUM {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
Clay_ErrorType errorType;
|
Clay_ErrorType errorType;
|
||||||
Clay_String errorText;
|
Clay_String errorText;
|
||||||
uintptr_t userData;
|
void *userData;
|
||||||
} Clay_ErrorData;
|
} Clay_ErrorData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void (*errorHandlerFunction)(Clay_ErrorData errorText);
|
void (*errorHandlerFunction)(Clay_ErrorData errorText);
|
||||||
uintptr_t userData;
|
void *userData;
|
||||||
} Clay_ErrorHandler;
|
} Clay_ErrorHandler;
|
||||||
|
|
||||||
// Function Forward Declarations ---------------------------------
|
// Function Forward Declarations ---------------------------------
|
||||||
@ -553,8 +553,8 @@ void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_Pointer
|
|||||||
bool Clay_PointerOver(Clay_ElementId elementId);
|
bool Clay_PointerOver(Clay_ElementId elementId);
|
||||||
Clay_ScrollContainerData Clay_GetScrollContainerData(Clay_ElementId id);
|
Clay_ScrollContainerData Clay_GetScrollContainerData(Clay_ElementId id);
|
||||||
Clay_TextElementConfig * Clay__StoreTextElementConfig(Clay_TextElementConfig config);
|
Clay_TextElementConfig * Clay__StoreTextElementConfig(Clay_TextElementConfig config);
|
||||||
void Clay_SetMeasureTextFunction(Clay_Dimensions (*measureTextFunction)(Clay_StringSlice text, Clay_TextElementConfig *config, uintptr_t userData), uintptr_t userData);
|
void Clay_SetMeasureTextFunction(Clay_Dimensions (*measureTextFunction)(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData), void *userData);
|
||||||
void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId, uintptr_t userData), uintptr_t userData);
|
void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId, void *userData), void *userData);
|
||||||
Clay_RenderCommand * Clay_RenderCommandArray_Get(Clay_RenderCommandArray* array, int32_t index);
|
Clay_RenderCommand * Clay_RenderCommandArray_Get(Clay_RenderCommandArray* array, int32_t index);
|
||||||
void Clay_SetDebugModeEnabled(bool enabled);
|
void Clay_SetDebugModeEnabled(bool enabled);
|
||||||
bool Clay_IsDebugModeEnabled(void);
|
bool Clay_IsDebugModeEnabled(void);
|
||||||
@ -863,8 +863,8 @@ struct Clay_Context {
|
|||||||
uint32_t debugSelectedElementId;
|
uint32_t debugSelectedElementId;
|
||||||
uint32_t generation;
|
uint32_t generation;
|
||||||
uintptr_t arenaResetOffset;
|
uintptr_t arenaResetOffset;
|
||||||
uintptr_t measureTextUserData;
|
void *measureTextUserData;
|
||||||
uintptr_t queryScrollOffsetUserData;
|
void *queryScrollOffsetUserData;
|
||||||
Clay_Arena internalArena;
|
Clay_Arena internalArena;
|
||||||
// Layout Elements / Render Commands
|
// Layout Elements / Render Commands
|
||||||
Clay_LayoutElementArray layoutElements;
|
Clay_LayoutElementArray layoutElements;
|
||||||
@ -928,11 +928,11 @@ Clay_String Clay__WriteStringToCharBuffer(Clay__charArray *buffer, Clay_String s
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CLAY_WASM
|
#ifdef CLAY_WASM
|
||||||
__attribute__((import_module("clay"), import_name("measureTextFunction"))) Clay_Dimensions Clay__MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, uintptr_t userData);
|
__attribute__((import_module("clay"), import_name("measureTextFunction"))) Clay_Dimensions Clay__MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData);
|
||||||
__attribute__((import_module("clay"), import_name("queryScrollOffsetFunction"))) Clay_Vector2 Clay__QueryScrollOffset(uint32_t elementId, uintptr_t userData);
|
__attribute__((import_module("clay"), import_name("queryScrollOffsetFunction"))) Clay_Vector2 Clay__QueryScrollOffset(uint32_t elementId, void *userData);
|
||||||
#else
|
#else
|
||||||
Clay_Dimensions (*Clay__MeasureText)(Clay_StringSlice text, Clay_TextElementConfig *config, uintptr_t userData);
|
Clay_Dimensions (*Clay__MeasureText)(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData);
|
||||||
Clay_Vector2 (*Clay__QueryScrollOffset)(uint32_t elementId, uintptr_t userData);
|
Clay_Vector2 (*Clay__QueryScrollOffset)(uint32_t elementId, void *userData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Clay_LayoutElement* Clay__GetOpenLayoutElement(void) {
|
Clay_LayoutElement* Clay__GetOpenLayoutElement(void) {
|
||||||
@ -3204,12 +3204,12 @@ Clay_Arena Clay_CreateArenaWithCapacityAndMemory(uint32_t capacity, void *offset
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CLAY_WASM
|
#ifndef CLAY_WASM
|
||||||
void Clay_SetMeasureTextFunction(Clay_Dimensions (*measureTextFunction)(Clay_StringSlice text, Clay_TextElementConfig *config, uintptr_t userData), uintptr_t userData) {
|
void Clay_SetMeasureTextFunction(Clay_Dimensions (*measureTextFunction)(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData), void *userData) {
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
Clay__MeasureText = measureTextFunction;
|
Clay__MeasureText = measureTextFunction;
|
||||||
context->measureTextUserData = userData;
|
context->measureTextUserData = userData;
|
||||||
}
|
}
|
||||||
void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId, uintptr_t userData), uintptr_t userData) {
|
void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId, void *userData), void *userData) {
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
Clay__QueryScrollOffset = queryScrollOffsetFunction;
|
Clay__QueryScrollOffset = queryScrollOffsetFunction;
|
||||||
context->queryScrollOffsetUserData = userData;
|
context->queryScrollOffsetUserData = userData;
|
||||||
|
@ -60,7 +60,7 @@ int main(int argc, char *argv[]) {
|
|||||||
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
|
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
|
||||||
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)windowWidth, (float)windowHeight }, (Clay_ErrorHandler) { HandleClayErrors });
|
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)windowWidth, (float)windowHeight }, (Clay_ErrorHandler) { HandleClayErrors });
|
||||||
|
|
||||||
Clay_SetMeasureTextFunction(SDL2_MeasureText, (uintptr_t)&fonts);
|
Clay_SetMeasureTextFunction(SDL2_MeasureText, &fonts);
|
||||||
|
|
||||||
Uint64 NOW = SDL_GetPerformanceCounter();
|
Uint64 NOW = SDL_GetPerformanceCounter();
|
||||||
Uint64 LAST = 0;
|
Uint64 LAST = 0;
|
||||||
|
@ -23,7 +23,7 @@ typedef struct app_state {
|
|||||||
ClayVideoDemo_Data demoData;
|
ClayVideoDemo_Data demoData;
|
||||||
} AppState;
|
} AppState;
|
||||||
|
|
||||||
static inline Clay_Dimensions SDL_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, uintptr_t userData)
|
static inline Clay_Dimensions SDL_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData)
|
||||||
{
|
{
|
||||||
TTF_Font *font = gFonts[config->fontId];
|
TTF_Font *font = gFonts[config->fontId];
|
||||||
int width, height;
|
int width, height;
|
||||||
|
@ -20,7 +20,7 @@ int main(void) {
|
|||||||
Font fonts[1];
|
Font fonts[1];
|
||||||
fonts[FONT_ID_BODY_16] = LoadFontEx("resources/Roboto-Regular.ttf", 48, 0, 400);
|
fonts[FONT_ID_BODY_16] = LoadFontEx("resources/Roboto-Regular.ttf", 48, 0, 400);
|
||||||
SetTextureFilter(fonts[FONT_ID_BODY_16].texture, TEXTURE_FILTER_BILINEAR);
|
SetTextureFilter(fonts[FONT_ID_BODY_16].texture, TEXTURE_FILTER_BILINEAR);
|
||||||
Clay_SetMeasureTextFunction(Raylib_MeasureText, (uintptr_t)fonts);
|
Clay_SetMeasureTextFunction(Raylib_MeasureText, fonts);
|
||||||
|
|
||||||
ClayVideoDemo_Data data = ClayVideoDemo_Initialize();
|
ClayVideoDemo_Data data = ClayVideoDemo_Initialize();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ int main(void) {
|
|||||||
.height = GetScreenHeight() / 2
|
.height = GetScreenHeight() / 2
|
||||||
}, (Clay_ErrorHandler) { HandleClayErrors }); // This final argument is new since the video was published
|
}, (Clay_ErrorHandler) { HandleClayErrors }); // This final argument is new since the video was published
|
||||||
ClayVideoDemo_Data dataTop = ClayVideoDemo_Initialize();
|
ClayVideoDemo_Data dataTop = ClayVideoDemo_Initialize();
|
||||||
Clay_SetMeasureTextFunction(Raylib_MeasureText, (uintptr_t)fonts);
|
Clay_SetMeasureTextFunction(Raylib_MeasureText, fonts);
|
||||||
|
|
||||||
Clay_Arena clayMemoryBottom = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory));
|
Clay_Arena clayMemoryBottom = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory));
|
||||||
Clay_Context *clayContextBottom = Clay_Initialize(clayMemoryBottom, (Clay_Dimensions) {
|
Clay_Context *clayContextBottom = Clay_Initialize(clayMemoryBottom, (Clay_Dimensions) {
|
||||||
@ -60,7 +60,7 @@ int main(void) {
|
|||||||
.height = GetScreenHeight() / 2
|
.height = GetScreenHeight() / 2
|
||||||
}, (Clay_ErrorHandler) { HandleClayErrors }); // This final argument is new since the video was published
|
}, (Clay_ErrorHandler) { HandleClayErrors }); // This final argument is new since the video was published
|
||||||
ClayVideoDemo_Data dataBottom = ClayVideoDemo_Initialize();
|
ClayVideoDemo_Data dataBottom = ClayVideoDemo_Initialize();
|
||||||
Clay_SetMeasureTextFunction(Raylib_MeasureText, (uintptr_t)fonts);
|
Clay_SetMeasureTextFunction(Raylib_MeasureText, fonts);
|
||||||
|
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
dataBottom.yOffset = GetScreenHeight() / 2;
|
dataBottom.yOffset = GetScreenHeight() / 2;
|
||||||
|
@ -73,7 +73,6 @@ Clay_RenderCommandArray CreateLayout(void) {
|
|||||||
.backgroundColor = { 140, 80, 200, 200 },
|
.backgroundColor = { 140, 80, 200, 200 },
|
||||||
.floating = { .attachTo = CLAY_ATTACH_TO_PARENT, .zIndex = 1, .attachPoints = { CLAY_ATTACH_POINT_CENTER_TOP, CLAY_ATTACH_POINT_CENTER_TOP }, .offset = {0, 0} },
|
.floating = { .attachTo = CLAY_ATTACH_TO_PARENT, .zIndex = 1, .attachPoints = { CLAY_ATTACH_POINT_CENTER_TOP, CLAY_ATTACH_POINT_CENTER_TOP }, .offset = {0, 0} },
|
||||||
.border = { .width = CLAY_BORDER_OUTSIDE(2), .color = {80, 80, 80, 255} },
|
.border = { .width = CLAY_BORDER_OUTSIDE(2), .color = {80, 80, 80, 255} },
|
||||||
.userData = 8
|
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(CLAY_STRING("I'm an inline floating container."), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {255,255,255,255} }));
|
CLAY_TEXT(CLAY_STRING("I'm an inline floating container."), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {255,255,255,255} }));
|
||||||
}
|
}
|
||||||
@ -235,7 +234,7 @@ int main(void) {
|
|||||||
SetTextureFilter(fonts[FONT_ID_BODY_24].texture, TEXTURE_FILTER_BILINEAR);
|
SetTextureFilter(fonts[FONT_ID_BODY_24].texture, TEXTURE_FILTER_BILINEAR);
|
||||||
fonts[FONT_ID_BODY_16] = LoadFontEx("resources/Roboto-Regular.ttf", 32, 0, 400);
|
fonts[FONT_ID_BODY_16] = LoadFontEx("resources/Roboto-Regular.ttf", 32, 0, 400);
|
||||||
SetTextureFilter(fonts[FONT_ID_BODY_16].texture, TEXTURE_FILTER_BILINEAR);
|
SetTextureFilter(fonts[FONT_ID_BODY_16].texture, TEXTURE_FILTER_BILINEAR);
|
||||||
Clay_SetMeasureTextFunction(Raylib_MeasureText, (uintptr_t)fonts);
|
Clay_SetMeasureTextFunction(Raylib_MeasureText, fonts);
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ typedef struct
|
|||||||
} SDL2_Font;
|
} SDL2_Font;
|
||||||
|
|
||||||
|
|
||||||
static Clay_Dimensions SDL2_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, uintptr_t userData)
|
static Clay_Dimensions SDL2_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData)
|
||||||
{
|
{
|
||||||
SDL2_Font *fonts = (SDL2_Font*)userData;
|
SDL2_Font *fonts = (SDL2_Font*)userData;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ Ray GetScreenToWorldPointWithZDistance(Vector2 position, Camera camera, int scre
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline Clay_Dimensions Raylib_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, uintptr_t userData) {
|
static inline Clay_Dimensions Raylib_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData) {
|
||||||
// Measure string size for Font
|
// Measure string size for Font
|
||||||
Clay_Dimensions textSize = { 0 };
|
Clay_Dimensions textSize = { 0 };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user