mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-23 14:48:06 +00:00
Compare commits
6 Commits
6f0a44b944
...
d7dc4ca91a
Author | SHA1 | Date | |
---|---|---|---|
|
d7dc4ca91a | ||
|
08e4c5b198 | ||
|
b1c72a0647 | ||
|
aee4baee1c | ||
|
1c636096e5 | ||
|
e5bd453f5e |
@ -111,7 +111,6 @@ TextElementConfig :: struct {
|
|||||||
lineHeight: u16,
|
lineHeight: u16,
|
||||||
wrapMode: TextWrapMode,
|
wrapMode: TextWrapMode,
|
||||||
textAlignment: TextAlignment,
|
textAlignment: TextAlignment,
|
||||||
hashStringContents: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageElementConfig :: struct {
|
ImageElementConfig :: struct {
|
||||||
|
7
clay.h
7
clay.h
@ -1670,6 +1670,7 @@ Clay_LayoutElementHashMapItem* Clay__AddHashMapItem(Clay_ElementId elementId, Cl
|
|||||||
item.nextIndex = hashItem->nextIndex;
|
item.nextIndex = hashItem->nextIndex;
|
||||||
if (hashItem->generation <= context->generation) { // First collision - assume this is the "same" element
|
if (hashItem->generation <= context->generation) { // First collision - assume this is the "same" element
|
||||||
hashItem->elementId = elementId; // Make sure to copy this across. If the stringId reference has changed, we should update the hash item to use the new one.
|
hashItem->elementId = elementId; // Make sure to copy this across. If the stringId reference has changed, we should update the hash item to use the new one.
|
||||||
|
hashItem->idAlias = idAlias;
|
||||||
hashItem->generation = context->generation + 1;
|
hashItem->generation = context->generation + 1;
|
||||||
hashItem->layoutElement = layoutElement;
|
hashItem->layoutElement = layoutElement;
|
||||||
hashItem->debugData->collision = false;
|
hashItem->debugData->collision = false;
|
||||||
@ -3810,10 +3811,10 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
|||||||
Clay_LayoutElementHashMapItem *mapItem = Clay__GetHashMapItem(currentElement->id); // TODO think of a way around this, maybe the fact that it's essentially a binary tree limits the cost, but the worst case is not great
|
Clay_LayoutElementHashMapItem *mapItem = Clay__GetHashMapItem(currentElement->id); // TODO think of a way around this, maybe the fact that it's essentially a binary tree limits the cost, but the worst case is not great
|
||||||
int32_t clipElementId = Clay__int32_tArray_GetValue(&context->layoutElementClipElementIds, (int32_t)(currentElement - context->layoutElements.internalArray));
|
int32_t clipElementId = Clay__int32_tArray_GetValue(&context->layoutElementClipElementIds, (int32_t)(currentElement - context->layoutElements.internalArray));
|
||||||
Clay_LayoutElementHashMapItem *clipItem = Clay__GetHashMapItem(clipElementId);
|
Clay_LayoutElementHashMapItem *clipItem = Clay__GetHashMapItem(clipElementId);
|
||||||
Clay_BoundingBox elementBox = mapItem->boundingBox;
|
|
||||||
elementBox.x -= root->pointerOffset.x;
|
|
||||||
elementBox.y -= root->pointerOffset.y;
|
|
||||||
if (mapItem) {
|
if (mapItem) {
|
||||||
|
Clay_BoundingBox elementBox = mapItem->boundingBox;
|
||||||
|
elementBox.x -= root->pointerOffset.x;
|
||||||
|
elementBox.y -= root->pointerOffset.y;
|
||||||
if ((Clay__PointIsInsideRect(position, elementBox)) && (clipElementId == 0 || (Clay__PointIsInsideRect(position, clipItem->boundingBox)))) {
|
if ((Clay__PointIsInsideRect(position, elementBox)) && (clipElementId == 0 || (Clay__PointIsInsideRect(position, clipItem->boundingBox)))) {
|
||||||
if (mapItem->onHoverFunction) {
|
if (mapItem->onHoverFunction) {
|
||||||
mapItem->onHoverFunction(mapItem->elementId, context->pointerInfo, mapItem->hoverFunctionUserData);
|
mapItem->onHoverFunction(mapItem->elementId, context->pointerInfo, mapItem->hoverFunctionUserData);
|
||||||
|
@ -148,7 +148,7 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
|
|||||||
for (size_t i = 0; i < rcommands->length; i++) {
|
for (size_t i = 0; i < rcommands->length; i++) {
|
||||||
Clay_RenderCommand *rcmd = Clay_RenderCommandArray_Get(rcommands, i);
|
Clay_RenderCommand *rcmd = Clay_RenderCommandArray_Get(rcommands, i);
|
||||||
const Clay_BoundingBox bounding_box = rcmd->boundingBox;
|
const Clay_BoundingBox bounding_box = rcmd->boundingBox;
|
||||||
const SDL_FRect rect = { (int)bounding_box.x, (int)bounding_box.y, (int)bounding_box.width, (int)bounding_box.height };
|
const SDL_FRect rect = { (float)bounding_box.x, (float)bounding_box.y, (float)bounding_box.width, (float)bounding_box.height };
|
||||||
|
|
||||||
switch (rcmd->commandType) {
|
switch (rcmd->commandType) {
|
||||||
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
|
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
|
||||||
@ -184,27 +184,27 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
|
|||||||
if (config->width.left > 0) {
|
if (config->width.left > 0) {
|
||||||
const float starting_y = rect.y + clampedRadii.topLeft;
|
const float starting_y = rect.y + clampedRadii.topLeft;
|
||||||
const float length = rect.h - clampedRadii.topLeft - clampedRadii.bottomLeft;
|
const float length = rect.h - clampedRadii.topLeft - clampedRadii.bottomLeft;
|
||||||
SDL_FRect line = { rect.x, starting_y, config->width.left, length };
|
SDL_FRect line = { rect.x, starting_y, (float)config->width.left, length };
|
||||||
SDL_RenderFillRect(rendererData->renderer, &line);
|
SDL_RenderFillRect(rendererData->renderer, &line);
|
||||||
}
|
}
|
||||||
if (config->width.right > 0) {
|
if (config->width.right > 0) {
|
||||||
const float starting_x = rect.x + rect.w - (float)config->width.right;
|
const float starting_x = rect.x + rect.w - (float)config->width.right;
|
||||||
const float starting_y = rect.y + clampedRadii.topRight;
|
const float starting_y = rect.y + clampedRadii.topRight;
|
||||||
const float length = rect.h - clampedRadii.topRight - clampedRadii.bottomRight;
|
const float length = rect.h - clampedRadii.topRight - clampedRadii.bottomRight;
|
||||||
SDL_FRect line = { starting_x, starting_y, config->width.right, length };
|
SDL_FRect line = { starting_x, starting_y, (float)config->width.right, length };
|
||||||
SDL_RenderFillRect(rendererData->renderer, &line);
|
SDL_RenderFillRect(rendererData->renderer, &line);
|
||||||
}
|
}
|
||||||
if (config->width.top > 0) {
|
if (config->width.top > 0) {
|
||||||
const float starting_x = rect.x + clampedRadii.topLeft;
|
const float starting_x = rect.x + clampedRadii.topLeft;
|
||||||
const float length = rect.w - clampedRadii.topLeft - clampedRadii.topRight;
|
const float length = rect.w - clampedRadii.topLeft - clampedRadii.topRight;
|
||||||
SDL_FRect line = { starting_x, rect.y, length, config->width.top };
|
SDL_FRect line = { starting_x, rect.y, length, (float)config->width.top };
|
||||||
SDL_RenderFillRect(rendererData->renderer, &line);
|
SDL_RenderFillRect(rendererData->renderer, &line);
|
||||||
}
|
}
|
||||||
if (config->width.bottom > 0) {
|
if (config->width.bottom > 0) {
|
||||||
const float starting_x = rect.x + clampedRadii.bottomLeft;
|
const float starting_x = rect.x + clampedRadii.bottomLeft;
|
||||||
const float starting_y = rect.y + rect.h - (float)config->width.bottom;
|
const float starting_y = rect.y + rect.h - (float)config->width.bottom;
|
||||||
const float length = rect.w - clampedRadii.bottomLeft - clampedRadii.bottomRight;
|
const float length = rect.w - clampedRadii.bottomLeft - clampedRadii.bottomRight;
|
||||||
SDL_FRect line = { starting_x, starting_y, length, config->width.bottom };
|
SDL_FRect line = { starting_x, starting_y, length, (float)config->width.bottom };
|
||||||
SDL_SetRenderDrawColor(rendererData->renderer, config->color.r, config->color.g, config->color.b, config->color.a);
|
SDL_SetRenderDrawColor(rendererData->renderer, config->color.r, config->color.g, config->color.b, config->color.a);
|
||||||
SDL_RenderFillRect(rendererData->renderer, &line);
|
SDL_RenderFillRect(rendererData->renderer, &line);
|
||||||
}
|
}
|
||||||
@ -238,10 +238,10 @@ static void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Cla
|
|||||||
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_START: {
|
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_START: {
|
||||||
Clay_BoundingBox boundingBox = rcmd->boundingBox;
|
Clay_BoundingBox boundingBox = rcmd->boundingBox;
|
||||||
currentClippingRectangle = (SDL_Rect) {
|
currentClippingRectangle = (SDL_Rect) {
|
||||||
.x = boundingBox.x,
|
.x = (int)boundingBox.x,
|
||||||
.y = boundingBox.y,
|
.y = (int)boundingBox.y,
|
||||||
.w = boundingBox.width,
|
.w = (int)boundingBox.width,
|
||||||
.h = boundingBox.height,
|
.h = (int)boundingBox.height,
|
||||||
};
|
};
|
||||||
SDL_SetRenderClipRect(rendererData->renderer, ¤tClippingRectangle);
|
SDL_SetRenderClipRect(rendererData->renderer, ¤tClippingRectangle);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user