mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-20 05:08:04 +00:00
Bulk of functionality
This commit is contained in:
parent
70ba499f75
commit
a79b6a9faf
@ -1422,13 +1422,13 @@ switch (renderCommand->commandType) {
|
|||||||
|
|
||||||
`uint32_t CLAY_ID(char *label)`
|
`uint32_t CLAY_ID(char *label)`
|
||||||
|
|
||||||
Generates a `uint32_t` string hash from the provided `char *label`. Used both to generate ids when defining element macros, as well as for referencing ids later when using utility functions such as [Clay_PointerOver](#clay-pointerover)
|
Generates a `uint32_t` string id from the provided `char *label`. Used both to generate ids when defining element macros, as well as for referencing ids later when using utility functions such as [Clay_PointerOver](#clay-pointerover)
|
||||||
|
|
||||||
### CLAY_IDI()
|
### CLAY_IDI()
|
||||||
|
|
||||||
`uint32_t CLAY_IDI(char *label, int index)`
|
`uint32_t CLAY_IDI(char *label, int index)`
|
||||||
|
|
||||||
Generates a `uint32_t` string hash from the provided `char *label`, combined with the `int index`. Used for generating ids for sequential elements (such as in a `for` loop) without having to construct dynamic strings at runtime.
|
Generates a `uint32_t` string id from the provided `char *label`, combined with the `int index`. Used for generating ids for sequential elements (such as in a `for` loop) without having to construct dynamic strings at runtime.
|
||||||
|
|
||||||
## Data Structures & Definitions
|
## Data Structures & Definitions
|
||||||
|
|
||||||
|
@ -57,6 +57,13 @@ BorderData :: struct {
|
|||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ElementId :: struct {
|
||||||
|
id: u32,
|
||||||
|
offset: u32,
|
||||||
|
baseId: u32,
|
||||||
|
stringId: String,
|
||||||
|
}
|
||||||
|
|
||||||
when ODIN_OS == .Windows {
|
when ODIN_OS == .Windows {
|
||||||
EnumBackingType :: u32
|
EnumBackingType :: u32
|
||||||
} else {
|
} else {
|
||||||
@ -234,13 +241,13 @@ ClayArray :: struct($type: typeid) {
|
|||||||
foreign Clay {
|
foreign Clay {
|
||||||
MinMemorySize :: proc() -> u32 ---
|
MinMemorySize :: proc() -> u32 ---
|
||||||
CreateArenaWithCapacityAndMemory :: proc(capacity: u32, offset: [^]u8) -> Arena ---
|
CreateArenaWithCapacityAndMemory :: proc(capacity: u32, offset: [^]u8) -> Arena ---
|
||||||
SetPointerPosition :: proc(position: Vector2) ---
|
SetPointerState :: proc(position: Vector2, pointerDown: bool) ---
|
||||||
Initialize :: proc(arena: Arena) ---
|
Initialize :: proc(arena: Arena) ---
|
||||||
UpdateScrollContainers :: proc(isPointerActive: bool, scrollDelta: Vector2, deltaTime: c.float) ---
|
UpdateScrollContainers :: proc(isPointerActive: bool, scrollDelta: Vector2, deltaTime: c.float) ---
|
||||||
BeginLayout :: proc(screenWidth: c.int, screenHeight: c.int) ---
|
BeginLayout :: proc(screenWidth: c.int, screenHeight: c.int) ---
|
||||||
EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> ClayArray(RenderCommand) ---
|
EndLayout :: proc(screenWidth: c.int, screenHeight: c.int) -> ClayArray(RenderCommand) ---
|
||||||
PointerOver :: proc(id: u32) -> bool ---
|
PointerOver :: proc(id: ElementId) -> bool ---
|
||||||
GetScrollContainerData :: proc(id: u32) -> ScrollContainerData ---
|
GetScrollContainerData :: proc(id: ElementId) -> ScrollContainerData ---
|
||||||
SetMeasureTextFunction :: proc(measureTextFunction: proc "c" (text: ^String, config: ^TextElementConfig) -> Dimensions) ---
|
SetMeasureTextFunction :: proc(measureTextFunction: proc "c" (text: ^String, config: ^TextElementConfig) -> Dimensions) ---
|
||||||
RenderCommandArray_Get :: proc(array: ^ClayArray(RenderCommand), index: i32) -> ^RenderCommand ---
|
RenderCommandArray_Get :: proc(array: ^ClayArray(RenderCommand), index: i32) -> ^RenderCommand ---
|
||||||
}
|
}
|
||||||
@ -259,14 +266,14 @@ foreign _ {
|
|||||||
|
|
||||||
@(link_prefix = "Clay_", default_calling_convention = "c", private)
|
@(link_prefix = "Clay_", default_calling_convention = "c", private)
|
||||||
foreign Clay {
|
foreign Clay {
|
||||||
_OpenContainerElement :: proc(id: u32, layoutConfig: ^LayoutConfig) ---
|
_OpenContainerElement :: proc(id: ElementId, layoutConfig: ^LayoutConfig) ---
|
||||||
_OpenRectangleElement :: proc(id: u32, layoutConfig: ^LayoutConfig, rectangleConfig: ^RectangleElementConfig) ---
|
_OpenRectangleElement :: proc(id: ElementId, layoutConfig: ^LayoutConfig, rectangleConfig: ^RectangleElementConfig) ---
|
||||||
_OpenTextElement :: proc(id: u32, text: String, textConfig: ^TextElementConfig) ---
|
_OpenTextElement :: proc(id: ElementId, text: String, textConfig: ^TextElementConfig) ---
|
||||||
_OpenImageElement :: proc(id: u32, layoutConfig: ^LayoutConfig, imageConfig: ^ImageElementConfig) ---
|
_OpenImageElement :: proc(id: ElementId, layoutConfig: ^LayoutConfig, imageConfig: ^ImageElementConfig) ---
|
||||||
_OpenScrollElement :: proc(id: u32, layoutConfig: ^LayoutConfig, imageConfig: ^ScrollElementConfig) -> rawptr ---
|
_OpenScrollElement :: proc(id: ElementId, layoutConfig: ^LayoutConfig, imageConfig: ^ScrollElementConfig) ---
|
||||||
_OpenFloatingElement :: proc(id: u32, layoutConfig: ^LayoutConfig, imageConfig: ^FloatingElementConfig) -> rawptr ---
|
_OpenFloatingElement :: proc(id: ElementId, layoutConfig: ^LayoutConfig, imageConfig: ^FloatingElementConfig) ---
|
||||||
_OpenBorderElement :: proc(id: u32, layoutConfig: ^LayoutConfig, imageConfig: ^BorderElementConfig) ---
|
_OpenBorderElement :: proc(id: ElementId, layoutConfig: ^LayoutConfig, imageConfig: ^BorderElementConfig) ---
|
||||||
_OpenCustomElement :: proc(id: u32, layoutConfig: ^LayoutConfig, imageConfig: ^CustomElementConfig) ---
|
_OpenCustomElement :: proc(id: ElementId, layoutConfig: ^LayoutConfig, imageConfig: ^CustomElementConfig) ---
|
||||||
_CloseElementWithChildren :: proc() ---
|
_CloseElementWithChildren :: proc() ---
|
||||||
_CloseScrollElement :: proc() ---
|
_CloseScrollElement :: proc() ---
|
||||||
_CloseFloatingElement :: proc() ---
|
_CloseFloatingElement :: proc() ---
|
||||||
@ -278,52 +285,52 @@ foreign Clay {
|
|||||||
_CustomElementConfigArray_Add :: proc(array: ^ClayArray(CustomElementConfig), config: CustomElementConfig) -> ^CustomElementConfig ---
|
_CustomElementConfigArray_Add :: proc(array: ^ClayArray(CustomElementConfig), config: CustomElementConfig) -> ^CustomElementConfig ---
|
||||||
_ScrollElementConfigArray_Add :: proc(array: ^ClayArray(ScrollElementConfig), config: ScrollElementConfig) -> ^ScrollElementConfig ---
|
_ScrollElementConfigArray_Add :: proc(array: ^ClayArray(ScrollElementConfig), config: ScrollElementConfig) -> ^ScrollElementConfig ---
|
||||||
_BorderElementConfigArray_Add :: proc(array: ^ClayArray(BorderElementConfig), config: BorderElementConfig) -> ^BorderElementConfig ---
|
_BorderElementConfigArray_Add :: proc(array: ^ClayArray(BorderElementConfig), config: BorderElementConfig) -> ^BorderElementConfig ---
|
||||||
_HashString :: proc(toHash: String, index: u32) -> u32 ---
|
_HashString :: proc(toHash: String, index: u32) -> ElementId ---
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results, deferred_none = _CloseElementWithChildren)
|
@(require_results, deferred_none = _CloseElementWithChildren)
|
||||||
Container :: proc(id: u32, layoutConfig: ^LayoutConfig) -> bool {
|
Container :: proc(id: ElementId, layoutConfig: ^LayoutConfig) -> bool {
|
||||||
_OpenContainerElement(id, layoutConfig)
|
_OpenContainerElement(id, layoutConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results, deferred_none = _CloseElementWithChildren)
|
@(require_results, deferred_none = _CloseElementWithChildren)
|
||||||
Rectangle :: proc(id: u32, layoutConfig: ^LayoutConfig, rectangleConfig: ^RectangleElementConfig) -> bool {
|
Rectangle :: proc(id: ElementId, layoutConfig: ^LayoutConfig, rectangleConfig: ^RectangleElementConfig) -> bool {
|
||||||
_OpenRectangleElement(id, layoutConfig, rectangleConfig)
|
_OpenRectangleElement(id, layoutConfig, rectangleConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
Text :: proc(id: u32, text: string, textConfig: ^TextElementConfig) -> bool {
|
Text :: proc(id: ElementId, text: string, textConfig: ^TextElementConfig) -> bool {
|
||||||
_OpenTextElement(id, MakeString(text), textConfig)
|
_OpenTextElement(id, MakeString(text), textConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results, deferred_none = _CloseElementWithChildren)
|
@(require_results, deferred_none = _CloseElementWithChildren)
|
||||||
Image :: proc(id: u32, layoutConfig: ^LayoutConfig, imageConfig: ^ImageElementConfig) -> bool {
|
Image :: proc(id: ElementId, layoutConfig: ^LayoutConfig, imageConfig: ^ImageElementConfig) -> bool {
|
||||||
_OpenImageElement(id, layoutConfig, imageConfig)
|
_OpenImageElement(id, layoutConfig, imageConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results, deferred_none = _CloseScrollElement)
|
@(require_results, deferred_none = _CloseScrollElement)
|
||||||
Scroll :: proc(id: u32, layoutConfig: ^LayoutConfig, scrollConfig: ^ScrollElementConfig) -> bool {
|
Scroll :: proc(id: ElementId, layoutConfig: ^LayoutConfig, scrollConfig: ^ScrollElementConfig) -> bool {
|
||||||
_OpenScrollElement(id, layoutConfig, scrollConfig)
|
_OpenScrollElement(id, layoutConfig, scrollConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results, deferred_none = _CloseFloatingElement)
|
@(require_results, deferred_none = _CloseFloatingElement)
|
||||||
Floating :: proc(id: u32, layoutConfig: ^LayoutConfig, floatingConfig: ^FloatingElementConfig) -> bool {
|
Floating :: proc(id: ElementId, layoutConfig: ^LayoutConfig, floatingConfig: ^FloatingElementConfig) -> bool {
|
||||||
_OpenFloatingElement(id, layoutConfig, floatingConfig)
|
_OpenFloatingElement(id, layoutConfig, floatingConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results, deferred_none = _CloseElementWithChildren)
|
@(require_results, deferred_none = _CloseElementWithChildren)
|
||||||
Border :: proc(id: u32, layoutConfig: ^LayoutConfig, borderConfig: ^BorderElementConfig) -> bool {
|
Border :: proc(id: ElementId, layoutConfig: ^LayoutConfig, borderConfig: ^BorderElementConfig) -> bool {
|
||||||
_OpenBorderElement(id, layoutConfig, borderConfig)
|
_OpenBorderElement(id, layoutConfig, borderConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@(require_results, deferred_none = _CloseElementWithChildren)
|
@(require_results, deferred_none = _CloseElementWithChildren)
|
||||||
Custom :: proc(id: u32, layoutConfig: ^LayoutConfig, customConfig: ^CustomElementConfig) -> bool {
|
Custom :: proc(id: ElementId, layoutConfig: ^LayoutConfig, customConfig: ^CustomElementConfig) -> bool {
|
||||||
_OpenCustomElement(id, layoutConfig, customConfig)
|
_OpenCustomElement(id, layoutConfig, customConfig)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -412,6 +419,6 @@ MakeString :: proc(label: string) -> String {
|
|||||||
return String{chars = raw_data(label), length = cast(c.int)len(label)}
|
return String{chars = raw_data(label), length = cast(c.int)len(label)}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID :: proc(label: string, index: u32 = 0) -> u32 {
|
ID :: proc(label: string, index: u32 = 0) -> ElementId {
|
||||||
return _HashString(MakeString(label), index)
|
return _HashString(MakeString(label), index)
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -112,13 +112,15 @@ LandingPageDesktop :: proc() {
|
|||||||
LandingPageMobile :: proc() {
|
LandingPageMobile :: proc() {
|
||||||
if clay.Container(
|
if clay.Container(
|
||||||
clay.ID("LandingPage1Mobile"),
|
clay.ID("LandingPage1Mobile"),
|
||||||
clay.Layout({
|
clay.Layout(
|
||||||
|
{
|
||||||
layoutDirection = .TOP_TO_BOTTOM,
|
layoutDirection = .TOP_TO_BOTTOM,
|
||||||
sizing = {width = clay.SizingGrow({}), height = clay.SizingFit({min = cast(f32)windowHeight - 70})},
|
sizing = {width = clay.SizingGrow({}), height = clay.SizingFit({min = cast(f32)windowHeight - 70})},
|
||||||
childAlignment = {x = .CENTER, y = .CENTER},
|
childAlignment = {x = .CENTER, y = .CENTER},
|
||||||
padding = {16, 32},
|
padding = {16, 32},
|
||||||
childGap = 32,
|
childGap = 32,
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
if clay.Container(clay.ID("LeftText"), clay.Layout({sizing = {width = clay.SizingGrow({})}, layoutDirection = .TOP_TO_BOTTOM, childGap = 8})) {
|
if clay.Container(clay.ID("LeftText"), clay.Layout({sizing = {width = clay.SizingGrow({})}, layoutDirection = .TOP_TO_BOTTOM, childGap = 8})) {
|
||||||
clay.Text(
|
clay.Text(
|
||||||
@ -331,7 +333,7 @@ HighPerformancePageMobile :: proc(lerpValue: f32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererButtonActive :: proc(id: u32, index: i32, text: string) {
|
RendererButtonActive :: proc(id: clay.ElementId, index: i32, text: string) {
|
||||||
if clay.Rectangle(
|
if clay.Rectangle(
|
||||||
id,
|
id,
|
||||||
clay.Layout({sizing = {width = clay.SizingFixed(300)}, padding = {16, 16}}),
|
clay.Layout({sizing = {width = clay.SizingFixed(300)}, padding = {16, 16}}),
|
||||||
@ -341,7 +343,7 @@ RendererButtonActive :: proc(id: u32, index: i32, text: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererButtonInactive :: proc(id: u32, index: u32, text: string) {
|
RendererButtonInactive :: proc(id: clay.ElementId, index: u32, text: string) {
|
||||||
if clay.Border(id, clay.Layout({}), clay.BorderConfigOutsideRadius({2, COLOR_RED}, 10)) {
|
if clay.Border(id, clay.Layout({}), clay.BorderConfigOutsideRadius({2, COLOR_RED}, 10)) {
|
||||||
if clay.Rectangle(
|
if clay.Rectangle(
|
||||||
clay.ID("RendererButtonInactiveInner", index),
|
clay.ID("RendererButtonInactiveInner", index),
|
||||||
@ -377,11 +379,7 @@ RendererPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizing: clay.
|
|||||||
clay.ID("RendererRightText"),
|
clay.ID("RendererRightText"),
|
||||||
clay.Layout({sizing = {width = widthSizing}, childAlignment = {x = .CENTER}, layoutDirection = .TOP_TO_BOTTOM, childGap = 16}),
|
clay.Layout({sizing = {width = widthSizing}, childAlignment = {x = .CENTER}, layoutDirection = .TOP_TO_BOTTOM, childGap = 16}),
|
||||||
) {
|
) {
|
||||||
clay.Text(
|
clay.Text(clay.ID("RendererTextRightTitle"), "Try changing renderer!", clay.TextConfig({fontSize = 36, fontId = FONT_ID_BODY_36, textColor = COLOR_ORANGE}))
|
||||||
clay.ID("RendererTextRightTitle"),
|
|
||||||
"Try changing renderer!",
|
|
||||||
clay.TextConfig({fontSize = 36, fontId = FONT_ID_BODY_36, textColor = COLOR_ORANGE}),
|
|
||||||
)
|
|
||||||
if clay.Container(clay.ID("Spacer"), clay.Layout({sizing = {width = clay.SizingGrow({max = 32})}})) {}
|
if clay.Container(clay.ID("Spacer"), clay.Layout({sizing = {width = clay.SizingGrow({max = 32})}})) {}
|
||||||
RendererButtonActive(clay.ID("RendererSelectButtonActive", 0), 0, "Raylib Renderer")
|
RendererButtonActive(clay.ID("RendererSelectButtonActive", 0), 0, "Raylib Renderer")
|
||||||
}
|
}
|
||||||
@ -405,13 +403,15 @@ RendererPageDesktop :: proc() {
|
|||||||
RendererPageMobile :: proc() {
|
RendererPageMobile :: proc() {
|
||||||
if clay.Rectangle(
|
if clay.Rectangle(
|
||||||
clay.ID("RendererMobile"),
|
clay.ID("RendererMobile"),
|
||||||
clay.Layout({
|
clay.Layout(
|
||||||
|
{
|
||||||
layoutDirection = .TOP_TO_BOTTOM,
|
layoutDirection = .TOP_TO_BOTTOM,
|
||||||
sizing = {clay.SizingGrow({}), clay.SizingFit({min = cast(f32)windowHeight - 50})},
|
sizing = {clay.SizingGrow({}), clay.SizingFit({min = cast(f32)windowHeight - 50})},
|
||||||
childAlignment = {x = .CENTER, y = .CENTER},
|
childAlignment = {x = .CENTER, y = .CENTER},
|
||||||
padding = {x = 16, y = 32},
|
padding = {x = 16, y = 32},
|
||||||
childGap = 32,
|
childGap = 32,
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
clay.RectangleConfig({color = COLOR_LIGHT}),
|
clay.RectangleConfig({color = COLOR_LIGHT}),
|
||||||
) {
|
) {
|
||||||
RendererPage({fontSize = 48, fontId = FONT_ID_TITLE_48, textColor = COLOR_RED}, clay.SizingGrow({}))
|
RendererPage({fontSize = 48, fontId = FONT_ID_TITLE_48, textColor = COLOR_RED}, clay.SizingGrow({}))
|
||||||
@ -450,7 +450,7 @@ createLayout :: proc(lerpValue: f32) -> clay.ClayArray(clay.RenderCommand) {
|
|||||||
clay.Text(clay.ID("LinkDocsText"), "Docs", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
clay.Text(clay.ID("LinkDocsText"), "Docs", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
githubButtonId: u32 = clay.ID("HeaderButtonGithub")
|
githubButtonId: clay.ElementId = clay.ID("HeaderButtonGithub")
|
||||||
if clay.Border(clay.ID("LinkGithubOuter"), clay.Layout({}), clay.BorderConfigOutsideRadius({2, COLOR_RED}, 10)) {
|
if clay.Border(clay.ID("LinkGithubOuter"), clay.Layout({}), clay.BorderConfigOutsideRadius({2, COLOR_RED}, 10)) {
|
||||||
if clay.Rectangle(
|
if clay.Rectangle(
|
||||||
githubButtonId,
|
githubButtonId,
|
||||||
@ -542,7 +542,7 @@ main :: proc() {
|
|||||||
}
|
}
|
||||||
windowWidth = raylib.GetScreenWidth()
|
windowWidth = raylib.GetScreenWidth()
|
||||||
windowHeight = raylib.GetScreenHeight()
|
windowHeight = raylib.GetScreenHeight()
|
||||||
clay.SetPointerPosition(transmute(clay.Vector2)raylib.GetMousePosition())
|
clay.SetPointerState(transmute(clay.Vector2)raylib.GetMousePosition(), raylib.IsMouseButtonDown(raylib.MouseButton.LEFT))
|
||||||
clay.UpdateScrollContainers(false, transmute(clay.Vector2)raylib.GetMouseWheelMoveV(), raylib.GetFrameTime())
|
clay.UpdateScrollContainers(false, transmute(clay.Vector2)raylib.GetMouseWheelMoveV(), raylib.GetFrameTime())
|
||||||
renderCommands: clay.ClayArray(clay.RenderCommand) = createLayout(animationLerpValue < 0 ? (animationLerpValue + 1) : (1 - animationLerpValue))
|
renderCommands: clay.ClayArray(clay.RenderCommand) = createLayout(animationLerpValue < 0 ? (animationLerpValue + 1) : (1 - animationLerpValue))
|
||||||
raylib.BeginDrawing()
|
raylib.BeginDrawing()
|
||||||
|
@ -18,7 +18,6 @@ const Clay_Color COLOR_LIGHT = (Clay_Color) {244, 235, 230, 255};
|
|||||||
Clay_Color COLOR_LIGHT_HOVER = (Clay_Color) {224, 215, 210, 255};
|
Clay_Color COLOR_LIGHT_HOVER = (Clay_Color) {224, 215, 210, 255};
|
||||||
Clay_Color COLOR_BUTTON_HOVER = (Clay_Color) {238, 227, 225, 255};
|
Clay_Color COLOR_BUTTON_HOVER = (Clay_Color) {238, 227, 225, 255};
|
||||||
Clay_Color COLOR_BROWN = (Clay_Color) {61, 26, 5, 255};
|
Clay_Color COLOR_BROWN = (Clay_Color) {61, 26, 5, 255};
|
||||||
//Clay_Color COLOR_RED = (Clay_Color) {252, 67, 27, 255};
|
|
||||||
Clay_Color COLOR_RED = (Clay_Color) {168, 66, 28, 255};
|
Clay_Color COLOR_RED = (Clay_Color) {168, 66, 28, 255};
|
||||||
Clay_Color COLOR_RED_HOVER = (Clay_Color) {148, 46, 8, 255};
|
Clay_Color COLOR_RED_HOVER = (Clay_Color) {148, 46, 8, 255};
|
||||||
Clay_Color COLOR_ORANGE = (Clay_Color) {225, 138, 50, 255};
|
Clay_Color COLOR_ORANGE = (Clay_Color) {225, 138, 50, 255};
|
||||||
|
@ -20,7 +20,7 @@ set(CMAKE_C_STANDARD 99)
|
|||||||
|
|
||||||
add_executable(clay_examples_raylib_sidebar_scrolling_container main.c)
|
add_executable(clay_examples_raylib_sidebar_scrolling_container main.c)
|
||||||
|
|
||||||
target_compile_options(clay_examples_raylib_sidebar_scrolling_container PUBLIC -Wno-initializer-overrides)
|
target_compile_options(clay_examples_raylib_sidebar_scrolling_container PUBLIC -DCLAY_DEBUG)
|
||||||
target_include_directories(clay_examples_raylib_sidebar_scrolling_container PUBLIC .)
|
target_include_directories(clay_examples_raylib_sidebar_scrolling_container PUBLIC .)
|
||||||
|
|
||||||
target_link_libraries(clay_examples_raylib_sidebar_scrolling_container PUBLIC raylib)
|
target_link_libraries(clay_examples_raylib_sidebar_scrolling_container PUBLIC raylib)
|
||||||
|
File diff suppressed because one or more lines are too long
@ -3,7 +3,9 @@ void $NAME$_Set($NAME$ *array, int index, $TYPE$ value) {
|
|||||||
array->internalArray[index] = value;
|
array->internalArray[index] = value;
|
||||||
array->length = index < array->length ? array->length : index + 1;
|
array->length = index < array->length ? array->length : index + 1;
|
||||||
} else {
|
} else {
|
||||||
Clay__StringArray_Add(&Clay_warnings, CLAY_STRING("Attempting to allocate array in arena, but arena is already at capacity and would overflow."));
|
if (Clay__warningsEnabled) {
|
||||||
|
Clay__WarningArray_Add(&Clay_warnings, (Clay__Warning) { CLAY_STRING("Attempting to allocate array in arena, but arena is already at capacity and would overflow.") });
|
||||||
|
}
|
||||||
#ifdef CLAY_OVERFLOW_TRAP
|
#ifdef CLAY_OVERFLOW_TRAP
|
||||||
raise(SIGTRAP);
|
raise(SIGTRAP);
|
||||||
#endif
|
#endif
|
||||||
|
@ -170,7 +170,7 @@ void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands)
|
|||||||
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
|
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
|
||||||
Clay_RectangleElementConfig *config = renderCommand->config.rectangleElementConfig;
|
Clay_RectangleElementConfig *config = renderCommand->config.rectangleElementConfig;
|
||||||
if (config->cornerRadius.topLeft > 0) {
|
if (config->cornerRadius.topLeft > 0) {
|
||||||
float radius = (config->cornerRadius.topLeft * 2) / (boundingBox.width > boundingBox.height) ? boundingBox.height : boundingBox.width;
|
float radius = (config->cornerRadius.topLeft * 2) / (float)((boundingBox.width > boundingBox.height) ? boundingBox.height : boundingBox.width);
|
||||||
DrawRectangleRounded((Rectangle) { boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height }, radius, 8, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRectangleRounded((Rectangle) { boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height }, radius, 8, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
} else {
|
} else {
|
||||||
DrawRectangle(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRectangle(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
Loading…
Reference in New Issue
Block a user