mirror of
https://github.com/nicbarker/clay.git
synced 2025-05-17 15:58:05 +00:00
Compare commits
6 Commits
556c0fde9f
...
82543475b9
Author | SHA1 | Date | |
---|---|---|---|
|
82543475b9 | ||
|
19a27b39f2 | ||
|
22e8cc318c | ||
|
8e6640f7a2 | ||
|
1c1be9ac97 | ||
|
829cb3fca7 |
@ -102,6 +102,7 @@ TextAlignment :: enum EnumBackingType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextElementConfig :: struct {
|
TextElementConfig :: struct {
|
||||||
|
userData: rawptr,
|
||||||
textColor: Color,
|
textColor: Color,
|
||||||
fontId: u16,
|
fontId: u16,
|
||||||
fontSize: u16,
|
fontSize: u16,
|
||||||
@ -366,6 +367,8 @@ Context :: struct {} // opaque structure, only use as a pointer
|
|||||||
|
|
||||||
@(link_prefix = "Clay_", default_calling_convention = "c")
|
@(link_prefix = "Clay_", default_calling_convention = "c")
|
||||||
foreign Clay {
|
foreign Clay {
|
||||||
|
_OpenElement :: proc() ---
|
||||||
|
_CloseElement :: proc() ---
|
||||||
MinMemorySize :: proc() -> u32 ---
|
MinMemorySize :: proc() -> u32 ---
|
||||||
CreateArenaWithCapacityAndMemory :: proc(capacity: c.size_t, offset: [^]u8) -> Arena ---
|
CreateArenaWithCapacityAndMemory :: proc(capacity: c.size_t, offset: [^]u8) -> Arena ---
|
||||||
SetPointerState :: proc(position: Vector2, pointerDown: bool) ---
|
SetPointerState :: proc(position: Vector2, pointerDown: bool) ---
|
||||||
@ -398,9 +401,7 @@ foreign Clay {
|
|||||||
|
|
||||||
@(link_prefix = "Clay_", default_calling_convention = "c", private)
|
@(link_prefix = "Clay_", default_calling_convention = "c", private)
|
||||||
foreign Clay {
|
foreign Clay {
|
||||||
_OpenElement :: proc() ---
|
|
||||||
_ConfigureOpenElement :: proc(config: ElementDeclaration) ---
|
_ConfigureOpenElement :: proc(config: ElementDeclaration) ---
|
||||||
_CloseElement :: proc() ---
|
|
||||||
_HashString :: proc(key: String, offset: u32, seed: u32) -> ElementId ---
|
_HashString :: proc(key: String, offset: u32, seed: u32) -> ElementId ---
|
||||||
_OpenTextElement :: proc(text: String, textConfig: ^TextElementConfig) ---
|
_OpenTextElement :: proc(text: String, textConfig: ^TextElementConfig) ---
|
||||||
_StoreTextElementConfig :: proc(config: TextElementConfig) -> ^TextElementConfig ---
|
_StoreTextElementConfig :: proc(config: TextElementConfig) -> ^TextElementConfig ---
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -489,7 +489,7 @@ errorHandler :: proc "c" (errorData: clay.ErrorData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
minMemorySize: u32 = clay.MinMemorySize()
|
minMemorySize: c.size_t = cast(c.size_t)clay.MinMemorySize()
|
||||||
memory := make([^]u8, minMemorySize)
|
memory := make([^]u8, minMemorySize)
|
||||||
arena: clay.Arena = clay.CreateArenaWithCapacityAndMemory(minMemorySize, memory)
|
arena: clay.Arena = clay.CreateArenaWithCapacityAndMemory(minMemorySize, memory)
|
||||||
clay.Initialize(arena, {cast(f32)raylib.GetScreenWidth(), cast(f32)raylib.GetScreenHeight()}, { handler = errorHandler })
|
clay.Initialize(arena, {cast(f32)raylib.GetScreenWidth(), cast(f32)raylib.GetScreenHeight()}, { handler = errorHandler })
|
||||||
|
6
clay.h
6
clay.h
@ -357,6 +357,8 @@ typedef CLAY_PACKED_ENUM {
|
|||||||
|
|
||||||
// Controls various functionality related to text elements.
|
// Controls various functionality related to text elements.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
// A pointer that will be transparently passed through to the resulting render command.
|
||||||
|
void *userData;
|
||||||
// The RGBA color of the font to render, conventionally specified as 0-255.
|
// The RGBA color of the font to render, conventionally specified as 0-255.
|
||||||
Clay_Color textColor;
|
Clay_Color textColor;
|
||||||
// An integer transparently passed to Clay_MeasureText to identify the font to use.
|
// An integer transparently passed to Clay_MeasureText to identify the font to use.
|
||||||
@ -1769,7 +1771,7 @@ bool Clay__MemCmp(const char *s1, const char *s2, int32_t length);
|
|||||||
uint8x16_t v2 = vld1q_u8((const uint8_t *)s2);
|
uint8x16_t v2 = vld1q_u8((const uint8_t *)s2);
|
||||||
|
|
||||||
// Compare vectors
|
// Compare vectors
|
||||||
if (vminvq_u32(vceqq_u8(v1, v2)) != 0xFFFFFFFF) { // If there's a difference
|
if (vminvq_u32(vreinterpretq_u32_u8(vceqq_u8(v1, v2))) != 0xFFFFFFFF) { // If there's a difference
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2692,7 +2694,7 @@ void Clay__CalculateFinalLayout(void) {
|
|||||||
.letterSpacing = textElementConfig->letterSpacing,
|
.letterSpacing = textElementConfig->letterSpacing,
|
||||||
.lineHeight = textElementConfig->lineHeight,
|
.lineHeight = textElementConfig->lineHeight,
|
||||||
}},
|
}},
|
||||||
.userData = sharedConfig->userData,
|
.userData = textElementConfig->userData,
|
||||||
.id = Clay__HashNumber(lineIndex, currentElement->id).id,
|
.id = Clay__HashNumber(lineIndex, currentElement->id).id,
|
||||||
.zIndex = root->zIndex,
|
.zIndex = root->zIndex,
|
||||||
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT,
|
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT,
|
||||||
|
@ -119,6 +119,7 @@
|
|||||||
{name: 'bottomRight', type: 'float'},
|
{name: 'bottomRight', type: 'float'},
|
||||||
]};
|
]};
|
||||||
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
||||||
|
{ name: 'userData', type: 'uint32_t' },
|
||||||
{ name: 'textColor', ...colorDefinition },
|
{ name: 'textColor', ...colorDefinition },
|
||||||
{ name: 'fontId', type: 'uint16_t' },
|
{ name: 'fontId', type: 'uint16_t' },
|
||||||
{ name: 'fontSize', type: 'uint16_t' },
|
{ name: 'fontSize', type: 'uint16_t' },
|
||||||
|
Binary file not shown.
@ -119,6 +119,7 @@
|
|||||||
{name: 'bottomRight', type: 'float'},
|
{name: 'bottomRight', type: 'float'},
|
||||||
]};
|
]};
|
||||||
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
||||||
|
{ name: 'userData', type: 'uint32_t' },
|
||||||
{ name: 'textColor', ...colorDefinition },
|
{ name: 'textColor', ...colorDefinition },
|
||||||
{ name: 'fontId', type: 'uint16_t' },
|
{ name: 'fontId', type: 'uint16_t' },
|
||||||
{ name: 'fontSize', type: 'uint16_t' },
|
{ name: 'fontSize', type: 'uint16_t' },
|
||||||
|
Loading…
Reference in New Issue
Block a user