mirror of
https://github.com/nicbarker/clay.git
synced 2025-05-03 17:08:06 +00:00
Compare commits
14 Commits
d35aad9724
...
d5ca133b1a
Author | SHA1 | Date | |
---|---|---|---|
|
d5ca133b1a | ||
|
9e7595b873 | ||
|
32d1a31dfe | ||
|
b2b50724e2 | ||
|
12b3280dab | ||
|
d81c9e1de5 | ||
|
7142a427bb | ||
|
d7ee448ed5 | ||
|
7ecd5adbce | ||
|
2fcb4cc76e | ||
|
23863edde0 | ||
|
974af1e61c | ||
|
10f1565f6f | ||
|
77bc75fc8b |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,5 @@
|
|||||||
cmake-build-debug/
|
cmake-build-debug/
|
||||||
cmake-build-release/
|
cmake-build-release/
|
||||||
build/
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea/
|
.idea/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
49
clay.h
49
clay.h
@ -406,6 +406,9 @@ CLAY__TYPEDEF(Clay_BorderElementConfig, struct {
|
|||||||
Clay_Border bottom;
|
Clay_Border bottom;
|
||||||
Clay_Border betweenChildren;
|
Clay_Border betweenChildren;
|
||||||
Clay_CornerRadius cornerRadius;
|
Clay_CornerRadius cornerRadius;
|
||||||
|
#ifdef CLAY_EXTEND_CONFIG_BORDER
|
||||||
|
CLAY_EXTEND_CONFIG_BORDER
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
CLAY__TYPEDEF(Clay_ElementConfigUnion, union {
|
CLAY__TYPEDEF(Clay_ElementConfigUnion, union {
|
||||||
@ -1326,7 +1329,7 @@ CLAY__TYPEDEF(Clay__LayoutElementTreeRoot, struct {
|
|||||||
|
|
||||||
Clay__LayoutElementTreeRoot CLAY__LAYOUT_ELEMENT_TREE_ROOT_DEFAULT = CLAY__DEFAULT_STRUCT;
|
Clay__LayoutElementTreeRoot CLAY__LAYOUT_ELEMENT_TREE_ROOT_DEFAULT = CLAY__DEFAULT_STRUCT;
|
||||||
|
|
||||||
// __GENERATED__ template array_define,array_allocate,array_add,array_get TYPE=Clay__LayoutElementTreeRoot NAME=Clay__LayoutElementTreeRootArray DEFAULT_VALUE=&CLAY__LAYOUT_ELEMENT_TREE_ROOT_DEFAULT
|
// __GENERATED__ template array_define,array_allocate,array_add,array_get,array_set TYPE=Clay__LayoutElementTreeRoot NAME=Clay__LayoutElementTreeRootArray DEFAULT_VALUE=&CLAY__LAYOUT_ELEMENT_TREE_ROOT_DEFAULT
|
||||||
#pragma region generated
|
#pragma region generated
|
||||||
CLAY__TYPEDEF(Clay__LayoutElementTreeRootArray, struct
|
CLAY__TYPEDEF(Clay__LayoutElementTreeRootArray, struct
|
||||||
{
|
{
|
||||||
@ -1347,6 +1350,12 @@ Clay__LayoutElementTreeRoot *Clay__LayoutElementTreeRootArray_Add(Clay__LayoutEl
|
|||||||
Clay__LayoutElementTreeRoot *Clay__LayoutElementTreeRootArray_Get(Clay__LayoutElementTreeRootArray *array, int32_t index) {
|
Clay__LayoutElementTreeRoot *Clay__LayoutElementTreeRootArray_Get(Clay__LayoutElementTreeRootArray *array, int32_t index) {
|
||||||
return Clay__Array_RangeCheck(index, array->length) ? &array->internalArray[index] : &CLAY__LAYOUT_ELEMENT_TREE_ROOT_DEFAULT;
|
return Clay__Array_RangeCheck(index, array->length) ? &array->internalArray[index] : &CLAY__LAYOUT_ELEMENT_TREE_ROOT_DEFAULT;
|
||||||
}
|
}
|
||||||
|
void Clay__LayoutElementTreeRootArray_Set(Clay__LayoutElementTreeRootArray *array, int32_t index, Clay__LayoutElementTreeRoot value) {
|
||||||
|
if (Clay__Array_RangeCheck(index, array->capacity)) {
|
||||||
|
array->internalArray[index] = value;
|
||||||
|
array->length = index < array->length ? array->length : index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
// __GENERATED__ template
|
// __GENERATED__ template
|
||||||
|
|
||||||
@ -1381,7 +1390,7 @@ struct Clay_Context {
|
|||||||
bool externalScrollHandlingEnabled;
|
bool externalScrollHandlingEnabled;
|
||||||
uint32_t debugSelectedElementId;
|
uint32_t debugSelectedElementId;
|
||||||
uint32_t generation;
|
uint32_t generation;
|
||||||
uint64_t arenaResetOffset;
|
uintptr_t arenaResetOffset;
|
||||||
Clay_Arena internalArena;
|
Clay_Arena internalArena;
|
||||||
// Layout Elements / Render Commands
|
// Layout Elements / Render Commands
|
||||||
Clay_LayoutElementArray layoutElements;
|
Clay_LayoutElementArray layoutElements;
|
||||||
@ -2093,6 +2102,9 @@ void Clay__CompressChildrenAlongAxis(bool xAxis, float totalSizeToDistribute, Cl
|
|||||||
float targetSize = 0;
|
float targetSize = 0;
|
||||||
for (int32_t i = 0; i < resizableContainerBuffer.length; ++i) {
|
for (int32_t i = 0; i < resizableContainerBuffer.length; ++i) {
|
||||||
Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
|
Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
|
||||||
|
if (!xAxis && Clay__ElementHasConfig(childElement, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
float childSize = xAxis ? childElement->dimensions.width : childElement->dimensions.height;
|
float childSize = xAxis ? childElement->dimensions.width : childElement->dimensions.height;
|
||||||
if ((childSize - largestSize) < 0.1 && (childSize - largestSize) > -0.1) {
|
if ((childSize - largestSize) < 0.1 && (childSize - largestSize) > -0.1) {
|
||||||
Clay__int32_tArray_Add(&largestContainers, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
|
Clay__int32_tArray_Add(&largestContainers, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
|
||||||
@ -2457,6 +2469,20 @@ void Clay__CalculateFinalLayout() {
|
|||||||
// Calculate sizing along the Y axis
|
// Calculate sizing along the Y axis
|
||||||
Clay__SizeContainersAlongAxis(false);
|
Clay__SizeContainersAlongAxis(false);
|
||||||
|
|
||||||
|
// Sort tree roots by z-index
|
||||||
|
int32_t sortMax = context->layoutElementTreeRoots.length - 1;
|
||||||
|
while (sortMax > 0) { // todo dumb bubble sort
|
||||||
|
for (int32_t i = 0; i < sortMax; ++i) {
|
||||||
|
Clay__LayoutElementTreeRoot current = *Clay__LayoutElementTreeRootArray_Get(&context->layoutElementTreeRoots, i);
|
||||||
|
Clay__LayoutElementTreeRoot next = *Clay__LayoutElementTreeRootArray_Get(&context->layoutElementTreeRoots, i + 1);
|
||||||
|
if (next.zIndex < current.zIndex) {
|
||||||
|
Clay__LayoutElementTreeRootArray_Set(&context->layoutElementTreeRoots, i, next);
|
||||||
|
Clay__LayoutElementTreeRootArray_Set(&context->layoutElementTreeRoots, i + 1, current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sortMax--;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate final positions and generate render commands
|
// Calculate final positions and generate render commands
|
||||||
context->renderCommands.length = 0;
|
context->renderCommands.length = 0;
|
||||||
dfsBuffer.length = 0;
|
dfsBuffer.length = 0;
|
||||||
@ -2606,7 +2632,7 @@ void Clay__CalculateFinalLayout() {
|
|||||||
for (int32_t elementConfigIndex = 0; elementConfigIndex < currentElement->elementConfigs.length; ++elementConfigIndex) {
|
for (int32_t elementConfigIndex = 0; elementConfigIndex < currentElement->elementConfigs.length; ++elementConfigIndex) {
|
||||||
sortedConfigIndexes[elementConfigIndex] = elementConfigIndex;
|
sortedConfigIndexes[elementConfigIndex] = elementConfigIndex;
|
||||||
}
|
}
|
||||||
int32_t sortMax = currentElement->elementConfigs.length - 1;
|
sortMax = currentElement->elementConfigs.length - 1;
|
||||||
while (sortMax > 0) { // todo dumb bubble sort
|
while (sortMax > 0) { // todo dumb bubble sort
|
||||||
for (int32_t i = 0; i < sortMax; ++i) {
|
for (int32_t i = 0; i < sortMax; ++i) {
|
||||||
int32_t current = sortedConfigIndexes[i];
|
int32_t current = sortedConfigIndexes[i];
|
||||||
@ -3199,16 +3225,19 @@ void Clay__RenderDebugView() {
|
|||||||
Clay_TextElementConfig *infoTitleConfig = CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE });
|
Clay_TextElementConfig *infoTitleConfig = CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE });
|
||||||
Clay_ElementId scrollId = Clay__HashString(CLAY_STRING("Clay__DebugViewOuterScrollPane"), 0, 0);
|
Clay_ElementId scrollId = Clay__HashString(CLAY_STRING("Clay__DebugViewOuterScrollPane"), 0, 0);
|
||||||
float scrollYOffset = 0;
|
float scrollYOffset = 0;
|
||||||
|
bool pointerInDebugView = context->pointerInfo.position.y < context->layoutDimensions.height - 300;
|
||||||
for (int32_t i = 0; i < context->scrollContainerDatas.length; ++i) {
|
for (int32_t i = 0; i < context->scrollContainerDatas.length; ++i) {
|
||||||
Clay__ScrollContainerDataInternal *scrollContainerData = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
|
Clay__ScrollContainerDataInternal *scrollContainerData = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
|
||||||
if (scrollContainerData->elementId == scrollId.id) {
|
if (scrollContainerData->elementId == scrollId.id) {
|
||||||
if (!context->externalScrollHandlingEnabled) {
|
if (!context->externalScrollHandlingEnabled) {
|
||||||
scrollYOffset = scrollContainerData->scrollPosition.y;
|
scrollYOffset = scrollContainerData->scrollPosition.y;
|
||||||
|
} else {
|
||||||
|
pointerInDebugView = context->pointerInfo.position.y + scrollContainerData->scrollPosition.y < context->layoutDimensions.height - 300;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t highlightedRow = context->pointerInfo.position.y < context->layoutDimensions.height - 300
|
int32_t highlightedRow = pointerInDebugView
|
||||||
? (int32_t)((context->pointerInfo.position.y - scrollYOffset) / (float)CLAY__DEBUGVIEW_ROW_HEIGHT) - 1
|
? (int32_t)((context->pointerInfo.position.y - scrollYOffset) / (float)CLAY__DEBUGVIEW_ROW_HEIGHT) - 1
|
||||||
: -1;
|
: -1;
|
||||||
if (context->pointerInfo.position.x < context->layoutDimensions.width - (float)Clay__debugViewWidth) {
|
if (context->pointerInfo.position.x < context->layoutDimensions.width - (float)Clay__debugViewWidth) {
|
||||||
@ -3216,13 +3245,13 @@ void Clay__RenderDebugView() {
|
|||||||
}
|
}
|
||||||
Clay__RenderDebugLayoutData layoutData = CLAY__DEFAULT_STRUCT;
|
Clay__RenderDebugLayoutData layoutData = CLAY__DEFAULT_STRUCT;
|
||||||
CLAY(CLAY_ID("Clay__DebugView"),
|
CLAY(CLAY_ID("Clay__DebugView"),
|
||||||
CLAY_FLOATING({ .parentId = Clay__HashString(CLAY_STRING("Clay__RootContainer"), 0, 0).id, .attachment = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_CENTER }}),
|
CLAY_FLOATING({ .zIndex = 65000, .parentId = Clay__HashString(CLAY_STRING("Clay__RootContainer"), 0, 0).id, .attachment = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_CENTER }}),
|
||||||
CLAY_LAYOUT({ .sizing = { CLAY_SIZING_FIXED((float)Clay__debugViewWidth) , CLAY_SIZING_FIXED(context->layoutDimensions.height) }, .layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
CLAY_LAYOUT({ .sizing = { CLAY_SIZING_FIXED((float)Clay__debugViewWidth) , CLAY_SIZING_FIXED(context->layoutDimensions.height) }, .layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
||||||
CLAY_BORDER({ .bottom = { .width = 1, .color = CLAY__DEBUGVIEW_COLOR_3 }})
|
CLAY_BORDER({ .bottom = { .width = 1, .color = CLAY__DEBUGVIEW_COLOR_3 }})
|
||||||
) {
|
) {
|
||||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_2 })) {
|
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_2 })) {
|
||||||
CLAY_TEXT(CLAY_STRING("Clay Debug Tools"), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("Clay Debug Tools"), infoTextConfig);
|
||||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), {0} } })) {}
|
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) } })) {}
|
||||||
// Close button
|
// Close button
|
||||||
CLAY(CLAY_BORDER_OUTSIDE_RADIUS(1, (CLAY__INIT(Clay_Color){217,91,67,255}), 4),
|
CLAY(CLAY_BORDER_OUTSIDE_RADIUS(1, (CLAY__INIT(Clay_Color){217,91,67,255}), 4),
|
||||||
CLAY_LAYOUT({ .sizing = {CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10)}, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER} }),
|
CLAY_LAYOUT({ .sizing = {CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10)}, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER} }),
|
||||||
@ -3237,7 +3266,7 @@ void Clay__RenderDebugView() {
|
|||||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 })) {
|
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 })) {
|
||||||
Clay_ElementId panelContentsId = Clay__HashString(CLAY_STRING("Clay__DebugViewPaneOuter"), 0, 0);
|
Clay_ElementId panelContentsId = Clay__HashString(CLAY_STRING("Clay__DebugViewPaneOuter"), 0, 0);
|
||||||
// Element list
|
// Element list
|
||||||
CLAY(Clay__AttachId(panelContentsId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }), CLAY_FLOATING({ .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH })) {
|
CLAY(Clay__AttachId(panelContentsId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }), CLAY_FLOATING({ .zIndex = 65001, .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH })) {
|
||||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = {.x = CLAY__DEBUGVIEW_OUTER_PADDING }, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = {.x = CLAY__DEBUGVIEW_OUTER_PADDING }, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
||||||
layoutData = Clay__RenderDebugLayoutElementsList((int32_t)initialRootsLength, highlightedRow);
|
layoutData = Clay__RenderDebugLayoutElementsList((int32_t)initialRootsLength, highlightedRow);
|
||||||
}
|
}
|
||||||
@ -3269,7 +3298,7 @@ void Clay__RenderDebugView() {
|
|||||||
) {
|
) {
|
||||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} })) {
|
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} })) {
|
||||||
CLAY_TEXT(CLAY_STRING("Layout Config"), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("Layout Config"), infoTextConfig);
|
||||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), {0} } })) {}
|
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) } })) {}
|
||||||
if (selectedItem->elementId.stringId.length != 0) {
|
if (selectedItem->elementId.stringId.length != 0) {
|
||||||
CLAY_TEXT(selectedItem->elementId.stringId, infoTitleConfig);
|
CLAY_TEXT(selectedItem->elementId.stringId, infoTitleConfig);
|
||||||
if (selectedItem->elementId.offset != 0) {
|
if (selectedItem->elementId.offset != 0) {
|
||||||
@ -3402,7 +3431,7 @@ void Clay__RenderDebugView() {
|
|||||||
}
|
}
|
||||||
// Image Preview
|
// Image Preview
|
||||||
CLAY_TEXT(CLAY_STRING("Preview"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Preview"), infoTitleConfig);
|
||||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0, imageConfig->sourceDimensions.width), {0} }}), Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .imageElementConfig = imageConfig }, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)) {}
|
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0, imageConfig->sourceDimensions.width) }}), Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .imageElementConfig = imageConfig }, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)) {}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3586,7 +3615,7 @@ uint32_t Clay_MinMemorySize(void) {
|
|||||||
.maxMeasureTextCacheWordCount = Clay__defaultMaxMeasureTextWordCacheCount,
|
.maxMeasureTextCacheWordCount = Clay__defaultMaxMeasureTextWordCacheCount,
|
||||||
.internalArena = {
|
.internalArena = {
|
||||||
.capacity = SIZE_MAX,
|
.capacity = SIZE_MAX,
|
||||||
.memory = (char*)&fakeContext,
|
.memory = NULL,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Clay_Context* currentContext = Clay_GetCurrentContext();
|
Clay_Context* currentContext = Clay_GetCurrentContext();
|
||||||
|
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
#define CLAY_IMPLEMENTATION
|
#define CLAY_IMPLEMENTATION
|
||||||
#include "../../clay.h"
|
#include "../../clay.h"
|
||||||
#include "../../renderers/raylib/clay_renderer_raylib.c"
|
#define CLAY_RAYLIB_IMPLEMENTATION // This is different to the video, the raylib renderer is now in a header file
|
||||||
|
#include "../../renderers/raylib/clay_renderer_raylib.h"
|
||||||
|
|
||||||
const int FONT_ID_BODY_16 = 0;
|
const int FONT_ID_BODY_16 = 0;
|
||||||
Clay_Color COLOR_WHITE = { 255, 255, 255, 255};
|
Clay_Color COLOR_WHITE = { 255, 255, 255, 255};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#define CLAY_IMPLEMENTATION
|
#define CLAY_IMPLEMENTATION
|
||||||
#include "../../clay.h"
|
#include "../../clay.h"
|
||||||
#include "../../renderers/raylib/clay_renderer_raylib.c"
|
#define CLAY_RAYLIB_IMPLEMENTATION
|
||||||
|
#include "../../renderers/raylib/clay_renderer_raylib.h"
|
||||||
|
|
||||||
const uint32_t FONT_ID_BODY_24 = 0;
|
const uint32_t FONT_ID_BODY_24 = 0;
|
||||||
const uint32_t FONT_ID_BODY_16 = 1;
|
const uint32_t FONT_ID_BODY_16 = 1;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef CLAY_RENDERER_RAYLIB_H
|
||||||
|
#define CLAY_RENDERER_RAYLIB_H
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
@ -14,8 +17,6 @@ typedef struct
|
|||||||
Font font;
|
Font font;
|
||||||
} Raylib_Font;
|
} Raylib_Font;
|
||||||
|
|
||||||
Raylib_Font Raylib_fonts[10];
|
|
||||||
Camera Raylib_camera;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -38,6 +39,14 @@ typedef struct
|
|||||||
};
|
};
|
||||||
} CustomLayoutElement;
|
} CustomLayoutElement;
|
||||||
|
|
||||||
|
#ifdef CLAY_RAYLIB_IMPLEMENTATION
|
||||||
|
#undef CLAY_RAYLIB_IMPLEMENTATION
|
||||||
|
|
||||||
|
// Global state
|
||||||
|
Raylib_Font Raylib_fonts[10];
|
||||||
|
Camera Raylib_camera;
|
||||||
|
uint32_t measureCalls = 0;
|
||||||
|
|
||||||
// Get a ray trace from the screen position (i.e mouse) within a specific section of the screen
|
// Get a ray trace from the screen position (i.e mouse) within a specific section of the screen
|
||||||
Ray GetScreenToWorldPointWithZDistance(Vector2 position, Camera camera, int screenWidth, int screenHeight, float zDistance)
|
Ray GetScreenToWorldPointWithZDistance(Vector2 position, Camera camera, int screenWidth, int screenHeight, float zDistance)
|
||||||
{
|
{
|
||||||
@ -87,8 +96,6 @@ Ray GetScreenToWorldPointWithZDistance(Vector2 position, Camera camera, int scre
|
|||||||
return ray;
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t measureCalls = 0;
|
|
||||||
|
|
||||||
static inline Clay_Dimensions Raylib_MeasureText(Clay_String *text, Clay_TextElementConfig *config) {
|
static inline Clay_Dimensions Raylib_MeasureText(Clay_String *text, Clay_TextElementConfig *config) {
|
||||||
measureCalls++;
|
measureCalls++;
|
||||||
// Measure string size for Font
|
// Measure string size for Font
|
||||||
@ -122,6 +129,7 @@ static inline Clay_Dimensions Raylib_MeasureText(Clay_String *text, Clay_TextEle
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Clay_Raylib_Initialize(int width, int height, const char *title, unsigned int flags) {
|
void Clay_Raylib_Initialize(int width, int height, const char *title, unsigned int flags) {
|
||||||
|
measureCalls = 0;
|
||||||
SetConfigFlags(flags);
|
SetConfigFlags(flags);
|
||||||
InitWindow(width, height, title);
|
InitWindow(width, height, title);
|
||||||
// EnableEventWaiting();
|
// EnableEventWaiting();
|
||||||
@ -231,3 +239,6 @@ void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // CLAY_RAYLIB_IMPLEMENTATION
|
||||||
|
#endif // CLAY_RENDERER_RAYLIB_H
|
Loading…
Reference in New Issue
Block a user