mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-23 14:48:06 +00:00
Compare commits
5 Commits
3f8e1cb642
...
bb3b5ae5ad
Author | SHA1 | Date | |
---|---|---|---|
|
bb3b5ae5ad | ||
|
08e4c5b198 | ||
|
b1c72a0647 | ||
|
aee4baee1c | ||
|
d7e072fe25 |
@ -111,7 +111,6 @@ TextElementConfig :: struct {
|
||||
lineHeight: u16,
|
||||
wrapMode: TextWrapMode,
|
||||
textAlignment: TextAlignment,
|
||||
hashStringContents: bool,
|
||||
}
|
||||
|
||||
ImageElementConfig :: struct {
|
||||
|
7
clay.h
7
clay.h
@ -1670,6 +1670,7 @@ Clay_LayoutElementHashMapItem* Clay__AddHashMapItem(Clay_ElementId elementId, Cl
|
||||
item.nextIndex = hashItem->nextIndex;
|
||||
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->idAlias = idAlias;
|
||||
hashItem->generation = context->generation + 1;
|
||||
hashItem->layoutElement = layoutElement;
|
||||
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
|
||||
int32_t clipElementId = Clay__int32_tArray_GetValue(&context->layoutElementClipElementIds, (int32_t)(currentElement - context->layoutElements.internalArray));
|
||||
Clay_LayoutElementHashMapItem *clipItem = Clay__GetHashMapItem(clipElementId);
|
||||
Clay_BoundingBox elementBox = mapItem->boundingBox;
|
||||
elementBox.x -= root->pointerOffset.x;
|
||||
elementBox.y -= root->pointerOffset.y;
|
||||
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 (mapItem->onHoverFunction) {
|
||||
mapItem->onHoverFunction(mapItem->elementId, context->pointerInfo, mapItem->hoverFunctionUserData);
|
||||
|
@ -99,16 +99,22 @@ static inline Clay_Dimensions Raylib_MeasureText(Clay_StringSlice text, Clay_Tex
|
||||
|
||||
float scaleFactor = config->fontSize/(float)fontToUse.baseSize;
|
||||
|
||||
for (int i = 0; i < text.length; ++i)
|
||||
{
|
||||
if (text.chars[i] == '\n') {
|
||||
int byte_index = 0;
|
||||
while (byte_index < text.length) {
|
||||
if (text.chars[byte_index] == '\n') {
|
||||
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||
lineTextWidth = 0;
|
||||
byte_index++;
|
||||
continue;
|
||||
}
|
||||
int index = text.chars[i] - 32;
|
||||
if (fontToUse.glyphs[index].advanceX != 0) lineTextWidth += fontToUse.glyphs[index].advanceX;
|
||||
else lineTextWidth += (fontToUse.recs[index].width + fontToUse.glyphs[index].offsetX);
|
||||
|
||||
int codepoint_bytes = 0;
|
||||
int codepoint = GetCodepoint(&text.chars[byte_index], &codepoint_bytes);
|
||||
int glyph_index = GetGlyphIndex(fontToUse, codepoint);
|
||||
byte_index += codepoint_bytes;
|
||||
|
||||
if (fontToUse.glyphs[glyph_index].advanceX != 0) lineTextWidth += fontToUse.glyphs[glyph_index].advanceX;
|
||||
else lineTextWidth += (fontToUse.recs[glyph_index].width + fontToUse.glyphs[glyph_index].offsetX);
|
||||
}
|
||||
|
||||
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||
|
Loading…
Reference in New Issue
Block a user