mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-23 22:58:06 +00:00
Compare commits
8 Commits
3de5ac0685
...
38f36bb22d
Author | SHA1 | Date | |
---|---|---|---|
|
38f36bb22d | ||
|
982ade4cf9 | ||
|
d5af2c3dc0 | ||
|
2677bec854 | ||
|
05ac2810d8 | ||
|
1f8cab8d72 | ||
|
6186596b41 | ||
|
d7e072fe25 |
9
clay.h
9
clay.h
@ -102,6 +102,10 @@
|
||||
|
||||
static uint8_t CLAY__ELEMENT_DEFINITION_LATCH;
|
||||
|
||||
// GCC marks the above CLAY__ELEMENT_DEFINITION_LATCH as an unused variable for files that include clay.h but don't declare any layout
|
||||
// This is to suppress that warning
|
||||
static inline void Clay__SuppressUnusedLatchDefinitionVariableWarning(void) { (void) CLAY__ELEMENT_DEFINITION_LATCH; }
|
||||
|
||||
// Publicly visible layout element macros -----------------------------------------------------
|
||||
|
||||
/* This macro looks scary on the surface, but is actually quite simple.
|
||||
@ -1654,6 +1658,8 @@ void Clay__CloseElement(void) {
|
||||
elementHasScrollVertical = config->config.scrollElementConfig->vertical;
|
||||
context->openClipElementStack.length--;
|
||||
break;
|
||||
} else if (config->type == CLAY__ELEMENT_CONFIG_TYPE_FLOATING) {
|
||||
context->openClipElementStack.length--;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1933,6 +1939,9 @@ void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *declaration) {
|
||||
if (!openLayoutElementId.id) {
|
||||
openLayoutElementId = Clay__HashString(CLAY_STRING("Clay__FloatingContainer"), context->layoutElementTreeRoots.length, 0);
|
||||
}
|
||||
int32_t currentElementIndex = Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 1);
|
||||
Clay__int32_tArray_Set(&context->layoutElementClipElementIds, currentElementIndex, clipElementId);
|
||||
Clay__int32_tArray_Add(&context->openClipElementStack, clipElementId);
|
||||
Clay__LayoutElementTreeRootArray_Add(&context->layoutElementTreeRoots, CLAY__INIT(Clay__LayoutElementTreeRoot) {
|
||||
.layoutElementIndex = Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 1),
|
||||
.parentId = floatingConfig.parentId,
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <SDL_ttf.h>
|
||||
#include <SDL_image.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159
|
||||
|
@ -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