mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-15 10:48:04 +00:00
Compare commits
3 Commits
983807d001
...
da381445c5
Author | SHA1 | Date | |
---|---|---|---|
|
da381445c5 | ||
|
06167b4f4b | ||
|
d7e072fe25 |
6
clay.h
6
clay.h
@ -4118,11 +4118,15 @@ Clay_ScrollContainerData Clay_GetScrollContainerData(Clay_ElementId id) {
|
||||
for (int32_t i = 0; i < context->scrollContainerDatas.length; ++i) {
|
||||
Clay__ScrollContainerDataInternal *scrollContainerData = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
|
||||
if (scrollContainerData->elementId == id.id) {
|
||||
Clay_ScrollElementConfig *scrollElementConfig = Clay__FindElementConfigWithType(scrollContainerData->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_SCROLL).scrollElementConfig;
|
||||
if (!scrollElementConfig) { // This can happen on the first frame before a scroll container is declared
|
||||
return CLAY__INIT(Clay_ScrollContainerData) CLAY__DEFAULT_STRUCT;
|
||||
}
|
||||
return CLAY__INIT(Clay_ScrollContainerData) {
|
||||
.scrollPosition = &scrollContainerData->scrollPosition,
|
||||
.scrollContainerDimensions = { scrollContainerData->boundingBox.width, scrollContainerData->boundingBox.height },
|
||||
.contentDimensions = scrollContainerData->contentSize,
|
||||
.config = *Clay__FindElementConfigWithType(scrollContainerData->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_SCROLL).scrollElementConfig,
|
||||
.config = *scrollElementConfig,
|
||||
.found = true
|
||||
};
|
||||
}
|
||||
|
@ -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