mirror of
https://github.com/nicbarker/clay.git
synced 2025-05-03 17:08:06 +00:00
Compare commits
26 Commits
c39a3d0243
...
25135d26ed
Author | SHA1 | Date | |
---|---|---|---|
|
25135d26ed | ||
|
44fb89c8b6 | ||
|
bc9ef8b02d | ||
|
0989aeee06 | ||
|
e11a394c25 | ||
|
670f707997 | ||
|
b4452d080c | ||
|
be99977da6 | ||
|
f950d317c9 | ||
|
c44d6b9309 | ||
|
2cfab84034 | ||
|
31bf0ad2dd | ||
|
f8b13b5978 | ||
|
9bc743fd12 | ||
|
672927d387 | ||
|
b7e1d69ca6 | ||
|
e9522005db | ||
|
409bf1c3bf | ||
|
f0fec168a2 | ||
|
bc31e8d332 | ||
|
697adce4a9 | ||
|
1936afd184 | ||
|
678bcf2ad0 | ||
|
11e3f91220 | ||
|
eb1ee390bb | ||
|
4699018599 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,8 @@
|
||||
cmake-build-debug/
|
||||
cmake-build-release/
|
||||
build/
|
||||
.DS_Store
|
||||
.idea/
|
||||
node_modules/
|
||||
*.dSYM
|
||||
.vs/
|
@ -4,13 +4,11 @@ project(clay)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
add_subdirectory("examples/cpp-project-example")
|
||||
|
||||
# Don't try to compile C99 projects using MSVC
|
||||
if(NOT MSVC)
|
||||
add_subdirectory("examples/raylib-sidebar-scrolling-container")
|
||||
add_subdirectory("examples/raylib-multi-context")
|
||||
add_subdirectory("examples/raylib-sidebar-scrolling-container")
|
||||
# add_subdirectory("examples/cairo-pdf-rendering") Some issue with github actions populating cairo, disable for now
|
||||
if(NOT MSVC)
|
||||
add_subdirectory("examples/clay-official-website")
|
||||
endif()
|
||||
add_subdirectory("examples/introducing-clay-video-demo")
|
||||
add_subdirectory("examples/SDL2-video-demo")
|
||||
endif()
|
||||
|
141
README.md
141
README.md
@ -81,7 +81,7 @@ const Clay_Color COLOR_ORANGE = (Clay_Color) {225, 138, 50, 255};
|
||||
|
||||
// Layout config is just a struct that can be declared statically, or inline
|
||||
Clay_LayoutConfig sidebarItemLayout = (Clay_LayoutConfig) {
|
||||
.sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(50) },
|
||||
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) },
|
||||
};
|
||||
|
||||
// Re-useable components are just normal functions
|
||||
@ -94,12 +94,12 @@ Clay_RenderCommandArray CreateLayout() {
|
||||
Clay_BeginLayout();
|
||||
|
||||
// An example of laying out a UI with a fixed width sidebar and flexible width main content
|
||||
CLAY(CLAY_ID("OuterContainer"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(), CLAY_SIZING_GROW()}, .padding = {16, 16}, .childGap = 16 }), CLAY_RECTANGLE({ .color = {250,250,255,255} })) {
|
||||
CLAY(CLAY_ID("OuterContainer"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = {16, 16}, .childGap = 16 }), CLAY_RECTANGLE({ .color = {250,250,255,255} })) {
|
||||
CLAY(CLAY_ID("SideBar"),
|
||||
CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW() }, .padding = {16, 16}, .childGap = 16 }),
|
||||
CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = {16, 16}, .childGap = 16 }),
|
||||
CLAY_RECTANGLE({ .color = COLOR_LIGHT })
|
||||
) {
|
||||
CLAY(CLAY_ID("ProfilePictureOuter"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW() }, .padding = {16, 16}, .childGap = 16, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("ProfilePictureOuter"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = {16, 16}, .childGap = 16, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("ProfilePicture"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}), CLAY_IMAGE({ .imageData = &profilePicture, .sourceDimensions = {60, 60} })) {}
|
||||
CLAY_TEXT(CLAY_STRING("Clay - UI Library"), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {255, 255, 255, 255} }));
|
||||
}
|
||||
@ -110,7 +110,7 @@ Clay_RenderCommandArray CreateLayout() {
|
||||
}
|
||||
}
|
||||
|
||||
CLAY(CLAY_ID("MainContent"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_GROW() }}), CLAY_RECTANGLE({ .color = COLOR_LIGHT })) {}
|
||||
CLAY(CLAY_ID("MainContent"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) }}), CLAY_RECTANGLE({ .color = COLOR_LIGHT })) {}
|
||||
}
|
||||
// ...
|
||||
});
|
||||
@ -151,6 +151,62 @@ In summary, the general order of steps is:
|
||||
|
||||
For help starting out or to discuss clay, considering joining [the discord server.](https://discord.gg/b4FTWkxdvT)
|
||||
|
||||
## Summary
|
||||
|
||||
- [High Level Documentation](#high-level-documentation)
|
||||
- [Building UI Hierarchies](#building-ui-hierarchies)
|
||||
- [Configuring Layout and Styling UI Elements](#configuring-layout-and-styling-ui-elements)
|
||||
- [Element IDs](#element-ids)
|
||||
- [Mouse, Touch and Pointer Interactions](#mouse-touch-and-pointer-interactions)
|
||||
- [Scrolling Elements](#scrolling-elements)
|
||||
- [Floating Elements](#floating-elements-absolute-positioning)
|
||||
- [Custom Elements](#laying-out-your-own-custom-elements)
|
||||
- [Retained Mode Rendering](#retained-mode-rendering)
|
||||
- [Visibility Culling](#visibility-culling)
|
||||
- [Preprocessor Directives](#preprocessor-directives)
|
||||
- [Bindings](#bindings-for-non-c)
|
||||
- [Debug Tools](#debug-tools)
|
||||
- [API](#api)
|
||||
- [Naming Conventions](#naming-conventions)
|
||||
- [Public Functions](#public-functions)
|
||||
- [Lifecycle](#lifecycle-for-public-functions)
|
||||
- [Clay_MinMemorySize](#clay_minmemorysize)
|
||||
- [Clay_CreateArenaWithCapacityAndMemory](#clay_createarenawithcapacityandmemory)
|
||||
- [Clay_SetMeasureTextFunction](#clay_setmeasuretextfunction)
|
||||
- [Clay_SetMaxElementCount](clay_setmaxelementcount)
|
||||
- [Clay_SetMaxMeasureTextCacheWordCount](#clay_setmaxmeasuretextcachewordcount)
|
||||
- [Clay_Initialize](#clay_initialize)
|
||||
- [Clay_SetLayoutDimensions](#clay_setlayoutdimensions)
|
||||
- [Clay_SetPointerState](#clay_setpointerstate)
|
||||
- [Clay_UpdateScrollContainers](#clay_updatescrollcontainers)
|
||||
- [Clay_BeginLayout](#clay_beginlayout)
|
||||
- [Clay_EndLayout](#clay_endlayout)
|
||||
- [Clay_Hovered](#clay_hovered)
|
||||
- [Clay_OnHover](#clay_onhover)
|
||||
- [Clay_PointerOver](#clay_pointerover)
|
||||
- [Clay_GetScrollContainerData](#clay_getscrollcontainerdata)
|
||||
- [Clay_GetElementId](#clay_getelementid)
|
||||
- [Element Macros](#element-macros)
|
||||
- [CLAY](#clay-1)
|
||||
- [CLAY_ID](#clay_id)
|
||||
- [CLAY_IDI](#clay_idi)
|
||||
- [CLAY_LAYOUT](#clay_layout)
|
||||
- [CLAY_RECTANGLE](#clay_rectangle)
|
||||
- [CLAY_TEXT](#clay_text)
|
||||
- [CLAY_IMAGE](#clay_image)
|
||||
- [CLAY_SCROLL](#clay_scroll)
|
||||
- [CLAY_BORDER](#clay_border)
|
||||
- [CLAY_FLOATING](#clay_floating)
|
||||
- [CLAY_CUSTOM_ELEMENT](#clay_custom_element)
|
||||
- [Data Structures & Defs](data-structures--definitions)
|
||||
- [Clay_String](#clay_string)
|
||||
- [Clay_ElementId](#clay_elementid)
|
||||
- [Clay_RenderCommandArray](#clay_rendercommandarray)
|
||||
- [Clay_RenderCommand](#clay_rendercommand)
|
||||
- [Clay_ScrollContainerData](#clay_scrollcontainerdata)
|
||||
- [Clay_ErrorHandler](#clay_errorhandler)
|
||||
- [Clay_ErrorData](#clay_errordata)
|
||||
|
||||
## High Level Documentation
|
||||
|
||||
### Building UI Hierarchies
|
||||
@ -187,7 +243,7 @@ CLAY(CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
||||
}
|
||||
// Only render this element if we're on a mobile screen
|
||||
if (isMobileScreen) {
|
||||
CLAY() {
|
||||
CLAY(0) {
|
||||
// etc
|
||||
}
|
||||
}
|
||||
@ -362,7 +418,7 @@ typedef struct t_CustomElementData {
|
||||
Model myModel = Load3DModel(filePath);
|
||||
CustomElement modelElement = (CustomElement) { .type = CUSTOM_ELEMENT_TYPE_MODEL, .model = myModel }
|
||||
// ...
|
||||
CLAY() {
|
||||
CLAY(0) {
|
||||
// This config is type safe and contains the CustomElementData struct
|
||||
CLAY(CLAY_CUSTOM_ELEMENT({ .customData = { .type = CUSTOM_ELEMENT_TYPE_MODEL, .model = myModel } })) {}
|
||||
}
|
||||
@ -425,8 +481,7 @@ Clay is usable out of the box as a `.h` include in both C99 and C++20 with desig
|
||||
There are also supported bindings for other languages, including:
|
||||
|
||||
- [Odin Bindings](https://github.com/nicbarker/clay/tree/main/bindings/odin)
|
||||
|
||||
Unfortunately clay does **not** support Microsoft C11 or C17 via MSVC at this time.
|
||||
- [Rust Bindings](https://github.com/clay-ui-rs/clay)
|
||||
|
||||
### Debug Tools
|
||||
|
||||
@ -490,18 +545,24 @@ render(renderCommands2);
|
||||
**Each Frame**
|
||||
`Clay_SetLayoutDimensions` -> `Clay_SetPointerState` -> `Clay_UpdateScrollContainers` -> `Clay_BeginLayout` -> `CLAY() etc...` -> `Clay_EndLayout`
|
||||
|
||||
---
|
||||
|
||||
### Clay_MinMemorySize
|
||||
|
||||
`uint32_t Clay_MinMemorySize()`
|
||||
|
||||
Returns the minimum amount of memory **in bytes** that clay needs to accomodate the current [CLAY_MAX_ELEMENT_COUNT](#preprocessor-directives).
|
||||
|
||||
---
|
||||
|
||||
### Clay_CreateArenaWithCapacityAndMemory
|
||||
|
||||
`Clay_Arena Clay_CreateArenaWithCapacityAndMemory(uint32_t capacity, void *offset)`
|
||||
|
||||
Creates a `Clay_Arena` struct with the given capacity and base memory pointer, which can be passed to [Clay_Initialize](#clay_initialize).
|
||||
|
||||
---
|
||||
|
||||
### Clay_SetMeasureTextFunction
|
||||
|
||||
`void Clay_SetMeasureTextFunction(Clay_Dimensions (*measureTextFunction)(Clay_String *text, Clay_TextElementConfig *config))`
|
||||
@ -512,6 +573,8 @@ Takes a pointer to a function that can be used to measure the `width, height` di
|
||||
|
||||
**Note 2: It is essential that this function is as fast as possible.** For text heavy use-cases this function is called many times, and despite the fact that clay caches text measurements internally, it can easily become the dominant overall layout cost if the provided function is slow. **This is on the hot path!**
|
||||
|
||||
---
|
||||
|
||||
### Clay_SetMaxElementCount
|
||||
|
||||
`void Clay_SetMaxElementCount(uint32_t maxElementCount)`
|
||||
@ -520,6 +583,8 @@ Sets the internal maximum element count that will be used in subsequent [Clay_In
|
||||
|
||||
**Note: You will need to reinitialize clay, after calling [Clay_MinMemorySize()](#clay_minmemorysize) to calculate updated memory requirements.**
|
||||
|
||||
---
|
||||
|
||||
### Clay_SetMaxMeasureTextCacheWordCount
|
||||
|
||||
`void Clay_SetMaxMeasureTextCacheWordCount(uint32_t maxMeasureTextCacheWordCount)`
|
||||
@ -528,6 +593,8 @@ Sets the internal text measurement cache size that will be used in subsequent [C
|
||||
|
||||
**Note: You will need to reinitialize clay, after calling [Clay_MinMemorySize()](#clay_minmemorysize) to calculate updated memory requirements.**
|
||||
|
||||
---
|
||||
|
||||
### Clay_Initialize
|
||||
|
||||
`Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler)`
|
||||
@ -548,18 +615,24 @@ Sets the context that subsequent clay commands will operate on. You can get this
|
||||
|
||||
Returns the context that clay commands are currently operating on, or null if no context has been set. See [Running more than one Clay instance](#running-more-than-one-clay-instance).
|
||||
|
||||
---
|
||||
|
||||
### Clay_SetLayoutDimensions
|
||||
|
||||
`void Clay_SetLayoutDimensions(Clay_Dimensions dimensions)`
|
||||
|
||||
Sets the internal layout dimensions. Cheap enough to be called every frame with your screen dimensions to automatically respond to window resizing, etc.
|
||||
|
||||
---
|
||||
|
||||
### Clay_SetPointerState
|
||||
|
||||
`void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown)`
|
||||
|
||||
Sets the internal pointer position and state (i.e. current mouse / touch position) and recalculates overlap info, which is used for mouseover / click calculation (via [Clay_PointerOver](#clay_pointerover) and updating scroll containers with [Clay_UpdateScrollContainers](#clay_updatescrollcontainers). **isPointerDown should represent the current state this frame, e.g. it should be `true` for the entire duration the left mouse button is held down.** Clay has internal handling for detecting click / touch start & end.
|
||||
|
||||
---
|
||||
|
||||
### Clay_UpdateScrollContainers
|
||||
|
||||
`void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime)`
|
||||
@ -570,24 +643,32 @@ Touch / drag scrolling only occurs if the `enableDragScrolling` parameter is `tr
|
||||
|
||||
`deltaTime` is the time **in seconds** since the last frame (e.g. 0.016 is **16 milliseconds**), and is used to normalize & smooth scrolling across different refresh rates.
|
||||
|
||||
---
|
||||
|
||||
### Clay_BeginLayout
|
||||
|
||||
`void Clay_BeginLayout()`
|
||||
|
||||
Prepares clay to calculate a new layout. Called each frame / layout **before** any of the [Element Macros](#element-macros).
|
||||
|
||||
---
|
||||
|
||||
### Clay_EndLayout
|
||||
|
||||
`Clay_RenderCommandArray Clay_EndLayout()`
|
||||
|
||||
Ends declaration of element macros and calculates the results of the current layout. Renders a [Clay_RenderCommandArray](#clay_rendercommandarray) containing the results of the layout calculation.
|
||||
|
||||
---
|
||||
|
||||
### Clay_Hovered
|
||||
|
||||
`bool Clay_Hovered()`
|
||||
|
||||
Called **during** layout declaration, and returns `true` if the pointer position previously set with `Clay_SetPointerState` is inside the bounding box of the currently open element. Note: this is based on the element's position from the **last** frame.
|
||||
|
||||
---
|
||||
|
||||
### Clay_OnHover
|
||||
|
||||
`void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerData, intptr_t userData), intptr_t userData)`
|
||||
@ -612,6 +693,8 @@ CLAY(CLAY_LAYOUT({ .padding = { 8, 8 }}), Clay_OnHover(HandleButtonInteraction,
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Clay_PointerOver
|
||||
|
||||
`bool Clay_PointerOver(Clay_ElementId id)`
|
||||
@ -624,6 +707,8 @@ Returns `true` if the pointer position previously set with `Clay_SetPointerState
|
||||
|
||||
Returns [Clay_ScrollContainerData](#clay_scrollcontainerdata) for the scroll container matching the provided ID. This function allows imperative manipulation of scroll position, allowing you to build things such as scroll bars, buttons that "jump" to somewhere in a scroll container, etc.
|
||||
|
||||
---
|
||||
|
||||
### Clay_GetElementId
|
||||
|
||||
`Clay_ElementId Clay_GetElementId(Clay_String idString)`
|
||||
@ -644,6 +729,7 @@ Returns a [Clay_ElementId](#clay_elementid) for the provided id string, used for
|
||||
**Notes**
|
||||
|
||||
**CLAY** opens a generic empty container, that is configurable and supports nested children.
|
||||
**CLAY** requires at least 1 parameter, so if you want to create an element without any configuration, use `CLAY(0)`.
|
||||
|
||||
**Examples**
|
||||
```C
|
||||
@ -664,6 +750,8 @@ CLAY(CLAY_ID("Outer"), CLAY_LAYOUT({ .padding = {16, 16} })) {
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_ID
|
||||
|
||||
**Usage**
|
||||
@ -686,7 +774,7 @@ To regenerate the same ID outside of layout declaration when using utility funct
|
||||
// Tag a button with the Id "Button"
|
||||
CLAY(
|
||||
CLAY_ID("Button"),
|
||||
CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW() }, .padding = {16, 16}, .childGap = 16) })
|
||||
CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = {16, 16}, .childGap = 16) })
|
||||
) {
|
||||
// ...children
|
||||
}
|
||||
@ -698,12 +786,16 @@ if (buttonIsHovered && leftMouseButtonPressed) {
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_IDI()
|
||||
|
||||
`Clay_ElementId CLAY_IDI(char *label, int index)`
|
||||
|
||||
An offset version of [CLAY_ID](#clay_id). Generates a [Clay_ElementId](#clay_elementid) 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.
|
||||
|
||||
---
|
||||
|
||||
### CLAY_LAYOUT
|
||||
|
||||
**Usage**
|
||||
@ -733,8 +825,8 @@ Clay_LayoutConfig {
|
||||
.y = CLAY_ALIGN_Y_TOP (default) | CLAY_ALIGN_Y_CENTER | CLAY_ALIGN_Y_BOTTOM;
|
||||
};
|
||||
Clay_Sizing sizing { // Recommended to use the provided macros here - see #sizing for more in depth explanation
|
||||
.width = CLAY_SIZING_FIT(float min, float max) (default) | CLAY_SIZING_GROW(float min, float max) | CLAY_SIZING_FIXED(width) | CLAY_SIZING_PERCENT(float percent)
|
||||
.height = CLAY_SIZING_FIT(float min, float max) (default) | CLAY_SIZING_GROW(float min, float max) | CLAY_SIZING_FIXED(height) | CLAY_SIZING_PERCENT(float percent)
|
||||
.width = CLAY_SIZING_FIT(float min, float max) (default) | CLAY_SIZING_GROW(float min, float max) | CLAY_SIZING_FIXED(float width) | CLAY_SIZING_PERCENT(float percent)
|
||||
.height = CLAY_SIZING_FIT(float min, float max) (default) | CLAY_SIZING_GROW(float min, float max) | CLAY_SIZING_FIXED(float height) | CLAY_SIZING_PERCENT(float percent)
|
||||
}; // See CLAY_SIZING_GROW() etc for more details
|
||||
};
|
||||
```
|
||||
@ -810,11 +902,13 @@ Controls how final width and height of element are calculated. The same configur
|
||||
**Example Usage**
|
||||
|
||||
```C
|
||||
CLAY(CLAY_ID("Button"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW() }, .padding = {16, 16}, .childGap = 16) }) {
|
||||
CLAY(CLAY_ID("Button"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = {16, 16}, .childGap = 16) }) {
|
||||
// Children will be laid out vertically with 16px of padding around and between
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_RECTANGLE
|
||||
**Usage**
|
||||
|
||||
@ -896,6 +990,8 @@ CLAY(
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_TEXT
|
||||
**Usage**
|
||||
|
||||
@ -1017,6 +1113,8 @@ Element is subject to [culling](#visibility-culling). Otherwise, multiple `Clay_
|
||||
|
||||
`Clay_RenderCommand.textContent` will be populated with a `Clay_String` _slice_ of the original string passed in (i.e. wrapping doesn't reallocate, it just returns a `Clay_String` pointing to the start of the new line with a `length`)
|
||||
|
||||
---
|
||||
|
||||
### CLAY_IMAGE
|
||||
**Usage**
|
||||
|
||||
@ -1114,6 +1212,8 @@ Image *imageToRender = renderCommand->elementConfig.imageElementConfig->imageDat
|
||||
|
||||
Element is subject to [culling](#visibility-culling). Otherwise, a single `Clay_RenderCommand`s with `commandType = CLAY_RENDER_COMMAND_TYPE_IMAGE` will be created. The user will need to access `renderCommand->elementConfig.imageElementConfig->imageData` to retrieve image data referenced during layout creation. It's also up to the user to decide how / if they wish to blend `rectangleElementConfig->color` with the image.
|
||||
|
||||
---
|
||||
|
||||
### CLAY_SCROLL
|
||||
**Usage**
|
||||
|
||||
@ -1173,6 +1273,8 @@ CLAY(CLAY_SCROLL(.vertical = true)) {
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_BORDER
|
||||
**Usage**
|
||||
|
||||
@ -1290,6 +1392,8 @@ CLAY(
|
||||
Element is subject to [culling](#visibility-culling). Otherwise, a single `Clay_RenderCommand` with `commandType = CLAY_RENDER_COMMAND_TYPE_BORDER` representing the container will be created.
|
||||
Rendering of borders and rounded corners is left up to the user. See the provided [Raylib Renderer](https://github.com/nicbarker/clay/tree/main/renderers/raylib) for examples of how to draw borders using line and curve primitives.
|
||||
|
||||
---
|
||||
|
||||
### CLAY_FLOATING
|
||||
**Usage**
|
||||
|
||||
@ -1501,6 +1605,8 @@ When using `.parentId`, the floating container can be declared anywhere after `B
|
||||
|
||||
`CLAY_FLOATING` elements will not generate any render commands.
|
||||
|
||||
---
|
||||
|
||||
### CLAY_CUSTOM_ELEMENT
|
||||
**Usage**
|
||||
|
||||
@ -1627,6 +1733,8 @@ The number of characters in the string, _not including an optional null terminat
|
||||
|
||||
A pointer to the contents of the string. This data is not guaranteed to be null terminated, so if you are passing it to code that expects standard null terminated C strings, you will need to copy the data and append a null terminator.
|
||||
|
||||
---
|
||||
|
||||
### Clay_ElementId
|
||||
|
||||
```C
|
||||
@ -1664,6 +1772,7 @@ If this id was generated using [CLAY_IDI](#clay_idi), `.baseId` is the hash of t
|
||||
|
||||
Stores the original string that was passed in when [CLAY_ID](#clay_id) or [CLAY_IDI](#clay_idi) were called.
|
||||
|
||||
---
|
||||
|
||||
### Clay_RenderCommandArray
|
||||
|
||||
@ -1697,6 +1806,8 @@ Represents the total number of `Clay_RenderCommand` elements stored consecutivel
|
||||
|
||||
An array of [Clay_RenderCommand](#clay_rendercommand)s representing the calculated layout. If there was at least one render command, this array will contain elements from `.internalArray[0]` to `.internalArray[.length - 1]`.
|
||||
|
||||
---
|
||||
|
||||
### Clay_RenderCommand
|
||||
|
||||
```C
|
||||
@ -1763,6 +1874,8 @@ Only used if `.commandType == CLAY_RENDER_COMMAND_TYPE_TEXT`. A `Clay_String` co
|
||||
|
||||
The id that was originally used with the element macro that created this render command. See [CLAY_ID](#clay_id) for details.
|
||||
|
||||
---
|
||||
|
||||
### Clay_ScrollContainerData
|
||||
|
||||
```C
|
||||
@ -1812,6 +1925,8 @@ Dimensions representing the inner width and height of the content _inside_ the s
|
||||
|
||||
The [Clay_ScrollElementConfig](#clay_scroll) for the matching scroll container element.
|
||||
|
||||
---
|
||||
|
||||
### Clay_PointerData
|
||||
|
||||
```C
|
||||
|
5
bindings/jai/.gitignore
vendored
Normal file
5
bindings/jai/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.build/
|
||||
main.exe
|
||||
main.pdb
|
||||
main.rdi
|
||||
main
|
116
bindings/jai/README.md
Normal file
116
bindings/jai/README.md
Normal file
@ -0,0 +1,116 @@
|
||||
### Jai Language Bindings
|
||||
|
||||
This directory contains bindings for the [Jai](https://jai.community/t/overview-of-jai/128) programming language, as well as an example implementation of the Clay demo from the video in Jai.
|
||||
|
||||
If you haven't taken a look at the [full documentation for clay](https://github.com/nicbarker/clay/blob/main/README.md), it's recommended that you take a look there first to familiarise yourself with the general concepts. This README is abbreviated and applies to using clay in Jai specifically.
|
||||
|
||||
The **most notable difference** between the C API and the Jai bindings is the use of for statements to create the scope for declaring child elements. This is done using some [for_expansion](https://jai.community/t/loops/147) magic.
|
||||
When using the equivalent of the [Element Macros](https://github.com/nicbarker/clay/blob/main/README.md#element-macros):
|
||||
|
||||
```C
|
||||
// C form of element macros
|
||||
// Parent element with 8px of padding
|
||||
CLAY(CLAY_LAYOUT({ .padding = 8 })) {
|
||||
// Child element 1
|
||||
CLAY_TEXT(CLAY_STRING("Hello World"), CLAY_TEXT_CONFIG({ .fontSize = 16 }));
|
||||
// Child element 2 with red background
|
||||
CLAY(CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
// etc
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```Jai
|
||||
// Jai form of element macros
|
||||
// Parent element with 8px of padding
|
||||
for Clay.Element(Clay.Layout(.{padding = 8})) {
|
||||
// Child element 1
|
||||
Clay.Text("Hello World", Clay.TextConfig(.{fontSize = 16}));
|
||||
// Child element 2 with red background
|
||||
for Clay.Element(Clay.Rectangle(.{color = COLOR_RED})) {
|
||||
// etc
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> For now, the Jai and Odin bindings are missing the OnHover() and Hovered() functions.
|
||||
> You can you PointerOver instead, an example of that is in `examples/introducing_clay_video_demo`.
|
||||
|
||||
### Quick Start
|
||||
|
||||
1. Download the clay-jai directory and copy it into your modules folder.
|
||||
|
||||
```Jai
|
||||
Clay :: #import "clay-jai";
|
||||
```
|
||||
|
||||
1. Ask clay for how much static memory it needs using [Clay.MinMemorySize()](https://github.com/nicbarker/clay/blob/main/README.md#clay_minmemorysize), create an Arena for it to use with [Clay.CreateArenaWithCapacityAndMemory()](https://github.com/nicbarker/clay/blob/main/README.md#clay_createarenawithcapacityandmemory), and initialize it with [Clay.Initialize()](https://github.com/nicbarker/clay/blob/main/README.md#clay_initialize).
|
||||
|
||||
```Jai
|
||||
clay_required_memory := Clay.MinMemorySize();
|
||||
memory := alloc(clay_required_memory);
|
||||
clay_memory := Clay.CreateArenaWithCapacityAndMemory(clay_required_memory, memory);
|
||||
Clay.Initialize(
|
||||
clay_memory,
|
||||
Clay.Dimensions.{cast(float, GetScreenWidth()), cast(float, GetScreenHeight())},
|
||||
.{handle_clay_errors, 0}
|
||||
);
|
||||
```
|
||||
|
||||
3. Provide a `measure_text(text, config)` proc marked with `#c_call` with [Clay.SetMeasureTextFunction(function)](https://github.com/nicbarker/clay/blob/main/README.md#clay_setmeasuretextfunction) so that clay can measure and wrap text.
|
||||
|
||||
```Jai
|
||||
// Example measure text function
|
||||
measure_text :: (text: *Clay.String, config: *Clay.TextElementConfig) -> Clay.Dimensions #c_call {
|
||||
}
|
||||
|
||||
// Tell clay how to measure text
|
||||
Clay.SetMeasureTextFunction(measure_text)
|
||||
```
|
||||
|
||||
4. **Optional** - Call [Clay.SetPointerPosition(pointerPosition)](https://github.com/nicbarker/clay/blob/main/README.md#clay_setpointerposition) if you want to use mouse interactions.
|
||||
|
||||
```Jai
|
||||
// Update internal pointer position for handling mouseover / click / touch events
|
||||
Clay.SetPointerPosition(.{ mousePositionX, mousePositionY })
|
||||
```
|
||||
|
||||
5. Call [Clay.BeginLayout(screenWidth, screenHeight)](https://github.com/nicbarker/clay/blob/main/README.md#clay_beginlayout) and declare your layout using the provided macros.
|
||||
|
||||
```Jai
|
||||
// An example function to begin the "root" of your layout tree
|
||||
CreateLayout :: () -> Clay.RenderCommandArray {
|
||||
Clay.BeginLayout(windowWidth, windowHeight);
|
||||
|
||||
for Clay.Element(
|
||||
Clay.ID("OuterContainer"),
|
||||
Clay.Layout(.{
|
||||
sizing = .{Clay.SizingGrow(), Clay.SizingGrow()},
|
||||
padding = .{16, 16},
|
||||
childGap = 16
|
||||
}),
|
||||
Clay.Rectangle(.{color = .{250, 250, 255, 255}}),
|
||||
) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
1. Call [Clay.EndLayout()](https://github.com/nicbarker/clay/blob/main/README.md#clay_endlayout) and process the resulting [Clay.RenderCommandArray](https://github.com/nicbarker/clay/blob/main/README.md#clay_rendercommandarray) in your choice of renderer.
|
||||
|
||||
```Jai
|
||||
render_commands: Clay.RenderCommandArray = Clay.EndLayout();
|
||||
|
||||
for 0..render_commands.length - 1 {
|
||||
render_command := Clay.RenderCommandArray_Get(*render_commands, cast(s32) it);
|
||||
|
||||
if #complete render_command.commandType == {
|
||||
case .RECTANGLE;
|
||||
DrawRectangle(render_command.boundingBox, render_command.config.rectangleElementConfig.color)
|
||||
// ... Implement handling of other command types
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please see the [full C documentation for clay](https://github.com/nicbarker/clay/blob/main/README.md) for API details. All public C functions and Macros have Jai binding equivalents, generally of the form `CLAY_RECTANGLE` (C) -> `Clay.Rectangle` (Jai)
|
1
bindings/jai/clay-jai/.gitignore
vendored
Normal file
1
bindings/jai/clay-jai/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
source/clay.h
|
164
bindings/jai/clay-jai/generate.jai
Normal file
164
bindings/jai/clay-jai/generate.jai
Normal file
@ -0,0 +1,164 @@
|
||||
AT_COMPILE_TIME :: true;
|
||||
|
||||
SOURCE_PATH :: "source";
|
||||
|
||||
DECLARATIONS_TO_OMIT :: string.[
|
||||
// These have custom declaration in module.jai
|
||||
"Clay_Vector2",
|
||||
"Clay__ElementConfigType",
|
||||
"Clay__AlignClay__ElementConfigType",
|
||||
"Clay_Border",
|
||||
"Clay__AlignClay_Border",
|
||||
"Clay_BorderElementConfig",
|
||||
"Clay__AlignClay_BorderElementConfig",
|
||||
|
||||
// These are not supported yet
|
||||
"Clay_OnHover",
|
||||
"Clay_Hovered",
|
||||
];
|
||||
|
||||
#if AT_COMPILE_TIME {
|
||||
#if !#exists(JAILS_DIAGNOSTICS_BUILD) {
|
||||
#run,stallable {
|
||||
Compiler.set_build_options_dc(.{do_output=false});
|
||||
options := Compiler.get_build_options();
|
||||
args := options.compile_time_command_line;
|
||||
if !generate_bindings(args, options.minimum_os_version) {
|
||||
Compiler.compiler_set_workspace_status(.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#import "System";
|
||||
|
||||
main :: () {
|
||||
set_working_directory(path_strip_filename(get_path_of_running_executable()));
|
||||
if !generate_bindings(get_command_line_arguments(), #run get_build_options().minimum_os_version) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generate_bindings :: (args: [] string, minimum_os_version: type_of(Compiler.Build_Options.minimum_os_version)) -> bool {
|
||||
compile := array_find(args, "-compile");
|
||||
compile_debug := array_find(args, "-debug");
|
||||
|
||||
could_copy := FileUtils.copy_file("../../../clay.h", "source/clay.h");
|
||||
if !could_copy then return false;
|
||||
defer if !compile_debug then File.file_delete("source/clay.h");
|
||||
|
||||
if compile {
|
||||
source_file := tprint("%/clay.c", SOURCE_PATH);
|
||||
|
||||
success := true;
|
||||
#if OS == .WINDOWS {
|
||||
// TODO try to use BuildCpp module again
|
||||
File.make_directory_if_it_does_not_exist("windows", true);
|
||||
|
||||
command := ifx compile_debug {
|
||||
write_string("Compiling debug...\n");
|
||||
Process.break_command_into_strings("clang -g -gcodeview -c source\\clay.c");
|
||||
} else {
|
||||
write_string("Compiling release...\n");
|
||||
Process.break_command_into_strings("clang -O3 -c source\\clay.c");
|
||||
}
|
||||
result := Process.run_command(..command, capture_and_return_output=true, print_captured_output=true);
|
||||
if result.exit_code != 0 then return false;
|
||||
defer File.file_delete("clay.o");
|
||||
|
||||
write_string("Linking...\n");
|
||||
command = Process.break_command_into_strings("llvm-ar -rcs windows/clay.lib clay.o");
|
||||
result = Process.run_command(..command, capture_and_return_output=true, print_captured_output=true);
|
||||
if result.exit_code != 0 then return false;
|
||||
} else #if OS == .LINUX {
|
||||
File.make_directory_if_it_does_not_exist("linux", true);
|
||||
|
||||
could_build := BuildCpp.build_cpp_static_lib("linux/clay", "source/clay.c",
|
||||
debug = compile_debug,
|
||||
);
|
||||
assert(could_build);
|
||||
} else {
|
||||
// TODO MacOS
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if !success then return false;
|
||||
write_string("Succesfully built clay\n");
|
||||
}
|
||||
|
||||
output_filename: string;
|
||||
options: Generator.Generate_Bindings_Options;
|
||||
{
|
||||
write_string("Generating bindings...\n");
|
||||
|
||||
using options;
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
array_add(*libpaths, "windows");
|
||||
output_filename = "windows.jai";
|
||||
} else #if OS == .LINUX {
|
||||
array_add(*libpaths, "linux");
|
||||
output_filename = "linux.jai";
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
array_add(*libnames, "clay");
|
||||
array_add(*include_paths, SOURCE_PATH);
|
||||
array_add(*source_files, tprint("%/clay.h", SOURCE_PATH));
|
||||
array_add(*strip_prefixes, "Clay_");
|
||||
|
||||
auto_detect_enum_prefixes = true;
|
||||
log_stripped_declarations = true;
|
||||
generate_compile_time_struct_checks = true;
|
||||
|
||||
visitor = clay_visitor;
|
||||
}
|
||||
|
||||
could_generate := Generator.generate_bindings(options, output_filename);
|
||||
|
||||
return could_generate;
|
||||
}
|
||||
|
||||
clay_visitor :: (decl: *Generator.Declaration, parent_decl: *Generator.Declaration) -> Generator.Declaration_Visit_Result {
|
||||
if !parent_decl {
|
||||
if array_find(DECLARATIONS_TO_OMIT, decl.name) {
|
||||
decl.decl_flags |= .OMIT_FROM_OUTPUT;
|
||||
return .STOP;
|
||||
}
|
||||
|
||||
// We don't want the align and wrapper strucs
|
||||
if String.begins_with(decl.name, "Clay__Align") || String.ends_with(decl.name, "Wrapper") {
|
||||
decl.decl_flags |= .OMIT_FROM_OUTPUT;
|
||||
return .STOP;
|
||||
}
|
||||
|
||||
if String.begins_with(decl.name, "Clay__") {
|
||||
// The way bindings generator strip prefixes mean that something like `Clay__Foo` will be turned to `Foo`
|
||||
// but what we want is `_Foo`
|
||||
decl.output_name = String.slice(decl.name, 5, decl.name.count - 5);
|
||||
}
|
||||
}
|
||||
|
||||
return .RECURSE;
|
||||
}
|
||||
|
||||
#scope_file
|
||||
|
||||
using Basic :: #import "Basic";
|
||||
Generator :: #import "Bindings_Generator";
|
||||
Compiler :: #import "Compiler";
|
||||
File :: #import "File";
|
||||
FileUtils :: #import "File_Utilities";
|
||||
BuildCpp :: #import "BuildCpp";
|
||||
Process :: #import "Process";
|
||||
String :: #import "String";
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
Windows :: #import "Windows";
|
||||
WindowsResources :: #import "Windows_Resources";
|
||||
getenv :: Windows.getenv;
|
||||
} else {
|
||||
Posix :: #import "POSIX";
|
||||
getenv :: Posix.getenv;
|
||||
}
|
711
bindings/jai/clay-jai/linux.jai
Normal file
711
bindings/jai/clay-jai/linux.jai
Normal file
@ -0,0 +1,711 @@
|
||||
//
|
||||
// This file was auto-generated using the following command:
|
||||
//
|
||||
// jai generate.jai - -compile
|
||||
//
|
||||
|
||||
|
||||
|
||||
// Utility Structs -------------------------
|
||||
// Note: Clay_String is not guaranteed to be null terminated. It may be if created from a literal C string,
|
||||
// but it is also used to represent slices.
|
||||
String :: struct {
|
||||
length: s32;
|
||||
chars: *u8;
|
||||
}
|
||||
|
||||
_StringArray :: struct {
|
||||
capacity: s32;
|
||||
length: s32;
|
||||
internalArray: *String;
|
||||
}
|
||||
|
||||
Context :: struct {}
|
||||
|
||||
Arena :: struct {
|
||||
nextAllocation: u64;
|
||||
capacity: u64;
|
||||
memory: *u8;
|
||||
}
|
||||
|
||||
Dimensions :: struct {
|
||||
width: float;
|
||||
height: float;
|
||||
}
|
||||
|
||||
Color :: struct {
|
||||
r: float;
|
||||
g: float;
|
||||
b: float;
|
||||
a: float;
|
||||
}
|
||||
|
||||
BoundingBox :: struct {
|
||||
x: float;
|
||||
y: float;
|
||||
width: float;
|
||||
height: float;
|
||||
}
|
||||
|
||||
// baseId + offset = id
|
||||
ElementId :: struct {
|
||||
id: u32;
|
||||
offset: u32;
|
||||
baseId: u32;
|
||||
stringId: String;
|
||||
}
|
||||
|
||||
CornerRadius :: struct {
|
||||
topLeft: float;
|
||||
topRight: float;
|
||||
bottomLeft: float;
|
||||
bottomRight: float;
|
||||
}
|
||||
|
||||
LayoutDirection :: enum u8 {
|
||||
LEFT_TO_RIGHT :: 0;
|
||||
TOP_TO_BOTTOM :: 1;
|
||||
CLAY_LEFT_TO_RIGHT :: LEFT_TO_RIGHT;
|
||||
CLAY_TOP_TO_BOTTOM :: TOP_TO_BOTTOM;
|
||||
}
|
||||
|
||||
LayoutAlignmentX :: enum u8 {
|
||||
LEFT :: 0;
|
||||
RIGHT :: 1;
|
||||
CENTER :: 2;
|
||||
CLAY_ALIGN_X_LEFT :: LEFT;
|
||||
CLAY_ALIGN_X_RIGHT :: RIGHT;
|
||||
CLAY_ALIGN_X_CENTER :: CENTER;
|
||||
}
|
||||
|
||||
LayoutAlignmentY :: enum u8 {
|
||||
TOP :: 0;
|
||||
BOTTOM :: 1;
|
||||
CENTER :: 2;
|
||||
CLAY_ALIGN_Y_TOP :: TOP;
|
||||
CLAY_ALIGN_Y_BOTTOM :: BOTTOM;
|
||||
CLAY_ALIGN_Y_CENTER :: CENTER;
|
||||
}
|
||||
|
||||
_SizingType :: enum u8 {
|
||||
FIT :: 0;
|
||||
GROW :: 1;
|
||||
PERCENT :: 2;
|
||||
FIXED :: 3;
|
||||
CLAY__SIZING_TYPE_FIT :: FIT;
|
||||
CLAY__SIZING_TYPE_GROW :: GROW;
|
||||
CLAY__SIZING_TYPE_PERCENT :: PERCENT;
|
||||
CLAY__SIZING_TYPE_FIXED :: FIXED;
|
||||
}
|
||||
|
||||
ChildAlignment :: struct {
|
||||
x: LayoutAlignmentX;
|
||||
y: LayoutAlignmentY;
|
||||
}
|
||||
|
||||
SizingMinMax :: struct {
|
||||
min: float;
|
||||
max: float;
|
||||
}
|
||||
|
||||
SizingAxis :: struct {
|
||||
size: union {
|
||||
minMax: SizingMinMax;
|
||||
percent: float;
|
||||
};
|
||||
type: _SizingType;
|
||||
}
|
||||
|
||||
Sizing :: struct {
|
||||
width: SizingAxis;
|
||||
height: SizingAxis;
|
||||
}
|
||||
|
||||
Padding :: struct {
|
||||
x: u16;
|
||||
y: u16;
|
||||
}
|
||||
|
||||
LayoutConfig :: struct {
|
||||
sizing: Sizing;
|
||||
padding: Padding;
|
||||
childGap: u16;
|
||||
childAlignment: ChildAlignment;
|
||||
layoutDirection: LayoutDirection;
|
||||
}
|
||||
|
||||
CLAY_LAYOUT_DEFAULT: LayoutConfig #elsewhere clay;
|
||||
|
||||
// Rectangle
|
||||
// NOTE: Not declared in the typedef as an ifdef inside macro arguments is UB
|
||||
RectangleElementConfig :: struct {
|
||||
color: Color;
|
||||
cornerRadius: CornerRadius;
|
||||
}
|
||||
|
||||
// Text
|
||||
TextElementConfigWrapMode :: enum u32 {
|
||||
WORDS :: 0;
|
||||
NEWLINES :: 1;
|
||||
NONE :: 2;
|
||||
CLAY_TEXT_WRAP_WORDS :: WORDS;
|
||||
CLAY_TEXT_WRAP_NEWLINES :: NEWLINES;
|
||||
CLAY_TEXT_WRAP_NONE :: NONE;
|
||||
}
|
||||
|
||||
TextElementConfig :: struct {
|
||||
textColor: Color;
|
||||
fontId: u16;
|
||||
fontSize: u16;
|
||||
letterSpacing: u16;
|
||||
lineHeight: u16;
|
||||
wrapMode: TextElementConfigWrapMode;
|
||||
}
|
||||
|
||||
// Image
|
||||
ImageElementConfig :: struct {
|
||||
imageData: *void;
|
||||
sourceDimensions: Dimensions;
|
||||
}
|
||||
|
||||
FloatingAttachPointType :: enum u8 {
|
||||
LEFT_TOP :: 0;
|
||||
LEFT_CENTER :: 1;
|
||||
LEFT_BOTTOM :: 2;
|
||||
CENTER_TOP :: 3;
|
||||
CENTER_CENTER :: 4;
|
||||
CENTER_BOTTOM :: 5;
|
||||
RIGHT_TOP :: 6;
|
||||
RIGHT_CENTER :: 7;
|
||||
RIGHT_BOTTOM :: 8;
|
||||
CLAY_ATTACH_POINT_LEFT_TOP :: LEFT_TOP;
|
||||
CLAY_ATTACH_POINT_LEFT_CENTER :: LEFT_CENTER;
|
||||
CLAY_ATTACH_POINT_LEFT_BOTTOM :: LEFT_BOTTOM;
|
||||
CLAY_ATTACH_POINT_CENTER_TOP :: CENTER_TOP;
|
||||
CLAY_ATTACH_POINT_CENTER_CENTER :: CENTER_CENTER;
|
||||
CLAY_ATTACH_POINT_CENTER_BOTTOM :: CENTER_BOTTOM;
|
||||
CLAY_ATTACH_POINT_RIGHT_TOP :: RIGHT_TOP;
|
||||
CLAY_ATTACH_POINT_RIGHT_CENTER :: RIGHT_CENTER;
|
||||
CLAY_ATTACH_POINT_RIGHT_BOTTOM :: RIGHT_BOTTOM;
|
||||
}
|
||||
|
||||
FloatingAttachPoints :: struct {
|
||||
element: FloatingAttachPointType;
|
||||
parent: FloatingAttachPointType;
|
||||
}
|
||||
|
||||
PointerCaptureMode :: enum u32 {
|
||||
CAPTURE :: 0;
|
||||
PASSTHROUGH :: 1;
|
||||
CLAY_POINTER_CAPTURE_MODE_CAPTURE :: CAPTURE;
|
||||
CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH :: PASSTHROUGH;
|
||||
}
|
||||
|
||||
FloatingElementConfig :: struct {
|
||||
offset: Vector2;
|
||||
expand: Dimensions;
|
||||
zIndex: u16;
|
||||
parentId: u32;
|
||||
attachment: FloatingAttachPoints;
|
||||
pointerCaptureMode: PointerCaptureMode;
|
||||
}
|
||||
|
||||
// Custom
|
||||
CustomElementConfig :: struct {
|
||||
customData: *void;
|
||||
}
|
||||
|
||||
// Scroll
|
||||
ScrollElementConfig :: struct {
|
||||
horizontal: bool;
|
||||
vertical: bool;
|
||||
}
|
||||
|
||||
ElementConfigUnion :: union {
|
||||
rectangleElementConfig: *RectangleElementConfig;
|
||||
textElementConfig: *TextElementConfig;
|
||||
imageElementConfig: *ImageElementConfig;
|
||||
floatingElementConfig: *FloatingElementConfig;
|
||||
customElementConfig: *CustomElementConfig;
|
||||
scrollElementConfig: *ScrollElementConfig;
|
||||
borderElementConfig: *BorderElementConfig;
|
||||
}
|
||||
|
||||
ElementConfig :: struct {
|
||||
type: ElementConfigType;
|
||||
config: ElementConfigUnion;
|
||||
}
|
||||
|
||||
// Miscellaneous Structs & Enums ---------------------------------
|
||||
ScrollContainerData :: struct {
|
||||
// Note: This is a pointer to the real internal scroll position, mutating it may cause a change in final layout.
|
||||
// Intended for use with external functionality that modifies scroll position, such as scroll bars or auto scrolling.
|
||||
scrollPosition: *Vector2;
|
||||
scrollContainerDimensions: Dimensions;
|
||||
contentDimensions: Dimensions;
|
||||
config: ScrollElementConfig;
|
||||
found: bool;
|
||||
}
|
||||
|
||||
RenderCommandType :: enum u8 {
|
||||
NONE :: 0;
|
||||
RECTANGLE :: 1;
|
||||
BORDER :: 2;
|
||||
TEXT :: 3;
|
||||
IMAGE :: 4;
|
||||
SCISSOR_START :: 5;
|
||||
SCISSOR_END :: 6;
|
||||
CUSTOM :: 7;
|
||||
CLAY_RENDER_COMMAND_TYPE_NONE :: NONE;
|
||||
CLAY_RENDER_COMMAND_TYPE_RECTANGLE :: RECTANGLE;
|
||||
CLAY_RENDER_COMMAND_TYPE_BORDER :: BORDER;
|
||||
CLAY_RENDER_COMMAND_TYPE_TEXT :: TEXT;
|
||||
CLAY_RENDER_COMMAND_TYPE_IMAGE :: IMAGE;
|
||||
CLAY_RENDER_COMMAND_TYPE_SCISSOR_START :: SCISSOR_START;
|
||||
CLAY_RENDER_COMMAND_TYPE_SCISSOR_END :: SCISSOR_END;
|
||||
CLAY_RENDER_COMMAND_TYPE_CUSTOM :: CUSTOM;
|
||||
}
|
||||
|
||||
RenderCommand :: struct {
|
||||
boundingBox: BoundingBox;
|
||||
config: ElementConfigUnion;
|
||||
text: String; // TODO I wish there was a way to avoid having to have this on every render command
|
||||
id: u32;
|
||||
commandType: RenderCommandType;
|
||||
}
|
||||
|
||||
RenderCommandArray :: struct {
|
||||
capacity: s32;
|
||||
length: s32;
|
||||
internalArray: *RenderCommand;
|
||||
}
|
||||
|
||||
PointerDataInteractionState :: enum u32 {
|
||||
PRESSED_THIS_FRAME :: 0;
|
||||
PRESSED :: 1;
|
||||
RELEASED_THIS_FRAME :: 2;
|
||||
RELEASED :: 3;
|
||||
CLAY_POINTER_DATA_PRESSED_THIS_FRAME :: PRESSED_THIS_FRAME;
|
||||
CLAY_POINTER_DATA_PRESSED :: PRESSED;
|
||||
CLAY_POINTER_DATA_RELEASED_THIS_FRAME :: RELEASED_THIS_FRAME;
|
||||
CLAY_POINTER_DATA_RELEASED :: RELEASED;
|
||||
}
|
||||
|
||||
PointerData :: struct {
|
||||
position: Vector2;
|
||||
state: PointerDataInteractionState;
|
||||
}
|
||||
|
||||
ErrorType :: enum u32 {
|
||||
TEXT_MEASUREMENT_FUNCTION_NOT_PROVIDED :: 0;
|
||||
ARENA_CAPACITY_EXCEEDED :: 1;
|
||||
ELEMENTS_CAPACITY_EXCEEDED :: 2;
|
||||
TEXT_MEASUREMENT_CAPACITY_EXCEEDED :: 3;
|
||||
DUPLICATE_ID :: 4;
|
||||
FLOATING_CONTAINER_PARENT_NOT_FOUND :: 5;
|
||||
INTERNAL_ERROR :: 6;
|
||||
CLAY_ERROR_TYPE_TEXT_MEASUREMENT_FUNCTION_NOT_PROVIDED :: TEXT_MEASUREMENT_FUNCTION_NOT_PROVIDED;
|
||||
CLAY_ERROR_TYPE_ARENA_CAPACITY_EXCEEDED :: ARENA_CAPACITY_EXCEEDED;
|
||||
CLAY_ERROR_TYPE_ELEMENTS_CAPACITY_EXCEEDED :: ELEMENTS_CAPACITY_EXCEEDED;
|
||||
CLAY_ERROR_TYPE_TEXT_MEASUREMENT_CAPACITY_EXCEEDED :: TEXT_MEASUREMENT_CAPACITY_EXCEEDED;
|
||||
CLAY_ERROR_TYPE_DUPLICATE_ID :: DUPLICATE_ID;
|
||||
CLAY_ERROR_TYPE_FLOATING_CONTAINER_PARENT_NOT_FOUND :: FLOATING_CONTAINER_PARENT_NOT_FOUND;
|
||||
CLAY_ERROR_TYPE_INTERNAL_ERROR :: INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
ErrorData :: struct {
|
||||
errorType: ErrorType;
|
||||
errorText: String;
|
||||
userData: u64;
|
||||
}
|
||||
|
||||
ErrorHandler :: struct {
|
||||
errorHandlerFunction: #type (errorText: ErrorData) -> void #c_call;
|
||||
userData: u64;
|
||||
}
|
||||
|
||||
// Function Forward Declarations ---------------------------------
|
||||
// Public API functions ---
|
||||
MinMemorySize :: () -> u32 #foreign clay "Clay_MinMemorySize";
|
||||
CreateArenaWithCapacityAndMemory :: (capacity: u32, offset: *void) -> Arena #foreign clay "Clay_CreateArenaWithCapacityAndMemory";
|
||||
SetPointerState :: (position: Vector2, pointerDown: bool) -> void #foreign clay "Clay_SetPointerState";
|
||||
Initialize :: (arena: Arena, layoutDimensions: Dimensions, errorHandler: ErrorHandler) -> *Context #foreign clay "Clay_Initialize";
|
||||
GetCurrentContext :: () -> *Context #foreign clay "Clay_GetCurrentContext";
|
||||
SetCurrentContext :: (_context: *Context) -> void #foreign clay "Clay_SetCurrentContext";
|
||||
UpdateScrollContainers :: (enableDragScrolling: bool, scrollDelta: Vector2, deltaTime: float) -> void #foreign clay "Clay_UpdateScrollContainers";
|
||||
SetLayoutDimensions :: (dimensions: Dimensions) -> void #foreign clay "Clay_SetLayoutDimensions";
|
||||
BeginLayout :: () -> void #foreign clay "Clay_BeginLayout";
|
||||
EndLayout :: () -> RenderCommandArray #foreign clay "Clay_EndLayout";
|
||||
GetElementId :: (idString: String) -> ElementId #foreign clay "Clay_GetElementId";
|
||||
GetElementIdWithIndex :: (idString: String, index: u32) -> ElementId #foreign clay "Clay_GetElementIdWithIndex";
|
||||
|
||||
PointerOver :: (elementId: ElementId) -> bool #foreign clay "Clay_PointerOver";
|
||||
GetScrollContainerData :: (id: ElementId) -> ScrollContainerData #foreign clay "Clay_GetScrollContainerData";
|
||||
SetMeasureTextFunction :: (measureTextFunction: #type (text: *String, config: *TextElementConfig) -> Dimensions #c_call) -> void #foreign clay "Clay_SetMeasureTextFunction";
|
||||
SetQueryScrollOffsetFunction :: (queryScrollOffsetFunction: #type (elementId: u32) -> Vector2 #c_call) -> void #foreign clay "Clay_SetQueryScrollOffsetFunction";
|
||||
RenderCommandArray_Get :: (array: *RenderCommandArray, index: s32) -> *RenderCommand #foreign clay "Clay_RenderCommandArray_Get";
|
||||
SetDebugModeEnabled :: (enabled: bool) -> void #foreign clay "Clay_SetDebugModeEnabled";
|
||||
IsDebugModeEnabled :: () -> bool #foreign clay "Clay_IsDebugModeEnabled";
|
||||
SetCullingEnabled :: (enabled: bool) -> void #foreign clay "Clay_SetCullingEnabled";
|
||||
GetMaxElementCount :: () -> s32 #foreign clay "Clay_GetMaxElementCount";
|
||||
SetMaxElementCount :: (maxElementCount: s32) -> void #foreign clay "Clay_SetMaxElementCount";
|
||||
GetMaxMeasureTextCacheWordCount :: () -> s32 #foreign clay "Clay_GetMaxMeasureTextCacheWordCount";
|
||||
SetMaxMeasureTextCacheWordCount :: (maxMeasureTextCacheWordCount: s32) -> void #foreign clay "Clay_SetMaxMeasureTextCacheWordCount";
|
||||
|
||||
// Internal API functions required by macros
|
||||
_OpenElement :: () -> void #foreign clay "Clay__OpenElement";
|
||||
_CloseElement :: () -> void #foreign clay "Clay__CloseElement";
|
||||
_StoreLayoutConfig :: (config: LayoutConfig) -> *LayoutConfig #foreign clay "Clay__StoreLayoutConfig";
|
||||
_ElementPostConfiguration :: () -> void #foreign clay "Clay__ElementPostConfiguration";
|
||||
_AttachId :: (id: ElementId) -> void #foreign clay "Clay__AttachId";
|
||||
_AttachLayoutConfig :: (config: *LayoutConfig) -> void #foreign clay "Clay__AttachLayoutConfig";
|
||||
_AttachElementConfig :: (config: ElementConfigUnion, type: ElementConfigType) -> void #foreign clay "Clay__AttachElementConfig";
|
||||
_StoreRectangleElementConfig :: (config: RectangleElementConfig) -> *RectangleElementConfig #foreign clay "Clay__StoreRectangleElementConfig";
|
||||
_StoreTextElementConfig :: (config: TextElementConfig) -> *TextElementConfig #foreign clay "Clay__StoreTextElementConfig";
|
||||
_StoreImageElementConfig :: (config: ImageElementConfig) -> *ImageElementConfig #foreign clay "Clay__StoreImageElementConfig";
|
||||
_StoreFloatingElementConfig :: (config: FloatingElementConfig) -> *FloatingElementConfig #foreign clay "Clay__StoreFloatingElementConfig";
|
||||
_StoreCustomElementConfig :: (config: CustomElementConfig) -> *CustomElementConfig #foreign clay "Clay__StoreCustomElementConfig";
|
||||
_StoreScrollElementConfig :: (config: ScrollElementConfig) -> *ScrollElementConfig #foreign clay "Clay__StoreScrollElementConfig";
|
||||
_StoreBorderElementConfig :: (config: BorderElementConfig) -> *BorderElementConfig #foreign clay "Clay__StoreBorderElementConfig";
|
||||
_HashString :: (key: String, offset: u32, seed: u32) -> ElementId #foreign clay "Clay__HashString";
|
||||
_OpenTextElement :: (text: String, textConfig: *TextElementConfig) -> void #foreign clay "Clay__OpenTextElement";
|
||||
_GetParentElementId :: () -> u32 #foreign clay "Clay__GetParentElementId";
|
||||
|
||||
_debugViewHighlightColor: Color #elsewhere clay "Clay__debugViewHighlightColor";
|
||||
_debugViewWidth: u32 #elsewhere clay "Clay__debugViewWidth";
|
||||
|
||||
#scope_file
|
||||
|
||||
#import "Basic"; // For assert
|
||||
|
||||
clay :: #library,no_dll "linux/clay";
|
||||
|
||||
#run {
|
||||
{
|
||||
instance: String;
|
||||
assert(((cast(*void)(*instance.length)) - cast(*void)(*instance)) == 0, "String.length has unexpected offset % instead of 0", ((cast(*void)(*instance.length)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(String.length)) == 4, "String.length has unexpected size % instead of 4", size_of(type_of(String.length)));
|
||||
assert(((cast(*void)(*instance.chars)) - cast(*void)(*instance)) == 8, "String.chars has unexpected offset % instead of 8", ((cast(*void)(*instance.chars)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(String.chars)) == 8, "String.chars has unexpected size % instead of 8", size_of(type_of(String.chars)));
|
||||
assert(size_of(String) == 16, "String has size % instead of 16", size_of(String));
|
||||
}
|
||||
|
||||
{
|
||||
instance: _StringArray;
|
||||
assert(((cast(*void)(*instance.capacity)) - cast(*void)(*instance)) == 0, "_StringArray.capacity has unexpected offset % instead of 0", ((cast(*void)(*instance.capacity)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(_StringArray.capacity)) == 4, "_StringArray.capacity has unexpected size % instead of 4", size_of(type_of(_StringArray.capacity)));
|
||||
assert(((cast(*void)(*instance.length)) - cast(*void)(*instance)) == 4, "_StringArray.length has unexpected offset % instead of 4", ((cast(*void)(*instance.length)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(_StringArray.length)) == 4, "_StringArray.length has unexpected size % instead of 4", size_of(type_of(_StringArray.length)));
|
||||
assert(((cast(*void)(*instance.internalArray)) - cast(*void)(*instance)) == 8, "_StringArray.internalArray has unexpected offset % instead of 8", ((cast(*void)(*instance.internalArray)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(_StringArray.internalArray)) == 8, "_StringArray.internalArray has unexpected size % instead of 8", size_of(type_of(_StringArray.internalArray)));
|
||||
assert(size_of(_StringArray) == 16, "_StringArray has size % instead of 16", size_of(_StringArray));
|
||||
}
|
||||
|
||||
{
|
||||
instance: Arena;
|
||||
assert(((cast(*void)(*instance.nextAllocation)) - cast(*void)(*instance)) == 0, "Arena.nextAllocation has unexpected offset % instead of 0", ((cast(*void)(*instance.nextAllocation)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Arena.nextAllocation)) == 8, "Arena.nextAllocation has unexpected size % instead of 8", size_of(type_of(Arena.nextAllocation)));
|
||||
assert(((cast(*void)(*instance.capacity)) - cast(*void)(*instance)) == 8, "Arena.capacity has unexpected offset % instead of 8", ((cast(*void)(*instance.capacity)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Arena.capacity)) == 8, "Arena.capacity has unexpected size % instead of 8", size_of(type_of(Arena.capacity)));
|
||||
assert(((cast(*void)(*instance.memory)) - cast(*void)(*instance)) == 16, "Arena.memory has unexpected offset % instead of 16", ((cast(*void)(*instance.memory)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Arena.memory)) == 8, "Arena.memory has unexpected size % instead of 8", size_of(type_of(Arena.memory)));
|
||||
assert(size_of(Arena) == 24, "Arena has size % instead of 24", size_of(Arena));
|
||||
}
|
||||
|
||||
{
|
||||
instance: Dimensions;
|
||||
assert(((cast(*void)(*instance.width)) - cast(*void)(*instance)) == 0, "Dimensions.width has unexpected offset % instead of 0", ((cast(*void)(*instance.width)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Dimensions.width)) == 4, "Dimensions.width has unexpected size % instead of 4", size_of(type_of(Dimensions.width)));
|
||||
assert(((cast(*void)(*instance.height)) - cast(*void)(*instance)) == 4, "Dimensions.height has unexpected offset % instead of 4", ((cast(*void)(*instance.height)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Dimensions.height)) == 4, "Dimensions.height has unexpected size % instead of 4", size_of(type_of(Dimensions.height)));
|
||||
assert(size_of(Dimensions) == 8, "Dimensions has size % instead of 8", size_of(Dimensions));
|
||||
}
|
||||
|
||||
{
|
||||
instance: Color;
|
||||
assert(((cast(*void)(*instance.r)) - cast(*void)(*instance)) == 0, "Color.r has unexpected offset % instead of 0", ((cast(*void)(*instance.r)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Color.r)) == 4, "Color.r has unexpected size % instead of 4", size_of(type_of(Color.r)));
|
||||
assert(((cast(*void)(*instance.g)) - cast(*void)(*instance)) == 4, "Color.g has unexpected offset % instead of 4", ((cast(*void)(*instance.g)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Color.g)) == 4, "Color.g has unexpected size % instead of 4", size_of(type_of(Color.g)));
|
||||
assert(((cast(*void)(*instance.b)) - cast(*void)(*instance)) == 8, "Color.b has unexpected offset % instead of 8", ((cast(*void)(*instance.b)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Color.b)) == 4, "Color.b has unexpected size % instead of 4", size_of(type_of(Color.b)));
|
||||
assert(((cast(*void)(*instance.a)) - cast(*void)(*instance)) == 12, "Color.a has unexpected offset % instead of 12", ((cast(*void)(*instance.a)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Color.a)) == 4, "Color.a has unexpected size % instead of 4", size_of(type_of(Color.a)));
|
||||
assert(size_of(Color) == 16, "Color has size % instead of 16", size_of(Color));
|
||||
}
|
||||
|
||||
{
|
||||
instance: BoundingBox;
|
||||
assert(((cast(*void)(*instance.x)) - cast(*void)(*instance)) == 0, "BoundingBox.x has unexpected offset % instead of 0", ((cast(*void)(*instance.x)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(BoundingBox.x)) == 4, "BoundingBox.x has unexpected size % instead of 4", size_of(type_of(BoundingBox.x)));
|
||||
assert(((cast(*void)(*instance.y)) - cast(*void)(*instance)) == 4, "BoundingBox.y has unexpected offset % instead of 4", ((cast(*void)(*instance.y)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(BoundingBox.y)) == 4, "BoundingBox.y has unexpected size % instead of 4", size_of(type_of(BoundingBox.y)));
|
||||
assert(((cast(*void)(*instance.width)) - cast(*void)(*instance)) == 8, "BoundingBox.width has unexpected offset % instead of 8", ((cast(*void)(*instance.width)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(BoundingBox.width)) == 4, "BoundingBox.width has unexpected size % instead of 4", size_of(type_of(BoundingBox.width)));
|
||||
assert(((cast(*void)(*instance.height)) - cast(*void)(*instance)) == 12, "BoundingBox.height has unexpected offset % instead of 12", ((cast(*void)(*instance.height)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(BoundingBox.height)) == 4, "BoundingBox.height has unexpected size % instead of 4", size_of(type_of(BoundingBox.height)));
|
||||
assert(size_of(BoundingBox) == 16, "BoundingBox has size % instead of 16", size_of(BoundingBox));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ElementId;
|
||||
assert(((cast(*void)(*instance.id)) - cast(*void)(*instance)) == 0, "ElementId.id has unexpected offset % instead of 0", ((cast(*void)(*instance.id)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementId.id)) == 4, "ElementId.id has unexpected size % instead of 4", size_of(type_of(ElementId.id)));
|
||||
assert(((cast(*void)(*instance.offset)) - cast(*void)(*instance)) == 4, "ElementId.offset has unexpected offset % instead of 4", ((cast(*void)(*instance.offset)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementId.offset)) == 4, "ElementId.offset has unexpected size % instead of 4", size_of(type_of(ElementId.offset)));
|
||||
assert(((cast(*void)(*instance.baseId)) - cast(*void)(*instance)) == 8, "ElementId.baseId has unexpected offset % instead of 8", ((cast(*void)(*instance.baseId)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementId.baseId)) == 4, "ElementId.baseId has unexpected size % instead of 4", size_of(type_of(ElementId.baseId)));
|
||||
assert(((cast(*void)(*instance.stringId)) - cast(*void)(*instance)) == 16, "ElementId.stringId has unexpected offset % instead of 16", ((cast(*void)(*instance.stringId)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementId.stringId)) == 16, "ElementId.stringId has unexpected size % instead of 16", size_of(type_of(ElementId.stringId)));
|
||||
assert(size_of(ElementId) == 32, "ElementId has size % instead of 32", size_of(ElementId));
|
||||
}
|
||||
|
||||
{
|
||||
instance: CornerRadius;
|
||||
assert(((cast(*void)(*instance.topLeft)) - cast(*void)(*instance)) == 0, "CornerRadius.topLeft has unexpected offset % instead of 0", ((cast(*void)(*instance.topLeft)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(CornerRadius.topLeft)) == 4, "CornerRadius.topLeft has unexpected size % instead of 4", size_of(type_of(CornerRadius.topLeft)));
|
||||
assert(((cast(*void)(*instance.topRight)) - cast(*void)(*instance)) == 4, "CornerRadius.topRight has unexpected offset % instead of 4", ((cast(*void)(*instance.topRight)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(CornerRadius.topRight)) == 4, "CornerRadius.topRight has unexpected size % instead of 4", size_of(type_of(CornerRadius.topRight)));
|
||||
assert(((cast(*void)(*instance.bottomLeft)) - cast(*void)(*instance)) == 8, "CornerRadius.bottomLeft has unexpected offset % instead of 8", ((cast(*void)(*instance.bottomLeft)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(CornerRadius.bottomLeft)) == 4, "CornerRadius.bottomLeft has unexpected size % instead of 4", size_of(type_of(CornerRadius.bottomLeft)));
|
||||
assert(((cast(*void)(*instance.bottomRight)) - cast(*void)(*instance)) == 12, "CornerRadius.bottomRight has unexpected offset % instead of 12", ((cast(*void)(*instance.bottomRight)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(CornerRadius.bottomRight)) == 4, "CornerRadius.bottomRight has unexpected size % instead of 4", size_of(type_of(CornerRadius.bottomRight)));
|
||||
assert(size_of(CornerRadius) == 16, "CornerRadius has size % instead of 16", size_of(CornerRadius));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ChildAlignment;
|
||||
assert(((cast(*void)(*instance.x)) - cast(*void)(*instance)) == 0, "ChildAlignment.x has unexpected offset % instead of 0", ((cast(*void)(*instance.x)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ChildAlignment.x)) == 1, "ChildAlignment.x has unexpected size % instead of 1", size_of(type_of(ChildAlignment.x)));
|
||||
assert(((cast(*void)(*instance.y)) - cast(*void)(*instance)) == 1, "ChildAlignment.y has unexpected offset % instead of 1", ((cast(*void)(*instance.y)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ChildAlignment.y)) == 1, "ChildAlignment.y has unexpected size % instead of 1", size_of(type_of(ChildAlignment.y)));
|
||||
assert(size_of(ChildAlignment) == 2, "ChildAlignment has size % instead of 2", size_of(ChildAlignment));
|
||||
}
|
||||
|
||||
{
|
||||
instance: SizingMinMax;
|
||||
assert(((cast(*void)(*instance.min)) - cast(*void)(*instance)) == 0, "SizingMinMax.min has unexpected offset % instead of 0", ((cast(*void)(*instance.min)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(SizingMinMax.min)) == 4, "SizingMinMax.min has unexpected size % instead of 4", size_of(type_of(SizingMinMax.min)));
|
||||
assert(((cast(*void)(*instance.max)) - cast(*void)(*instance)) == 4, "SizingMinMax.max has unexpected offset % instead of 4", ((cast(*void)(*instance.max)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(SizingMinMax.max)) == 4, "SizingMinMax.max has unexpected size % instead of 4", size_of(type_of(SizingMinMax.max)));
|
||||
assert(size_of(SizingMinMax) == 8, "SizingMinMax has size % instead of 8", size_of(SizingMinMax));
|
||||
}
|
||||
|
||||
{
|
||||
instance: SizingAxis;
|
||||
assert(((cast(*void)(*instance.size)) - cast(*void)(*instance)) == 0, "SizingAxis.size has unexpected offset % instead of 0", ((cast(*void)(*instance.size)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(SizingAxis.size)) == 8, "SizingAxis.size has unexpected size % instead of 8", size_of(type_of(SizingAxis.size)));
|
||||
assert(((cast(*void)(*instance.type)) - cast(*void)(*instance)) == 8, "SizingAxis.type has unexpected offset % instead of 8", ((cast(*void)(*instance.type)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(SizingAxis.type)) == 1, "SizingAxis.type has unexpected size % instead of 1", size_of(type_of(SizingAxis.type)));
|
||||
assert(size_of(SizingAxis) == 12, "SizingAxis has size % instead of 12", size_of(SizingAxis));
|
||||
}
|
||||
|
||||
{
|
||||
instance: Sizing;
|
||||
assert(((cast(*void)(*instance.width)) - cast(*void)(*instance)) == 0, "Sizing.width has unexpected offset % instead of 0", ((cast(*void)(*instance.width)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Sizing.width)) == 12, "Sizing.width has unexpected size % instead of 12", size_of(type_of(Sizing.width)));
|
||||
assert(((cast(*void)(*instance.height)) - cast(*void)(*instance)) == 12, "Sizing.height has unexpected offset % instead of 12", ((cast(*void)(*instance.height)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Sizing.height)) == 12, "Sizing.height has unexpected size % instead of 12", size_of(type_of(Sizing.height)));
|
||||
assert(size_of(Sizing) == 24, "Sizing has size % instead of 24", size_of(Sizing));
|
||||
}
|
||||
|
||||
{
|
||||
instance: Padding;
|
||||
assert(((cast(*void)(*instance.x)) - cast(*void)(*instance)) == 0, "Padding.x has unexpected offset % instead of 0", ((cast(*void)(*instance.x)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Padding.x)) == 2, "Padding.x has unexpected size % instead of 2", size_of(type_of(Padding.x)));
|
||||
assert(((cast(*void)(*instance.y)) - cast(*void)(*instance)) == 2, "Padding.y has unexpected offset % instead of 2", ((cast(*void)(*instance.y)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(Padding.y)) == 2, "Padding.y has unexpected size % instead of 2", size_of(type_of(Padding.y)));
|
||||
assert(size_of(Padding) == 4, "Padding has size % instead of 4", size_of(Padding));
|
||||
}
|
||||
|
||||
{
|
||||
instance: LayoutConfig;
|
||||
assert(((cast(*void)(*instance.sizing)) - cast(*void)(*instance)) == 0, "LayoutConfig.sizing has unexpected offset % instead of 0", ((cast(*void)(*instance.sizing)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(LayoutConfig.sizing)) == 24, "LayoutConfig.sizing has unexpected size % instead of 24", size_of(type_of(LayoutConfig.sizing)));
|
||||
assert(((cast(*void)(*instance.padding)) - cast(*void)(*instance)) == 24, "LayoutConfig.padding has unexpected offset % instead of 24", ((cast(*void)(*instance.padding)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(LayoutConfig.padding)) == 4, "LayoutConfig.padding has unexpected size % instead of 4", size_of(type_of(LayoutConfig.padding)));
|
||||
assert(((cast(*void)(*instance.childGap)) - cast(*void)(*instance)) == 28, "LayoutConfig.childGap has unexpected offset % instead of 28", ((cast(*void)(*instance.childGap)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(LayoutConfig.childGap)) == 2, "LayoutConfig.childGap has unexpected size % instead of 2", size_of(type_of(LayoutConfig.childGap)));
|
||||
assert(((cast(*void)(*instance.childAlignment)) - cast(*void)(*instance)) == 30, "LayoutConfig.childAlignment has unexpected offset % instead of 30", ((cast(*void)(*instance.childAlignment)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(LayoutConfig.childAlignment)) == 2, "LayoutConfig.childAlignment has unexpected size % instead of 2", size_of(type_of(LayoutConfig.childAlignment)));
|
||||
assert(((cast(*void)(*instance.layoutDirection)) - cast(*void)(*instance)) == 32, "LayoutConfig.layoutDirection has unexpected offset % instead of 32", ((cast(*void)(*instance.layoutDirection)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(LayoutConfig.layoutDirection)) == 1, "LayoutConfig.layoutDirection has unexpected size % instead of 1", size_of(type_of(LayoutConfig.layoutDirection)));
|
||||
assert(size_of(LayoutConfig) == 36, "LayoutConfig has size % instead of 36", size_of(LayoutConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: RectangleElementConfig;
|
||||
assert(((cast(*void)(*instance.color)) - cast(*void)(*instance)) == 0, "RectangleElementConfig.color has unexpected offset % instead of 0", ((cast(*void)(*instance.color)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RectangleElementConfig.color)) == 16, "RectangleElementConfig.color has unexpected size % instead of 16", size_of(type_of(RectangleElementConfig.color)));
|
||||
assert(((cast(*void)(*instance.cornerRadius)) - cast(*void)(*instance)) == 16, "RectangleElementConfig.cornerRadius has unexpected offset % instead of 16", ((cast(*void)(*instance.cornerRadius)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RectangleElementConfig.cornerRadius)) == 16, "RectangleElementConfig.cornerRadius has unexpected size % instead of 16", size_of(type_of(RectangleElementConfig.cornerRadius)));
|
||||
assert(size_of(RectangleElementConfig) == 32, "RectangleElementConfig has size % instead of 32", size_of(RectangleElementConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: TextElementConfig;
|
||||
assert(((cast(*void)(*instance.textColor)) - cast(*void)(*instance)) == 0, "TextElementConfig.textColor has unexpected offset % instead of 0", ((cast(*void)(*instance.textColor)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(TextElementConfig.textColor)) == 16, "TextElementConfig.textColor has unexpected size % instead of 16", size_of(type_of(TextElementConfig.textColor)));
|
||||
assert(((cast(*void)(*instance.fontId)) - cast(*void)(*instance)) == 16, "TextElementConfig.fontId has unexpected offset % instead of 16", ((cast(*void)(*instance.fontId)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(TextElementConfig.fontId)) == 2, "TextElementConfig.fontId has unexpected size % instead of 2", size_of(type_of(TextElementConfig.fontId)));
|
||||
assert(((cast(*void)(*instance.fontSize)) - cast(*void)(*instance)) == 18, "TextElementConfig.fontSize has unexpected offset % instead of 18", ((cast(*void)(*instance.fontSize)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(TextElementConfig.fontSize)) == 2, "TextElementConfig.fontSize has unexpected size % instead of 2", size_of(type_of(TextElementConfig.fontSize)));
|
||||
assert(((cast(*void)(*instance.letterSpacing)) - cast(*void)(*instance)) == 20, "TextElementConfig.letterSpacing has unexpected offset % instead of 20", ((cast(*void)(*instance.letterSpacing)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(TextElementConfig.letterSpacing)) == 2, "TextElementConfig.letterSpacing has unexpected size % instead of 2", size_of(type_of(TextElementConfig.letterSpacing)));
|
||||
assert(((cast(*void)(*instance.lineHeight)) - cast(*void)(*instance)) == 22, "TextElementConfig.lineHeight has unexpected offset % instead of 22", ((cast(*void)(*instance.lineHeight)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(TextElementConfig.lineHeight)) == 2, "TextElementConfig.lineHeight has unexpected size % instead of 2", size_of(type_of(TextElementConfig.lineHeight)));
|
||||
assert(((cast(*void)(*instance.wrapMode)) - cast(*void)(*instance)) == 24, "TextElementConfig.wrapMode has unexpected offset % instead of 24", ((cast(*void)(*instance.wrapMode)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(TextElementConfig.wrapMode)) == 4, "TextElementConfig.wrapMode has unexpected size % instead of 4", size_of(type_of(TextElementConfig.wrapMode)));
|
||||
assert(size_of(TextElementConfig) == 28, "TextElementConfig has size % instead of 28", size_of(TextElementConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ImageElementConfig;
|
||||
assert(((cast(*void)(*instance.imageData)) - cast(*void)(*instance)) == 0, "ImageElementConfig.imageData has unexpected offset % instead of 0", ((cast(*void)(*instance.imageData)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ImageElementConfig.imageData)) == 8, "ImageElementConfig.imageData has unexpected size % instead of 8", size_of(type_of(ImageElementConfig.imageData)));
|
||||
assert(((cast(*void)(*instance.sourceDimensions)) - cast(*void)(*instance)) == 8, "ImageElementConfig.sourceDimensions has unexpected offset % instead of 8", ((cast(*void)(*instance.sourceDimensions)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ImageElementConfig.sourceDimensions)) == 8, "ImageElementConfig.sourceDimensions has unexpected size % instead of 8", size_of(type_of(ImageElementConfig.sourceDimensions)));
|
||||
assert(size_of(ImageElementConfig) == 16, "ImageElementConfig has size % instead of 16", size_of(ImageElementConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: FloatingAttachPoints;
|
||||
assert(((cast(*void)(*instance.element)) - cast(*void)(*instance)) == 0, "FloatingAttachPoints.element has unexpected offset % instead of 0", ((cast(*void)(*instance.element)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingAttachPoints.element)) == 1, "FloatingAttachPoints.element has unexpected size % instead of 1", size_of(type_of(FloatingAttachPoints.element)));
|
||||
assert(((cast(*void)(*instance.parent)) - cast(*void)(*instance)) == 1, "FloatingAttachPoints.parent has unexpected offset % instead of 1", ((cast(*void)(*instance.parent)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingAttachPoints.parent)) == 1, "FloatingAttachPoints.parent has unexpected size % instead of 1", size_of(type_of(FloatingAttachPoints.parent)));
|
||||
assert(size_of(FloatingAttachPoints) == 2, "FloatingAttachPoints has size % instead of 2", size_of(FloatingAttachPoints));
|
||||
}
|
||||
|
||||
{
|
||||
instance: FloatingElementConfig;
|
||||
assert(((cast(*void)(*instance.offset)) - cast(*void)(*instance)) == 0, "FloatingElementConfig.offset has unexpected offset % instead of 0", ((cast(*void)(*instance.offset)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingElementConfig.offset)) == 8, "FloatingElementConfig.offset has unexpected size % instead of 8", size_of(type_of(FloatingElementConfig.offset)));
|
||||
assert(((cast(*void)(*instance.expand)) - cast(*void)(*instance)) == 8, "FloatingElementConfig.expand has unexpected offset % instead of 8", ((cast(*void)(*instance.expand)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingElementConfig.expand)) == 8, "FloatingElementConfig.expand has unexpected size % instead of 8", size_of(type_of(FloatingElementConfig.expand)));
|
||||
assert(((cast(*void)(*instance.zIndex)) - cast(*void)(*instance)) == 16, "FloatingElementConfig.zIndex has unexpected offset % instead of 16", ((cast(*void)(*instance.zIndex)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingElementConfig.zIndex)) == 2, "FloatingElementConfig.zIndex has unexpected size % instead of 2", size_of(type_of(FloatingElementConfig.zIndex)));
|
||||
assert(((cast(*void)(*instance.parentId)) - cast(*void)(*instance)) == 20, "FloatingElementConfig.parentId has unexpected offset % instead of 20", ((cast(*void)(*instance.parentId)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingElementConfig.parentId)) == 4, "FloatingElementConfig.parentId has unexpected size % instead of 4", size_of(type_of(FloatingElementConfig.parentId)));
|
||||
assert(((cast(*void)(*instance.attachment)) - cast(*void)(*instance)) == 24, "FloatingElementConfig.attachment has unexpected offset % instead of 24", ((cast(*void)(*instance.attachment)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingElementConfig.attachment)) == 2, "FloatingElementConfig.attachment has unexpected size % instead of 2", size_of(type_of(FloatingElementConfig.attachment)));
|
||||
assert(((cast(*void)(*instance.pointerCaptureMode)) - cast(*void)(*instance)) == 28, "FloatingElementConfig.pointerCaptureMode has unexpected offset % instead of 28", ((cast(*void)(*instance.pointerCaptureMode)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(FloatingElementConfig.pointerCaptureMode)) == 4, "FloatingElementConfig.pointerCaptureMode has unexpected size % instead of 4", size_of(type_of(FloatingElementConfig.pointerCaptureMode)));
|
||||
assert(size_of(FloatingElementConfig) == 32, "FloatingElementConfig has size % instead of 32", size_of(FloatingElementConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: CustomElementConfig;
|
||||
assert(((cast(*void)(*instance.customData)) - cast(*void)(*instance)) == 0, "CustomElementConfig.customData has unexpected offset % instead of 0", ((cast(*void)(*instance.customData)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(CustomElementConfig.customData)) == 8, "CustomElementConfig.customData has unexpected size % instead of 8", size_of(type_of(CustomElementConfig.customData)));
|
||||
assert(size_of(CustomElementConfig) == 8, "CustomElementConfig has size % instead of 8", size_of(CustomElementConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ScrollElementConfig;
|
||||
assert(((cast(*void)(*instance.horizontal)) - cast(*void)(*instance)) == 0, "ScrollElementConfig.horizontal has unexpected offset % instead of 0", ((cast(*void)(*instance.horizontal)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ScrollElementConfig.horizontal)) == 1, "ScrollElementConfig.horizontal has unexpected size % instead of 1", size_of(type_of(ScrollElementConfig.horizontal)));
|
||||
assert(((cast(*void)(*instance.vertical)) - cast(*void)(*instance)) == 1, "ScrollElementConfig.vertical has unexpected offset % instead of 1", ((cast(*void)(*instance.vertical)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ScrollElementConfig.vertical)) == 1, "ScrollElementConfig.vertical has unexpected size % instead of 1", size_of(type_of(ScrollElementConfig.vertical)));
|
||||
assert(size_of(ScrollElementConfig) == 2, "ScrollElementConfig has size % instead of 2", size_of(ScrollElementConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ElementConfigUnion;
|
||||
assert(((cast(*void)(*instance.rectangleElementConfig)) - cast(*void)(*instance)) == 0, "ElementConfigUnion.rectangleElementConfig has unexpected offset % instead of 0", ((cast(*void)(*instance.rectangleElementConfig)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfigUnion.rectangleElementConfig)) == 8, "ElementConfigUnion.rectangleElementConfig has unexpected size % instead of 8", size_of(type_of(ElementConfigUnion.rectangleElementConfig)));
|
||||
assert(((cast(*void)(*instance.textElementConfig)) - cast(*void)(*instance)) == 0, "ElementConfigUnion.textElementConfig has unexpected offset % instead of 0", ((cast(*void)(*instance.textElementConfig)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfigUnion.textElementConfig)) == 8, "ElementConfigUnion.textElementConfig has unexpected size % instead of 8", size_of(type_of(ElementConfigUnion.textElementConfig)));
|
||||
assert(((cast(*void)(*instance.imageElementConfig)) - cast(*void)(*instance)) == 0, "ElementConfigUnion.imageElementConfig has unexpected offset % instead of 0", ((cast(*void)(*instance.imageElementConfig)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfigUnion.imageElementConfig)) == 8, "ElementConfigUnion.imageElementConfig has unexpected size % instead of 8", size_of(type_of(ElementConfigUnion.imageElementConfig)));
|
||||
assert(((cast(*void)(*instance.floatingElementConfig)) - cast(*void)(*instance)) == 0, "ElementConfigUnion.floatingElementConfig has unexpected offset % instead of 0", ((cast(*void)(*instance.floatingElementConfig)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfigUnion.floatingElementConfig)) == 8, "ElementConfigUnion.floatingElementConfig has unexpected size % instead of 8", size_of(type_of(ElementConfigUnion.floatingElementConfig)));
|
||||
assert(((cast(*void)(*instance.customElementConfig)) - cast(*void)(*instance)) == 0, "ElementConfigUnion.customElementConfig has unexpected offset % instead of 0", ((cast(*void)(*instance.customElementConfig)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfigUnion.customElementConfig)) == 8, "ElementConfigUnion.customElementConfig has unexpected size % instead of 8", size_of(type_of(ElementConfigUnion.customElementConfig)));
|
||||
assert(((cast(*void)(*instance.scrollElementConfig)) - cast(*void)(*instance)) == 0, "ElementConfigUnion.scrollElementConfig has unexpected offset % instead of 0", ((cast(*void)(*instance.scrollElementConfig)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfigUnion.scrollElementConfig)) == 8, "ElementConfigUnion.scrollElementConfig has unexpected size % instead of 8", size_of(type_of(ElementConfigUnion.scrollElementConfig)));
|
||||
assert(((cast(*void)(*instance.borderElementConfig)) - cast(*void)(*instance)) == 0, "ElementConfigUnion.borderElementConfig has unexpected offset % instead of 0", ((cast(*void)(*instance.borderElementConfig)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfigUnion.borderElementConfig)) == 8, "ElementConfigUnion.borderElementConfig has unexpected size % instead of 8", size_of(type_of(ElementConfigUnion.borderElementConfig)));
|
||||
assert(size_of(ElementConfigUnion) == 8, "ElementConfigUnion has size % instead of 8", size_of(ElementConfigUnion));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ElementConfig;
|
||||
assert(((cast(*void)(*instance.type)) - cast(*void)(*instance)) == 0, "ElementConfig.type has unexpected offset % instead of 0", ((cast(*void)(*instance.type)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfig.type)) == 1, "ElementConfig.type has unexpected size % instead of 1", size_of(type_of(ElementConfig.type)));
|
||||
assert(((cast(*void)(*instance.config)) - cast(*void)(*instance)) == 8, "ElementConfig.config has unexpected offset % instead of 8", ((cast(*void)(*instance.config)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ElementConfig.config)) == 8, "ElementConfig.config has unexpected size % instead of 8", size_of(type_of(ElementConfig.config)));
|
||||
assert(size_of(ElementConfig) == 16, "ElementConfig has size % instead of 16", size_of(ElementConfig));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ScrollContainerData;
|
||||
assert(((cast(*void)(*instance.scrollPosition)) - cast(*void)(*instance)) == 0, "ScrollContainerData.scrollPosition has unexpected offset % instead of 0", ((cast(*void)(*instance.scrollPosition)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ScrollContainerData.scrollPosition)) == 8, "ScrollContainerData.scrollPosition has unexpected size % instead of 8", size_of(type_of(ScrollContainerData.scrollPosition)));
|
||||
assert(((cast(*void)(*instance.scrollContainerDimensions)) - cast(*void)(*instance)) == 8, "ScrollContainerData.scrollContainerDimensions has unexpected offset % instead of 8", ((cast(*void)(*instance.scrollContainerDimensions)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ScrollContainerData.scrollContainerDimensions)) == 8, "ScrollContainerData.scrollContainerDimensions has unexpected size % instead of 8", size_of(type_of(ScrollContainerData.scrollContainerDimensions)));
|
||||
assert(((cast(*void)(*instance.contentDimensions)) - cast(*void)(*instance)) == 16, "ScrollContainerData.contentDimensions has unexpected offset % instead of 16", ((cast(*void)(*instance.contentDimensions)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ScrollContainerData.contentDimensions)) == 8, "ScrollContainerData.contentDimensions has unexpected size % instead of 8", size_of(type_of(ScrollContainerData.contentDimensions)));
|
||||
assert(((cast(*void)(*instance.config)) - cast(*void)(*instance)) == 24, "ScrollContainerData.config has unexpected offset % instead of 24", ((cast(*void)(*instance.config)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ScrollContainerData.config)) == 2, "ScrollContainerData.config has unexpected size % instead of 2", size_of(type_of(ScrollContainerData.config)));
|
||||
assert(((cast(*void)(*instance.found)) - cast(*void)(*instance)) == 26, "ScrollContainerData.found has unexpected offset % instead of 26", ((cast(*void)(*instance.found)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ScrollContainerData.found)) == 1, "ScrollContainerData.found has unexpected size % instead of 1", size_of(type_of(ScrollContainerData.found)));
|
||||
assert(size_of(ScrollContainerData) == 32, "ScrollContainerData has size % instead of 32", size_of(ScrollContainerData));
|
||||
}
|
||||
|
||||
{
|
||||
instance: RenderCommand;
|
||||
assert(((cast(*void)(*instance.boundingBox)) - cast(*void)(*instance)) == 0, "RenderCommand.boundingBox has unexpected offset % instead of 0", ((cast(*void)(*instance.boundingBox)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommand.boundingBox)) == 16, "RenderCommand.boundingBox has unexpected size % instead of 16", size_of(type_of(RenderCommand.boundingBox)));
|
||||
assert(((cast(*void)(*instance.config)) - cast(*void)(*instance)) == 16, "RenderCommand.config has unexpected offset % instead of 16", ((cast(*void)(*instance.config)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommand.config)) == 8, "RenderCommand.config has unexpected size % instead of 8", size_of(type_of(RenderCommand.config)));
|
||||
assert(((cast(*void)(*instance.text)) - cast(*void)(*instance)) == 24, "RenderCommand.text has unexpected offset % instead of 24", ((cast(*void)(*instance.text)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommand.text)) == 16, "RenderCommand.text has unexpected size % instead of 16", size_of(type_of(RenderCommand.text)));
|
||||
assert(((cast(*void)(*instance.id)) - cast(*void)(*instance)) == 40, "RenderCommand.id has unexpected offset % instead of 40", ((cast(*void)(*instance.id)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommand.id)) == 4, "RenderCommand.id has unexpected size % instead of 4", size_of(type_of(RenderCommand.id)));
|
||||
assert(((cast(*void)(*instance.commandType)) - cast(*void)(*instance)) == 44, "RenderCommand.commandType has unexpected offset % instead of 44", ((cast(*void)(*instance.commandType)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommand.commandType)) == 1, "RenderCommand.commandType has unexpected size % instead of 1", size_of(type_of(RenderCommand.commandType)));
|
||||
assert(size_of(RenderCommand) == 48, "RenderCommand has size % instead of 48", size_of(RenderCommand));
|
||||
}
|
||||
|
||||
{
|
||||
instance: RenderCommandArray;
|
||||
assert(((cast(*void)(*instance.capacity)) - cast(*void)(*instance)) == 0, "RenderCommandArray.capacity has unexpected offset % instead of 0", ((cast(*void)(*instance.capacity)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommandArray.capacity)) == 4, "RenderCommandArray.capacity has unexpected size % instead of 4", size_of(type_of(RenderCommandArray.capacity)));
|
||||
assert(((cast(*void)(*instance.length)) - cast(*void)(*instance)) == 4, "RenderCommandArray.length has unexpected offset % instead of 4", ((cast(*void)(*instance.length)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommandArray.length)) == 4, "RenderCommandArray.length has unexpected size % instead of 4", size_of(type_of(RenderCommandArray.length)));
|
||||
assert(((cast(*void)(*instance.internalArray)) - cast(*void)(*instance)) == 8, "RenderCommandArray.internalArray has unexpected offset % instead of 8", ((cast(*void)(*instance.internalArray)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(RenderCommandArray.internalArray)) == 8, "RenderCommandArray.internalArray has unexpected size % instead of 8", size_of(type_of(RenderCommandArray.internalArray)));
|
||||
assert(size_of(RenderCommandArray) == 16, "RenderCommandArray has size % instead of 16", size_of(RenderCommandArray));
|
||||
}
|
||||
|
||||
{
|
||||
instance: PointerData;
|
||||
assert(((cast(*void)(*instance.position)) - cast(*void)(*instance)) == 0, "PointerData.position has unexpected offset % instead of 0", ((cast(*void)(*instance.position)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(PointerData.position)) == 8, "PointerData.position has unexpected size % instead of 8", size_of(type_of(PointerData.position)));
|
||||
assert(((cast(*void)(*instance.state)) - cast(*void)(*instance)) == 8, "PointerData.state has unexpected offset % instead of 8", ((cast(*void)(*instance.state)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(PointerData.state)) == 4, "PointerData.state has unexpected size % instead of 4", size_of(type_of(PointerData.state)));
|
||||
assert(size_of(PointerData) == 12, "PointerData has size % instead of 12", size_of(PointerData));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ErrorData;
|
||||
assert(((cast(*void)(*instance.errorType)) - cast(*void)(*instance)) == 0, "ErrorData.errorType has unexpected offset % instead of 0", ((cast(*void)(*instance.errorType)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ErrorData.errorType)) == 4, "ErrorData.errorType has unexpected size % instead of 4", size_of(type_of(ErrorData.errorType)));
|
||||
assert(((cast(*void)(*instance.errorText)) - cast(*void)(*instance)) == 8, "ErrorData.errorText has unexpected offset % instead of 8", ((cast(*void)(*instance.errorText)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ErrorData.errorText)) == 16, "ErrorData.errorText has unexpected size % instead of 16", size_of(type_of(ErrorData.errorText)));
|
||||
assert(((cast(*void)(*instance.userData)) - cast(*void)(*instance)) == 24, "ErrorData.userData has unexpected offset % instead of 24", ((cast(*void)(*instance.userData)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ErrorData.userData)) == 8, "ErrorData.userData has unexpected size % instead of 8", size_of(type_of(ErrorData.userData)));
|
||||
assert(size_of(ErrorData) == 32, "ErrorData has size % instead of 32", size_of(ErrorData));
|
||||
}
|
||||
|
||||
{
|
||||
instance: ErrorHandler;
|
||||
assert(((cast(*void)(*instance.errorHandlerFunction)) - cast(*void)(*instance)) == 0, "ErrorHandler.errorHandlerFunction has unexpected offset % instead of 0", ((cast(*void)(*instance.errorHandlerFunction)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ErrorHandler.errorHandlerFunction)) == 8, "ErrorHandler.errorHandlerFunction has unexpected size % instead of 8", size_of(type_of(ErrorHandler.errorHandlerFunction)));
|
||||
assert(((cast(*void)(*instance.userData)) - cast(*void)(*instance)) == 8, "ErrorHandler.userData has unexpected offset % instead of 8", ((cast(*void)(*instance.userData)) - cast(*void)(*instance)));
|
||||
assert(size_of(type_of(ErrorHandler.userData)) == 8, "ErrorHandler.userData has unexpected size % instead of 8", size_of(type_of(ErrorHandler.userData)));
|
||||
assert(size_of(ErrorHandler) == 16, "ErrorHandler has size % instead of 16", size_of(ErrorHandler));
|
||||
}
|
||||
}
|
||||
|
BIN
bindings/jai/clay-jai/linux/clay.a
Normal file
BIN
bindings/jai/clay-jai/linux/clay.a
Normal file
Binary file not shown.
296
bindings/jai/clay-jai/module.jai
Normal file
296
bindings/jai/clay-jai/module.jai
Normal file
@ -0,0 +1,296 @@
|
||||
/*
|
||||
These bindings adapt the CLAY macro using some for_expansion trickery, allowing a syntax similar to the one in the Odin bindings.
|
||||
I'll try to explain here why I did it that way.
|
||||
|
||||
In Odin, they can mark the procedure with deferred_none, allowing to call a proc after the current one, which works well with ifs.
|
||||
|
||||
@(require_results, deferred_none = _CloseElement)
|
||||
UI :: proc(configs: ..TypedConfig) -> bool {}
|
||||
|
||||
You can then use it like so :
|
||||
|
||||
if UI(Layout(), etc..) {Children ...}
|
||||
|
||||
So I tried to replicate this in Jai. The first thing I did was to try making a macro returning a bool with a backticked defer in it.
|
||||
|
||||
UI :: (configs: ..TypedConfig) -> bool #must #expand {
|
||||
`defer EndElement();
|
||||
return true;
|
||||
}
|
||||
|
||||
But this doesn't work if you have two elements side to side, as the end of the first element will be called after the start and the end of the second one.
|
||||
|
||||
Another option used in these bindings : https://github.com/nick-celestin-zizic/clay-jai is to have that defer like above and have the macro return nothing. You can then use it like that :
|
||||
|
||||
{ UI(Layout()); Children(); }
|
||||
|
||||
But I'm not a big fan of that since it's possible to forget the scope braces or to put the children before the element.
|
||||
|
||||
TODO This part is wrong... delete it and write the code that works
|
||||
|
||||
Another option to consider is to pass a code block to a macro that puts it between the start and the end.
|
||||
|
||||
UI :: (id: ElementId, layout: LayoutConfig, configs: ..ElementConfig, $code: Code) {
|
||||
OpenElement();
|
||||
...
|
||||
#insert code;
|
||||
CloseElement();
|
||||
}
|
||||
|
||||
UI(..., #code {
|
||||
Children();
|
||||
});
|
||||
|
||||
However this prevents to refer to variables from the previous scope, and it's also a bit akward to type.
|
||||
|
||||
The final solution I found, inspired by the fact that CLAY uses a for loop behind the scene, was to use Jai's for_expansions.
|
||||
Here is how it works :
|
||||
|
||||
InternalElementConfigArray :: struct {
|
||||
configs: [] TypedConfig;
|
||||
}
|
||||
|
||||
Element :: (configs: ..TypedConfig) -> InternalElementConfigArray #expand {
|
||||
return .{configs};
|
||||
}
|
||||
|
||||
for_expansion :: (configs_array: InternalElementConfigArray, body: Code, _: For_Flags) #expand {
|
||||
Jai forces the definition of these
|
||||
`it_index := 0;
|
||||
`it := 0;
|
||||
_OpenElement();
|
||||
...
|
||||
#insert body;
|
||||
_CloseElement();
|
||||
}
|
||||
|
||||
As you can see it's kinda similar to the previous one, but doesn't have the limitation on refering to variable from the calling scope.
|
||||
Element builds an InternalElementConfigArray that has an array to the TypedConfigs, which will be passed to the for_expansion when placed after a for (this is a Jai feature).
|
||||
This then allows to write something like :
|
||||
|
||||
for Element(Layout()) { Children(); }
|
||||
|
||||
With the downside that it's not obvious why the for is there before reading the documentation.
|
||||
*/
|
||||
|
||||
Vector2 :: Math.Vector2;
|
||||
|
||||
ElementConfigType :: enum u8 {
|
||||
NONE :: 0;
|
||||
RECTANGLE :: 1;
|
||||
BORDER_CONTAINER :: 2;
|
||||
FLOATING_CONTAINER :: 4;
|
||||
SCROLL_CONTAINER :: 8;
|
||||
IMAGE :: 16;
|
||||
TEXT :: 32;
|
||||
CUSTOM :: 64;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_NONE :: NONE;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_RECTANGLE :: RECTANGLE;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_BORDER_CONTAINER :: BORDER_CONTAINER;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_FLOATING_CONTAINER :: FLOATING_CONTAINER;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_SCROLL_CONTAINER :: SCROLL_CONTAINER;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_IMAGE :: IMAGE;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_TEXT :: TEXT;
|
||||
CLAY__ELEMENT_CONFIG_TYPE_CUSTOM :: CUSTOM;
|
||||
|
||||
// Jai bindings specific types, please don't assume any value in those
|
||||
// a it might change if the enums above overlap with it
|
||||
// TODO Check if these values need to be powers of two
|
||||
ID :: 250;
|
||||
LAYOUT :: 251;
|
||||
}
|
||||
|
||||
// This is passed to UI so that we can omit layout
|
||||
TypedConfig :: struct {
|
||||
type: ElementConfigType;
|
||||
config: *void;
|
||||
id: ElementId;
|
||||
}
|
||||
|
||||
BorderData :: struct {
|
||||
width: u32;
|
||||
color: Color;
|
||||
}
|
||||
|
||||
BorderElementConfig :: struct {
|
||||
left: BorderData;
|
||||
right: BorderData;
|
||||
top: BorderData;
|
||||
bottom: BorderData;
|
||||
betweenChildren: BorderData;
|
||||
cornerRadius: CornerRadius;
|
||||
}
|
||||
|
||||
make_string :: (str: string) -> String {
|
||||
clay_string := String.{cast(s32, str.count), str.data};
|
||||
return clay_string;
|
||||
}
|
||||
|
||||
global_counter := 0;
|
||||
|
||||
for_expansion :: (configs_array: InternalElementConfigArray, body: Code, _: For_Flags) #expand {
|
||||
// Jai forces the definition of these
|
||||
`it_index := 0;
|
||||
`it := 0;
|
||||
|
||||
_OpenElement();
|
||||
for config : configs_array.configs {
|
||||
if config.type == {
|
||||
case .ID;
|
||||
_AttachId(config.id);
|
||||
case .LAYOUT;
|
||||
_AttachLayoutConfig(cast(*LayoutConfig, config.config));
|
||||
case;
|
||||
// config.config is a *void, it stores the address of the pointer that is stored in the union
|
||||
// as ElementConfigUnion is a union of structs. We can't cast pointers directly to structs,
|
||||
// we first cast the address of the *void and then dereference it.
|
||||
// Maybe there's a cast modifier to avoid this, but I don't know it (no_check and trunc didn't work).
|
||||
_AttachElementConfig(cast(*ElementConfigUnion, *config.config).*, config.type);
|
||||
}
|
||||
}
|
||||
_ElementPostConfiguration();
|
||||
|
||||
#insert body;
|
||||
|
||||
_CloseElement();
|
||||
}
|
||||
|
||||
Element :: (configs: ..TypedConfig) -> InternalElementConfigArray #expand {
|
||||
return .{configs};
|
||||
}
|
||||
|
||||
ID :: (label: string, index: u32 = 0) -> TypedConfig {
|
||||
return .{type = .ID, id = _HashString(make_string(label), index, 0)};
|
||||
}
|
||||
|
||||
Layout :: (config: LayoutConfig) -> TypedConfig {
|
||||
return .{type = .LAYOUT, config = _StoreLayoutConfig(config)};
|
||||
}
|
||||
|
||||
Rectangle :: (config: RectangleElementConfig) -> TypedConfig {
|
||||
return .{
|
||||
type = .RECTANGLE,
|
||||
config = _StoreRectangleElementConfig(config)
|
||||
};
|
||||
}
|
||||
|
||||
Floating :: (config: FloatingElementConfig) -> TypedConfig {
|
||||
return .{type = .FLOATING_CONTAINER, config = _StoreFloatingElementConfig(config)};
|
||||
}
|
||||
|
||||
Scroll :: (config: ScrollElementConfig) -> TypedConfig {
|
||||
return .{type = .SCROLL_CONTAINER, config = _StoreScrollElementConfig(config)};
|
||||
}
|
||||
|
||||
Image :: (config: ImageElementConfig) -> TypedConfig {
|
||||
return .{type = .IMAGE, config = _StoreImageElementConfig(config)};
|
||||
}
|
||||
|
||||
Custom :: (config: CustomElementConfig) -> TypedConfig {
|
||||
return .{type = .CUSTOM, config = _StoreCustomElementConfig(config)};
|
||||
}
|
||||
|
||||
Border :: (config: BorderElementConfig) -> TypedConfig {
|
||||
return .{type = .BORDER, _StoreBorderElementConfig(config)};
|
||||
}
|
||||
|
||||
BorderOutside :: (outside_borders: BorderData) -> TypedConfig {
|
||||
return .{
|
||||
type = .BORDER,
|
||||
config = _StoreBorderElementConfig(BorderElementConfig.{
|
||||
left = outside_borders,
|
||||
right = outside_borders,
|
||||
top = outside_borders,
|
||||
bottom = outside_borders,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
BorderOutsideRadius :: (outside_borders: BorderData, radius: float) -> TypedConfig {
|
||||
return .{
|
||||
type = .BORDER,
|
||||
config = _StoreBorderElementConfig(.{
|
||||
left = outside_borders,
|
||||
right = outside_borders,
|
||||
top = outside_borders,
|
||||
bottom = outside_borders,
|
||||
cornerRadius = .{radius, radius, radius, radius},
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
BorderAll :: (all_borders: BorderData) -> TypedConfig {
|
||||
return .{
|
||||
type = .BORDER,
|
||||
config = _StoreBorderElementConfig(.{
|
||||
left = all_borders,
|
||||
right = all_borders,
|
||||
top = all_borders,
|
||||
bottom = all_borders,
|
||||
betweenChildren = all_borders,
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
BorderAllRadius :: (all_borders: BorderData, radius: float) -> TypedConfig {
|
||||
return .{
|
||||
type = .BORDER,
|
||||
config = _StoreBorderElementConfig(.{
|
||||
left = all_borders,
|
||||
right = all_borders,
|
||||
top = all_borders,
|
||||
bottom = all_borders,
|
||||
cornerRadius = .{radius, radius, radius, radius},
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
CornerRadiusAll :: (radius: float) -> CornerRadius {
|
||||
return .{radius, radius, radius, radius};
|
||||
}
|
||||
|
||||
Text :: (text: string, config: *TextElementConfig) {
|
||||
_OpenTextElement(make_string(text), config);
|
||||
}
|
||||
|
||||
TextConfig :: (config: TextElementConfig) -> *TextElementConfig {
|
||||
return _StoreTextElementConfig(config);
|
||||
}
|
||||
|
||||
SizingFit :: (size_min_max: SizingMinMax) -> SizingAxis {
|
||||
return .{type = .FIT, size = .{minMax = size_min_max}};
|
||||
}
|
||||
|
||||
SizingGrow :: (size_min_max: SizingMinMax = .{}) -> SizingAxis {
|
||||
return .{type = .GROW, size = .{minMax = size_min_max}};
|
||||
}
|
||||
|
||||
SizingFixed :: (size: float) -> SizingAxis {
|
||||
return .{type = .FIXED, size = .{minMax = .{size, size}}};
|
||||
}
|
||||
|
||||
SizingPercent :: (size_percent: float) -> SizingAxis {
|
||||
return .{type = .PERCENT, size = .{percent = size_percent}};
|
||||
}
|
||||
|
||||
GetElementId :: (str: string) -> ElementId {
|
||||
return GetElementId(make_string(str));
|
||||
}
|
||||
|
||||
#scope_module
|
||||
|
||||
Math :: #import "Math";
|
||||
Compiler :: #import "Compiler";
|
||||
ProgramPrint :: #import "Program_Print";
|
||||
|
||||
InternalElementConfigArray :: struct {
|
||||
configs: [] TypedConfig;
|
||||
}
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
#load "windows.jai";
|
||||
} else #if OS == .LINUX {
|
||||
#load "linux.jai";
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
2
bindings/jai/clay-jai/source/clay.c
Normal file
2
bindings/jai/clay-jai/source/clay.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define CLAY_IMPLEMENTATION
|
||||
#include "clay.h"
|
1293
bindings/jai/clay-jai/windows.jai
Normal file
1293
bindings/jai/clay-jai/windows.jai
Normal file
File diff suppressed because it is too large
Load Diff
BIN
bindings/jai/clay-jai/windows/clay.lib
Normal file
BIN
bindings/jai/clay-jai/windows/clay.lib
Normal file
Binary file not shown.
@ -0,0 +1,241 @@
|
||||
|
||||
RaylibFont :: struct {
|
||||
font_id: u16;
|
||||
font: Raylib.Font;
|
||||
}
|
||||
|
||||
g_raylib_fonts: [10]RaylibFont;
|
||||
|
||||
to_raylib_color :: (color: Clay.Color) -> Raylib.Color {
|
||||
return .{cast(u8) color.r, cast(u8) color.g, cast(u8) color.b, cast(u8) color.a};
|
||||
}
|
||||
|
||||
raylib_measure_text :: (text: *Clay.String, config: *Clay.TextElementConfig) -> Clay.Dimensions #c_call {
|
||||
text_size := Clay.Dimensions.{0, 0};
|
||||
|
||||
max_text_width: float = 0;
|
||||
line_text_width: float = 0;
|
||||
|
||||
text_height := cast(float)config.fontSize;
|
||||
font_to_use := g_raylib_fonts[config.fontId].font;
|
||||
|
||||
if text.length > 0 {
|
||||
for 0..(text.length - 1) {
|
||||
if text.chars[it] == #char "\n" {
|
||||
max_text_width = c_max(max_text_width, line_text_width);
|
||||
line_text_width = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
index := cast(s32, text.chars[it]) - 32;
|
||||
if font_to_use.glyphs[index].advanceX != 0 {
|
||||
line_text_width += cast(float) font_to_use.glyphs[index].advanceX;
|
||||
} else {
|
||||
line_text_width += (font_to_use.recs[index].width + cast(float) font_to_use.glyphs[index].offsetX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
max_text_width = c_max(max_text_width, line_text_width);
|
||||
text_size.width = max_text_width / 2;
|
||||
text_size.height = text_height;
|
||||
|
||||
return text_size;
|
||||
}
|
||||
|
||||
raylib_initialize :: (width: s32, height: s32, $$title: string, flags: Raylib.ConfigFlags) {
|
||||
c_string_title: *u8;
|
||||
#if is_constant(title) {
|
||||
// Constant strings in Jai are null-terminated
|
||||
c_string_title = title.data;
|
||||
} else {
|
||||
c_string_title = to_c_string(title);
|
||||
}
|
||||
|
||||
Raylib.SetConfigFlags(flags);
|
||||
Raylib.InitWindow(width, height, c_string_title);
|
||||
}
|
||||
|
||||
clay_raylib_render :: (render_commands: Clay.RenderCommandArray) {
|
||||
for 0..render_commands.length - 1 {
|
||||
render_command := Clay.RenderCommandArray_Get(*render_commands, cast(s32) it);
|
||||
bounding_box := render_command.boundingBox;
|
||||
|
||||
if #complete render_command.commandType == {
|
||||
case .NONE;
|
||||
case .TEXT;
|
||||
text := string.{
|
||||
cast(s64) render_command.text.length,
|
||||
render_command.text.chars,
|
||||
};
|
||||
c_string_text := temp_c_string(text);
|
||||
|
||||
font_to_use: Raylib.Font = g_raylib_fonts[render_command.config.textElementConfig.fontId].font;
|
||||
Raylib.DrawTextEx(
|
||||
font_to_use,
|
||||
c_string_text,
|
||||
.{bounding_box.x, bounding_box.y},
|
||||
cast(float) render_command.config.textElementConfig.fontSize,
|
||||
cast(float) render_command.config.textElementConfig.letterSpacing,
|
||||
to_raylib_color(render_command.config.textElementConfig.textColor),
|
||||
);
|
||||
case .IMAGE;
|
||||
// TODO image handling
|
||||
image_texture := cast(*Raylib.Texture2D, render_command.config.imageElementConfig.imageData).*;
|
||||
Raylib.DrawTextureEx(
|
||||
image_texture,
|
||||
.{bounding_box.x, bounding_box.y},
|
||||
0,
|
||||
bounding_box.width / cast(float) image_texture.width,
|
||||
Raylib.WHITE
|
||||
);
|
||||
case .SCISSOR_START;
|
||||
Raylib.BeginScissorMode(
|
||||
cast(s32, round(bounding_box.x)),
|
||||
cast(s32, round(bounding_box.y)),
|
||||
cast(s32, round(bounding_box.width)),
|
||||
cast(s32, round(bounding_box.height)),
|
||||
);
|
||||
case .SCISSOR_END;
|
||||
Raylib.EndScissorMode();
|
||||
case .RECTANGLE;
|
||||
config := render_command.config.rectangleElementConfig;
|
||||
if config.cornerRadius.topLeft > 0 {
|
||||
radius := (config.cornerRadius.topLeft * 2.0) / min(bounding_box.width, bounding_box.height);
|
||||
Raylib.DrawRectangleRounded(
|
||||
.{bounding_box.x, bounding_box.y, bounding_box.width, bounding_box.height},
|
||||
radius,
|
||||
8,
|
||||
to_raylib_color(config.color),
|
||||
);
|
||||
} else {
|
||||
Raylib.DrawRectangle(
|
||||
cast(s32, bounding_box.x),
|
||||
cast(s32, bounding_box.y),
|
||||
cast(s32, bounding_box.width),
|
||||
cast(s32, bounding_box.height),
|
||||
to_raylib_color(config.color),
|
||||
);
|
||||
}
|
||||
case .BORDER;
|
||||
config := render_command.config.borderElementConfig;
|
||||
|
||||
// Left border
|
||||
if config.left.width > 0 {
|
||||
Raylib.DrawRectangle(
|
||||
cast(s32, round(bounding_box.x)),
|
||||
cast(s32, round(bounding_box.y + config.cornerRadius.topLeft)),
|
||||
cast(s32, config.left.width),
|
||||
cast(s32, round(bounding_box.height - config.cornerRadius.topLeft - config.cornerRadius.bottomLeft)),
|
||||
to_raylib_color(config.right.color),
|
||||
);
|
||||
}
|
||||
|
||||
// Right border
|
||||
if config.right.width > 0 {
|
||||
Raylib.DrawRectangle(
|
||||
cast(s32, round(bounding_box.x + bounding_box.width - cast(float, config.right.width))),
|
||||
cast(s32, round(bounding_box.y + config.cornerRadius.topRight)),
|
||||
cast(s32, config.right.width),
|
||||
cast(s32, round(bounding_box.height - config.cornerRadius.topRight - config.cornerRadius.bottomRight)),
|
||||
to_raylib_color(config.right.color),
|
||||
);
|
||||
}
|
||||
|
||||
// Top border
|
||||
if config.top.width > 0 {
|
||||
Raylib.DrawRectangle(
|
||||
cast(s32, round(bounding_box.x + config.cornerRadius.topLeft)),
|
||||
cast(s32, round(bounding_box.y)),
|
||||
cast(s32, round(bounding_box.width - config.cornerRadius.topLeft - config.cornerRadius.topRight)),
|
||||
cast(s32, config.top.width),
|
||||
to_raylib_color(config.right.color),
|
||||
);
|
||||
}
|
||||
|
||||
// Bottom border
|
||||
if config.bottom.width > 0 {
|
||||
Raylib.DrawRectangle(
|
||||
cast(s32, round(bounding_box.x + config.cornerRadius.bottomLeft)),
|
||||
cast(s32, round(bounding_box.y + bounding_box.height - cast(float, config.bottom.width))),
|
||||
cast(s32, round(bounding_box.width - config.cornerRadius.bottomLeft - config.cornerRadius.bottomRight)),
|
||||
cast(s32, config.top.width),
|
||||
to_raylib_color(config.right.color),
|
||||
);
|
||||
}
|
||||
|
||||
if config.cornerRadius.topLeft > 0 {
|
||||
Raylib.DrawRing(
|
||||
.{
|
||||
round(bounding_box.x + config.cornerRadius.topLeft),
|
||||
round(bounding_box.y + config.cornerRadius.topLeft),
|
||||
},
|
||||
round(config.cornerRadius.topLeft - cast(float, config.top.width)),
|
||||
config.cornerRadius.topLeft,
|
||||
180,
|
||||
270,
|
||||
10,
|
||||
to_raylib_color(config.top.color),
|
||||
);
|
||||
}
|
||||
|
||||
if config.cornerRadius.topRight > 0 {
|
||||
Raylib.DrawRing(
|
||||
.{
|
||||
round(bounding_box.x + bounding_box.width - config.cornerRadius.topRight),
|
||||
round(bounding_box.y + config.cornerRadius.topRight),
|
||||
},
|
||||
round(config.cornerRadius.topRight - cast(float, config.top.width)),
|
||||
config.cornerRadius.topRight,
|
||||
270,
|
||||
360,
|
||||
10,
|
||||
to_raylib_color(config.top.color),
|
||||
);
|
||||
}
|
||||
|
||||
if config.cornerRadius.bottomLeft > 0 {
|
||||
Raylib.DrawRing(
|
||||
.{
|
||||
round(bounding_box.x + config.cornerRadius.bottomLeft),
|
||||
round(bounding_box.y + bounding_box.height - config.cornerRadius.bottomLeft),
|
||||
},
|
||||
round(config.cornerRadius.bottomLeft - cast(float, config.bottom.width)),
|
||||
config.cornerRadius.bottomLeft,
|
||||
90,
|
||||
180,
|
||||
10,
|
||||
to_raylib_color(config.bottom.color),
|
||||
);
|
||||
}
|
||||
|
||||
if config.cornerRadius.bottomRight > 0 {
|
||||
Raylib.DrawRing(
|
||||
.{
|
||||
round(bounding_box.x + bounding_box.width - config.cornerRadius.bottomRight),
|
||||
round(bounding_box.y + bounding_box.height - config.cornerRadius.bottomRight),
|
||||
},
|
||||
round(config.cornerRadius.bottomRight - cast(float, config.bottom.width)),
|
||||
config.cornerRadius.bottomRight,
|
||||
0.1,
|
||||
90,
|
||||
10,
|
||||
to_raylib_color(config.bottom.color),
|
||||
);
|
||||
}
|
||||
case .CUSTOM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#scope_file
|
||||
|
||||
round :: (x: float) -> float {
|
||||
rounded_int := cast(int, x + 0.5 * ifx x < 0 then -1 else 1);
|
||||
return cast(float, rounded_int);
|
||||
}
|
||||
|
||||
c_max :: (a: $T, b: T) -> T #c_call {
|
||||
if b < a return a;
|
||||
return b;
|
||||
}
|
293
bindings/jai/examples/introducing_clay_video_demo/main.jai
Normal file
293
bindings/jai/examples/introducing_clay_video_demo/main.jai
Normal file
@ -0,0 +1,293 @@
|
||||
using Basic :: #import "Basic";
|
||||
|
||||
Clay :: #import,file "../../clay-jai/module.jai";
|
||||
Raylib :: #import "raylib-jai";
|
||||
|
||||
for_expansion :: Clay.for_expansion;;
|
||||
|
||||
#load "clay_renderer_raylib.jai";
|
||||
|
||||
FONT_ID_BODY_16 :: 0;
|
||||
COLOR_WHITE :: Clay.Color.{255, 255, 255, 255};
|
||||
|
||||
window_width: s32 = 1024;
|
||||
window_height: s32 = 768;
|
||||
|
||||
Document :: struct {
|
||||
title: string;
|
||||
contents: string;
|
||||
}
|
||||
|
||||
documents :: Document.[
|
||||
.{"Squirrels", "The Secret Life of Squirrels: Nature's Clever Acrobats\nSquirrels are often overlooked creatures, dismissed as mere park inhabitants or backyard nuisances. Yet, beneath their fluffy tails and twitching noses lies an intricate world of cunning, agility, and survival tactics that are nothing short of fascinating. As one of the most common mammals in North America, squirrels have adapted to a wide range of environments from bustling urban centers to tranquil forests and have developed a variety of unique behaviors that continue to intrigue scientists and nature enthusiasts alike.\n\nMaster Tree Climbers\nAt the heart of a squirrel's skill set is its impressive ability to navigate trees with ease. Whether they're darting from branch to branch or leaping across wide gaps, squirrels possess an innate talent for acrobatics. Their powerful hind legs, which are longer than their front legs, give them remarkable jumping power. With a tail that acts as a counterbalance, squirrels can leap distances of up to ten times the length of their body, making them some of the best aerial acrobats in the animal kingdom.\nBut it's not just their agility that makes them exceptional climbers. Squirrels' sharp, curved claws allow them to grip tree bark with precision, while the soft pads on their feet provide traction on slippery surfaces. Their ability to run at high speeds and scale vertical trunks with ease is a testament to the evolutionary adaptations that have made them so successful in their arboreal habitats.\n\nFood Hoarders Extraordinaire\nSquirrels are often seen frantically gathering nuts, seeds, and even fungi in preparation for winter. While this behavior may seem like instinctual hoarding, it is actually a survival strategy that has been honed over millions of years. Known as \"scatter hoarding,\" squirrels store their food in a variety of hidden locations, often burying it deep in the soil or stashing it in hollowed-out tree trunks.\nInterestingly, squirrels have an incredible memory for the locations of their caches. Research has shown that they can remember thousands of hiding spots, often returning to them months later when food is scarce. However, they don't always recover every stash some forgotten caches eventually sprout into new trees, contributing to forest regeneration. This unintentional role as forest gardeners highlights the ecological importance of squirrels in their ecosystems.\n\nThe Great Squirrel Debate: Urban vs. Wild\nWhile squirrels are most commonly associated with rural or wooded areas, their adaptability has allowed them to thrive in urban environments as well. In cities, squirrels have become adept at finding food sources in places like parks, streets, and even garbage cans. However, their urban counterparts face unique challenges, including traffic, predators, and the lack of natural shelters. Despite these obstacles, squirrels in urban areas are often observed using human infrastructure such as buildings, bridges, and power lines as highways for their acrobatic escapades.\nThere is, however, a growing concern regarding the impact of urban life on squirrel populations. Pollution, deforestation, and the loss of natural habitats are making it more difficult for squirrels to find adequate food and shelter. As a result, conservationists are focusing on creating squirrel-friendly spaces within cities, with the goal of ensuring these resourceful creatures continue to thrive in both rural and urban landscapes.\n\nA Symbol of Resilience\nIn many cultures, squirrels are symbols of resourcefulness, adaptability, and preparation. Their ability to thrive in a variety of environments while navigating challenges with agility and grace serves as a reminder of the resilience inherent in nature. Whether you encounter them in a quiet forest, a city park, or your own backyard, squirrels are creatures that never fail to amaze with their endless energy and ingenuity.\nIn the end, squirrels may be small, but they are mighty in their ability to survive and thrive in a world that is constantly changing. So next time you spot one hopping across a branch or darting across your lawn, take a moment to appreciate the remarkable acrobat at work a true marvel of the natural world."},
|
||||
.{"Lorem Ipsum", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."},
|
||||
.{"Vacuum Instructions", "Chapter 3: Getting Started - Unpacking and Setup\n\nCongratulations on your new SuperClean Pro 5000 vacuum cleaner! In this section, we will guide you through the simple steps to get your vacuum up and running. Before you begin, please ensure that you have all the components listed in the \"Package Contents\" section on page 2.\n\n1. Unboxing Your Vacuum\nCarefully remove the vacuum cleaner from the box. Avoid using sharp objects that could damage the product. Once removed, place the unit on a flat, stable surface to proceed with the setup. Inside the box, you should find:\n\n The main vacuum unit\n A telescoping extension wand\n A set of specialized cleaning tools (crevice tool, upholstery brush, etc.)\n A reusable dust bag (if applicable)\n A power cord with a 3-prong plug\n A set of quick-start instructions\n\n2. Assembling Your Vacuum\nBegin by attaching the extension wand to the main body of the vacuum cleaner. Line up the connectors and twist the wand into place until you hear a click. Next, select the desired cleaning tool and firmly attach it to the wand's end, ensuring it is securely locked in.\n\nFor models that require a dust bag, slide the bag into the compartment at the back of the vacuum, making sure it is properly aligned with the internal mechanism. If your vacuum uses a bagless system, ensure the dust container is correctly seated and locked in place before use.\n\n3. Powering On\nTo start the vacuum, plug the power cord into a grounded electrical outlet. Once plugged in, locate the power switch, usually positioned on the side of the handle or body of the unit, depending on your model. Press the switch to the \"On\" position, and you should hear the motor begin to hum. If the vacuum does not power on, check that the power cord is securely plugged in, and ensure there are no blockages in the power switch.\n\nNote: Before first use, ensure that the vacuum filter (if your model has one) is properly installed. If unsure, refer to \"Section 5: Maintenance\" for filter installation instructions."},
|
||||
.{"Article 4", "Article 4"},
|
||||
.{"Article 5", "Article 5"},
|
||||
];
|
||||
|
||||
to_jai_string :: (str: Clay.String) -> string {
|
||||
return .{data = str.chars, count = cast(s64, str.length)};
|
||||
}
|
||||
|
||||
handle_clay_errors :: (error_data: Clay.ErrorData) #c_call {
|
||||
push_context {
|
||||
log_error(
|
||||
"Clay Error [%]: % | %",
|
||||
error_data.errorType,
|
||||
to_jai_string(error_data.errorText),
|
||||
error_data.userData
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render_header_button :: (text: string) {
|
||||
for Clay.Element(
|
||||
Clay.Layout(.{padding = .{16, 8}}),
|
||||
Clay.Rectangle(.{
|
||||
color = .{140, 140, 140, 255},
|
||||
cornerRadius = .{5, 5, 5, 5},
|
||||
})
|
||||
) {
|
||||
Clay.Text(text, Clay.TextConfig(.{
|
||||
fontId = FONT_ID_BODY_16,
|
||||
fontSize = 16,
|
||||
textColor = COLOR_WHITE,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
render_dropdown_menu_item :: (text: string) {
|
||||
for Clay.Element(
|
||||
Clay.Layout(.{padding = .{16, 16}})
|
||||
) {
|
||||
Clay.Text(text, Clay.TextConfig(.{
|
||||
fontId = FONT_ID_BODY_16,
|
||||
fontSize = 16,
|
||||
textColor = COLOR_WHITE,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
selected_document_index : int = 0;
|
||||
|
||||
main :: () {
|
||||
flags := Raylib.ConfigFlags.WINDOW_RESIZABLE | .MSAA_4X_HINT | .VSYNC_HINT;
|
||||
raylib_initialize(1024, 768, "Introducing Clay Demo", flags);
|
||||
|
||||
// For some reason, on linux, this is 8 bytes off ???
|
||||
clay_required_memory := Clay.MinMemorySize() + 8;
|
||||
memory := alloc(clay_required_memory);
|
||||
clay_memory := Clay.CreateArenaWithCapacityAndMemory(clay_required_memory, memory);
|
||||
Clay.Initialize(
|
||||
clay_memory,
|
||||
Clay.Dimensions.{cast(float, Raylib.GetScreenWidth()), cast(float, Raylib.GetScreenHeight())},
|
||||
.{handle_clay_errors, 0}
|
||||
);
|
||||
|
||||
Clay.SetMeasureTextFunction(raylib_measure_text);
|
||||
g_raylib_fonts[FONT_ID_BODY_16] = .{
|
||||
FONT_ID_BODY_16,
|
||||
Raylib.LoadFontEx("resources/Roboto-Regular.ttf", 48, null, 400),
|
||||
};
|
||||
Raylib.SetTextureFilter(g_raylib_fonts[FONT_ID_BODY_16].font.texture, .BILINEAR);
|
||||
|
||||
while !Raylib.WindowShouldClose() {
|
||||
Clay.SetLayoutDimensions(.{
|
||||
cast(float, Raylib.GetScreenWidth()),
|
||||
cast(float, Raylib.GetScreenHeight()),
|
||||
});
|
||||
|
||||
mouse_position := Raylib.GetMousePosition();
|
||||
scroll_delta := Raylib.GetMouseWheelMoveV();
|
||||
Clay.SetPointerState(mouse_position, Raylib.IsMouseButtonDown(0));
|
||||
Clay.UpdateScrollContainers(true, scroll_delta, Raylib.GetFrameTime());
|
||||
|
||||
layout_expand := Clay.Sizing.{
|
||||
Clay.SizingGrow(),
|
||||
Clay.SizingGrow(),
|
||||
};
|
||||
|
||||
content_background_config := Clay.RectangleElementConfig.{
|
||||
color = .{90, 90, 90, 255},
|
||||
cornerRadius = .{8, 8, 8, 8},
|
||||
};
|
||||
|
||||
Clay.BeginLayout();
|
||||
for Clay.Element(
|
||||
Clay.ID("OuterContainer"),
|
||||
Clay.Rectangle(.{color = .{43, 41, 51, 255}}),
|
||||
Clay.Layout(.{
|
||||
layoutDirection = .TOP_TO_BOTTOM,
|
||||
sizing = layout_expand,
|
||||
padding = .{16, 16},
|
||||
childGap = 16,
|
||||
}),
|
||||
) {
|
||||
for Clay.Element(
|
||||
Clay.ID("HeaderBar"),
|
||||
Clay.Rectangle(content_background_config),
|
||||
Clay.Layout(.{
|
||||
sizing = .{
|
||||
height = Clay.SizingFixed(60),
|
||||
width = Clay.SizingGrow(),
|
||||
},
|
||||
padding = .{16, 16},
|
||||
childGap = 16,
|
||||
childAlignment = .{
|
||||
y = .CENTER,
|
||||
}
|
||||
}),
|
||||
) {
|
||||
for Clay.Element(
|
||||
Clay.ID("FileButton"),
|
||||
Clay.Layout(.{padding = .{16, 8}}),
|
||||
Clay.Rectangle(.{
|
||||
color = .{140, 140, 140, 255},
|
||||
cornerRadius = .{5, 5, 5, 5},
|
||||
}),
|
||||
) {
|
||||
Clay.Text("File", Clay.TextConfig(.{
|
||||
fontId = FONT_ID_BODY_16,
|
||||
fontSize = 16,
|
||||
textColor = COLOR_WHITE,
|
||||
}));
|
||||
|
||||
file_menu_visible := Clay.PointerOver(Clay.GetElementId("FileButton")) ||
|
||||
Clay.PointerOver(Clay.GetElementId("FileMenu"));
|
||||
|
||||
if file_menu_visible {
|
||||
for Clay.Element(
|
||||
Clay.ID("FileMenu"),
|
||||
Clay.Floating(.{attachment = .{parent = .LEFT_BOTTOM}}),
|
||||
Clay.Layout(.{padding = .{0, 8}})
|
||||
) {
|
||||
for Clay.Element(
|
||||
Clay.Layout(.{
|
||||
layoutDirection=.TOP_TO_BOTTOM,
|
||||
sizing = .{width = Clay.SizingFixed(200)}
|
||||
}),
|
||||
Clay.Rectangle(.{
|
||||
color = .{40, 40, 40, 255},
|
||||
cornerRadius = .{8, 8, 8, 8}
|
||||
})
|
||||
) {
|
||||
// Render dropdown items here
|
||||
render_dropdown_menu_item("New");
|
||||
render_dropdown_menu_item("Open");
|
||||
render_dropdown_menu_item("Close");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render header buttons
|
||||
render_header_button("Edit");
|
||||
for Clay.Element(Clay.Layout(.{
|
||||
sizing = .{Clay.SizingGrow(), Clay.SizingGrow()}})) {}
|
||||
render_header_button("Upload");
|
||||
render_header_button("Media");
|
||||
render_header_button("Support");
|
||||
}
|
||||
|
||||
for Clay.Element(
|
||||
Clay.ID("LowerContent"),
|
||||
Clay.Layout(.{sizing = layout_expand, childGap = 16}),
|
||||
) {
|
||||
for Clay.Element(
|
||||
Clay.ID("Sidebar"),
|
||||
Clay.Rectangle(content_background_config),
|
||||
Clay.Layout(.{
|
||||
layoutDirection = .TOP_TO_BOTTOM,
|
||||
padding = .{16, 16},
|
||||
childGap = 8,
|
||||
sizing = .{
|
||||
width = Clay.SizingFixed(250),
|
||||
height = Clay.SizingGrow(),
|
||||
}
|
||||
})
|
||||
) {
|
||||
for document : documents {
|
||||
sidebar_button_layout := Clay.LayoutConfig.{
|
||||
sizing = .{width = Clay.SizingGrow()},
|
||||
padding = .{16, 16},
|
||||
};
|
||||
|
||||
if it_index == selected_document_index {
|
||||
for Clay.Element(
|
||||
Clay.Layout(sidebar_button_layout),
|
||||
Clay.Rectangle(.{
|
||||
color = .{120, 120, 120, 255},
|
||||
cornerRadius = .{8, 8, 8, 8},
|
||||
})
|
||||
) {
|
||||
Clay.Text(document.title, Clay.TextConfig(.{
|
||||
fontId = FONT_ID_BODY_16,
|
||||
fontSize = 20,
|
||||
textColor = COLOR_WHITE,
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
id := tprint("Parnets %", it_index);
|
||||
is_hovered := Clay.PointerOver(Clay.GetElementId(id));
|
||||
if is_hovered && Raylib.IsMouseButtonPressed(0) {
|
||||
selected_document_index = it_index;
|
||||
}
|
||||
|
||||
for Clay.Element(
|
||||
Clay.ID(id)
|
||||
) {
|
||||
for Clay.Element(
|
||||
Clay.Layout(sidebar_button_layout),
|
||||
ifx is_hovered then Clay.Rectangle(.{
|
||||
color = .{120, 120, 120, 120},
|
||||
cornerRadius = .{8, 8, 8, 8},
|
||||
}) else .{}
|
||||
) {
|
||||
Clay.Text(document.title, Clay.TextConfig(.{
|
||||
fontId = FONT_ID_BODY_16,
|
||||
fontSize = 20,
|
||||
textColor = COLOR_WHITE
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for Clay.Element(
|
||||
Clay.ID("MainContent"),
|
||||
Clay.Rectangle(content_background_config),
|
||||
Clay.Scroll(.{vertical = true}),
|
||||
Clay.Layout(.{
|
||||
layoutDirection = .TOP_TO_BOTTOM,
|
||||
childGap = 16,
|
||||
padding = .{16, 16},
|
||||
sizing = layout_expand,
|
||||
}),
|
||||
) {
|
||||
selected_document := documents[selected_document_index];
|
||||
Clay.Text(selected_document.title, Clay.TextConfig(.{
|
||||
fontId = FONT_ID_BODY_16,
|
||||
fontSize = 24,
|
||||
textColor = COLOR_WHITE,
|
||||
}));
|
||||
Clay.Text(selected_document.contents, Clay.TextConfig(.{
|
||||
fontId = FONT_ID_BODY_16,
|
||||
fontSize = 24,
|
||||
textColor = COLOR_WHITE
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render_commands := Clay.EndLayout();
|
||||
|
||||
Raylib.BeginDrawing();
|
||||
Raylib.ClearBackground(Raylib.BLACK);
|
||||
clay_raylib_render(render_commands);
|
||||
Raylib.EndDrawing();
|
||||
|
||||
reset_temporary_storage();
|
||||
}
|
||||
}
|
4
bindings/jai/examples/introducing_clay_video_demo/modules/raylib-jai/.gitignore
vendored
Normal file
4
bindings/jai/examples/introducing_clay_video_demo/modules/raylib-jai/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.build
|
||||
.vscode
|
||||
raylib/
|
||||
.DS_Store
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,148 @@
|
||||
|
||||
Vector2 :: Math.Vector2;
|
||||
Vector3 :: Math.Vector3;
|
||||
Vector4 :: Math.Vector4;
|
||||
Quaternion :: Math.Quaternion;
|
||||
Matrix :: Math.Matrix4;
|
||||
PI :: Math.PI;
|
||||
|
||||
LIGHTGRAY :: Color.{ 200, 200, 200, 255 };
|
||||
GRAY :: Color.{ 130, 130, 130, 255 };
|
||||
DARKGRAY :: Color.{ 80, 80, 80, 255 };
|
||||
YELLOW :: Color.{ 253, 249, 0, 255 };
|
||||
GOLD :: Color.{ 255, 203, 0, 255 };
|
||||
ORANGE :: Color.{ 255, 161, 0, 255 };
|
||||
PINK :: Color.{ 255, 109, 194, 255 };
|
||||
RED :: Color.{ 230, 41, 55, 255 };
|
||||
MAROON :: Color.{ 190, 33, 55, 255 };
|
||||
GREEN :: Color.{ 0, 228, 48, 255 };
|
||||
LIME :: Color.{ 0, 158, 47, 255 };
|
||||
DARKGREEN :: Color.{ 0, 117, 44, 255 };
|
||||
SKYBLUE :: Color.{ 102, 191, 255, 255 };
|
||||
BLUE :: Color.{ 0, 121, 241, 255 };
|
||||
DARKBLUE :: Color.{ 0, 82, 172, 255 };
|
||||
PURPLE :: Color.{ 200, 122, 255, 255 };
|
||||
VIOLET :: Color.{ 135, 60, 190, 255 };
|
||||
DARKPURPLE :: Color.{ 112, 31, 126, 255 };
|
||||
BEIGE :: Color.{ 211, 176, 131, 255 };
|
||||
BROWN :: Color.{ 127, 106, 79, 255 };
|
||||
DARKBROWN :: Color.{ 76, 63, 47, 255 };
|
||||
WHITE :: Color.{ 255, 255, 255, 255 };
|
||||
BLACK :: Color.{ 0, 0, 0, 255 };
|
||||
BLANK :: Color.{ 0, 0, 0, 0 };
|
||||
MAGENTA :: Color.{ 255, 0, 255, 255 };
|
||||
RAYWHITE :: Color.{ 245, 245, 245, 255 };
|
||||
|
||||
GetGamepadButtonPressed :: () -> GamepadButton #foreign raylib;
|
||||
|
||||
IsMouseButtonPressed :: (button: MouseButton) -> bool { return IsMouseButtonPressed(cast(s32) button); }
|
||||
IsMouseButtonDown :: (button: MouseButton) -> bool { return IsMouseButtonDown(cast(s32) button); }
|
||||
IsMouseButtonReleased :: (button: MouseButton) -> bool { return IsMouseButtonReleased(cast(s32) button); }
|
||||
IsMouseButtonUp :: (button: MouseButton) -> bool { return IsMouseButtonUp(cast(s32) button); }
|
||||
|
||||
IsKeyPressed :: (key: KeyboardKey) -> bool { return IsKeyPressed(cast(s32) key); }
|
||||
IsKeyPressedRepeat :: (key: KeyboardKey) -> bool { return IsKeyPressedRepeat(cast(s32) key); }
|
||||
IsKeyDown :: (key: KeyboardKey) -> bool { return IsKeyDown(cast(s32) key); }
|
||||
IsKeyReleased :: (key: KeyboardKey) -> bool { return IsKeyReleased(cast(s32) key); }
|
||||
IsKeyUp :: (key: KeyboardKey) -> bool { return IsKeyUp(cast(s32) key); }
|
||||
SetExitKey :: (key: KeyboardKey) -> void { return SetExitKey(cast(s32) key); }
|
||||
|
||||
SetConfigFlags :: (flags: ConfigFlags) -> void { return SetConfigFlags(cast(u32) flags); }
|
||||
|
||||
SetGesturesEnabled :: (flags: Gesture) -> void { return SetGesturesEnabled(cast(u32) flags); }
|
||||
IsGestureDetected :: (gesture: Gesture) -> bool { return IsGestureDetected(cast(u32) gesture); }
|
||||
|
||||
IsWindowState :: (flag: ConfigFlags) -> bool { return IsWindowState(cast(u32) flag); }
|
||||
SetWindowState :: (flags: ConfigFlags) -> void { return SetWindowState(cast(u32) flags); }
|
||||
ClearWindowState :: (flags: ConfigFlags) -> void { return ClearWindowState(cast(u32) flags); }
|
||||
|
||||
UpdateCamera :: (camera: *Camera, mode: CameraMode) -> void { return UpdateCamera(camera, cast(s32) mode); }
|
||||
|
||||
SetTraceLogLevel :: (logLevel: TraceLogLevel) -> void { return SetTraceLogLevel(cast(s32) logLevel); }
|
||||
TraceLog :: (logLevel: TraceLogLevel, text: string, __args: ..Any) { TraceLog(cast(s32) logLevel, text, __args); }
|
||||
|
||||
SetShaderValue :: (shader: Shader, locIndex: s32, value: *void, uniformType: ShaderUniformDataType) -> void {
|
||||
return SetShaderValue(shader, locIndex, value, cast(s32) uniformType);
|
||||
}
|
||||
SetShaderValueV :: (shader: Shader, locIndex: s32, value: *void, uniformType: ShaderUniformDataType, count: s32) -> void {
|
||||
return SetShaderValue(shader, locIndex, value, cast(s32) uniformType, count);
|
||||
}
|
||||
|
||||
IsGamepadButtonPressed :: (gamepad: s32, button: GamepadButton) -> bool { return IsGamepadButtonPressed(gamepad, cast(s32) button); }
|
||||
IsGamepadButtonDown :: (gamepad: s32, button: GamepadButton) -> bool { return IsGamepadButtonDown(gamepad, cast(s32) button); }
|
||||
IsGamepadButtonReleased :: (gamepad: s32, button: GamepadButton) -> bool { return IsGamepadButtonReleased(gamepad, cast(s32) button); }
|
||||
IsGamepadButtonUp :: (gamepad: s32, button: GamepadButton) -> bool { return IsGamepadButtonUp(gamepad, cast(s32) button); }
|
||||
|
||||
GetGamepadAxisMovement :: (gamepad: s32, axis: GamepadAxis) -> float { return GetGamepadAxisMovement(gamepad, cast(s32) axis); }
|
||||
|
||||
SetTextureFilter :: (texture: Texture2D, filter: TextureFilter) -> void { return SetTextureFilter(texture, cast(s32) filter); }
|
||||
SetTextureWrap :: (texture: Texture2D, wrap: TextureWrap) -> void { return SetTextureWrap(textuer, cast(s32) wrap); }
|
||||
|
||||
BeginBlendMode :: (mode: BlendMode) -> void { return BeginBlendMode(cast(s32) mode); }
|
||||
|
||||
ImageFormat :: (image: *Image, newFormat: PixelFormat) -> void { return ImageFormat(image, cast(s32) newFormat); }
|
||||
|
||||
LoadImageRaw :: (fileName: *u8, width: s32, height: s32, format: PixelFormat, headerSize: s32) -> Image {
|
||||
return LoadImageRaw(fileName, width, height, cast(s32) format, headerSize);
|
||||
}
|
||||
|
||||
LoadFontData :: (fileData: *u8, dataSize: s32, fontSize: s32, codepoints: *s32, codepointCount: s32, type: FontType) -> *GlyphInfo {
|
||||
return LoadFontData(fileData, dataSize, fontSize, codepoints, codepointCount, cast(s32) type);
|
||||
}
|
||||
|
||||
SetMouseCursor :: (cursor: MouseCursor) -> void { return SetMouseCursor(cast(s32) cursor); }
|
||||
|
||||
LoadTexture :: (data: *void, width: s32, height: s32, format: PixelFormat, mipmapCount: s32) -> u32 {
|
||||
return LoadTexture(data, width, height, cast(s32) format, mipmapCount);
|
||||
}
|
||||
|
||||
FramebufferAttach :: (fboId: u32, texId: u32, attachType: FramebufferAttachType, texType: FramebufferAttachTextureType, mipLevel: s32) -> void {
|
||||
return FramebufferAttach(fbiId, texId, cast(s32) attachType, cast(s32) texType, mipLevel);
|
||||
}
|
||||
|
||||
SetUniform :: (locIndex: s32, value: *void, uniformType: ShaderUniformDataType, count: s32) -> void { return SetUniform(locIndex, value, cast(s32) uniformType, count); }
|
||||
|
||||
SetMaterialTexture :: (material: *Material, mapType: MaterialMapIndex, texture: Texture2D) -> void { return SetMaterialTexture(material, mapType, texture); }
|
||||
|
||||
Camera3D :: struct {
|
||||
position: Vector3; // Camera position
|
||||
target: Vector3; // Camera target it looks-at
|
||||
up: Vector3; // Camera up vector (rotation over its axis)
|
||||
fovy: float; // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic
|
||||
projection: CameraProjection; // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
|
||||
}
|
||||
|
||||
TraceLogCallback :: #type (logLevel: TraceLogLevel, text: *u8, args: .. Any) #c_call;
|
||||
|
||||
#scope_module
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
user32 :: #system_library,link_always "user32";
|
||||
gdi32 :: #system_library,link_always "gdi32";
|
||||
shell32 :: #system_library,link_always "shell32";
|
||||
winmm :: #system_library,link_always "winmm";
|
||||
|
||||
raylib :: #library,no_dll "windows/raylib";
|
||||
|
||||
#load "windows.jai";
|
||||
} else #if OS == .LINUX {
|
||||
math :: #system_library,link_always "m";
|
||||
raylib :: #library,no_dll "linux/raylib";
|
||||
|
||||
#load "linux.jai";
|
||||
} else #if OS == .MACOS {
|
||||
#system_library,link_always "Cocoa";
|
||||
#system_library,link_always "OpenGL";
|
||||
#system_library,link_always "CoreGraphics";
|
||||
#system_library,link_always "AppKit";
|
||||
#system_library,link_always "IOKit";
|
||||
|
||||
raylib :: #library,no_dll "macos/raylib";
|
||||
|
||||
#load "macos.jai";
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
#import "Basic";
|
||||
Math :: #import "Math";
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
64
clay.h
64
clay.h
@ -70,15 +70,9 @@
|
||||
|
||||
#define CLAY_CORNER_RADIUS(radius) (CLAY__INIT(Clay_CornerRadius) { radius, radius, radius, radius })
|
||||
|
||||
#define CLAY__STRUCT_1_ARGS(a) a
|
||||
#define CLAY__STRUCT_0_ARGS() CLAY__DEFAULT_STRUCT
|
||||
#define CLAY__STRUCT_OVERRIDE(_0, _1, NAME, ...) NAME
|
||||
#define CLAY_SIZING_FIT(...) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = { __VA_ARGS__ } }, .type = CLAY__SIZING_TYPE_FIT })
|
||||
|
||||
#define CLAY__SIZING_FIT_INTERNAL(...) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = __VA_ARGS__ }, .type = CLAY__SIZING_TYPE_FIT })
|
||||
#define CLAY_SIZING_FIT(...) CLAY__SIZING_FIT_INTERNAL(CLAY__STRUCT_OVERRIDE("empty", ##__VA_ARGS__, CLAY__STRUCT_1_ARGS, CLAY__STRUCT_0_ARGS)(__VA_ARGS__))
|
||||
|
||||
#define CLAY__SIZING_GROW_INTERNAL(...) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = __VA_ARGS__ }, .type = CLAY__SIZING_TYPE_GROW })
|
||||
#define CLAY_SIZING_GROW(...) CLAY__SIZING_GROW_INTERNAL(CLAY__STRUCT_OVERRIDE("empty", ##__VA_ARGS__, CLAY__STRUCT_1_ARGS, CLAY__STRUCT_0_ARGS)(__VA_ARGS__))
|
||||
#define CLAY_SIZING_GROW(...) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = { __VA_ARGS__ } }, .type = CLAY__SIZING_TYPE_GROW })
|
||||
|
||||
#define CLAY_SIZING_FIXED(fixedSize) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = { fixedSize, fixedSize } }, .type = CLAY__SIZING_TYPE_FIXED })
|
||||
|
||||
@ -99,6 +93,8 @@
|
||||
// Note: If an error led you here, it's because CLAY_STRING can only be used with string literals, i.e. CLAY_STRING("SomeString") and not CLAY_STRING(yourString)
|
||||
#define CLAY_STRING(string) (CLAY__INIT(Clay_String) { .length = CLAY__STRING_LENGTH(CLAY__ENSURE_STRING_LITERAL(string)), .chars = (string) })
|
||||
|
||||
#define CLAY_STRING_CONST(string) { .length = CLAY__STRING_LENGTH(CLAY__ENSURE_STRING_LITERAL(string)), .chars = (string) }
|
||||
|
||||
static uint8_t CLAY__ELEMENT_DEFINITION_LATCH;
|
||||
|
||||
// Publicly visible layout element macros -----------------------------------------------------
|
||||
@ -128,7 +124,7 @@ static uint8_t CLAY__ELEMENT_DEFINITION_LATCH;
|
||||
*/
|
||||
#define CLAY(...) \
|
||||
for (\
|
||||
CLAY__ELEMENT_DEFINITION_LATCH = (Clay__OpenElement(), ##__VA_ARGS__, Clay__ElementPostConfiguration(), 0); \
|
||||
CLAY__ELEMENT_DEFINITION_LATCH = (Clay__OpenElement(), __VA_ARGS__, Clay__ElementPostConfiguration(), 0); \
|
||||
CLAY__ELEMENT_DEFINITION_LATCH < 1; \
|
||||
++CLAY__ELEMENT_DEFINITION_LATCH, Clay__CloseElement() \
|
||||
)
|
||||
@ -2092,13 +2088,13 @@ void Clay__CompressChildrenAlongAxis(bool xAxis, float totalSizeToDistribute, Cl
|
||||
Clay__int32_tArray largestContainers = context->openClipElementStack;
|
||||
largestContainers.length = 0;
|
||||
|
||||
while (totalSizeToDistribute > 0) {
|
||||
while (totalSizeToDistribute > 0.1) {
|
||||
float largestSize = 0;
|
||||
float targetSize = 0;
|
||||
for (int32_t i = 0; i < resizableContainerBuffer.length; ++i) {
|
||||
Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
|
||||
float childSize = xAxis ? childElement->dimensions.width : childElement->dimensions.height;
|
||||
if (childSize == largestSize) {
|
||||
if ((childSize - largestSize) < 0.1 && (childSize - largestSize) > -0.1) {
|
||||
Clay__int32_tArray_Add(&largestContainers, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
|
||||
} else if (childSize > largestSize) {
|
||||
targetSize = largestSize;
|
||||
@ -2965,8 +2961,8 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||
Clay__int32_tArray_Add(&dfsBuffer, (int32_t)root->layoutElementIndex);
|
||||
context->treeNodeVisited.internalArray[0] = false;
|
||||
if (rootIndex > 0) {
|
||||
CLAY(CLAY_IDI("Clay__DebugView_EmptyRowOuter", rootIndex), CLAY_LAYOUT({ .sizing = {.width = CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT)}, .padding = {CLAY__DEBUGVIEW_INDENT_WIDTH / 2, 0} })) {
|
||||
CLAY(CLAY_IDI("Clay__DebugView_EmptyRow", rootIndex), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), .height = CLAY_SIZING_FIXED((float)CLAY__DEBUGVIEW_ROW_HEIGHT) }}), CLAY_BORDER({ .top = { .width = 1, .color = CLAY__DEBUGVIEW_COLOR_3 } })) {}
|
||||
CLAY(CLAY_IDI("Clay__DebugView_EmptyRowOuter", rootIndex), CLAY_LAYOUT({ .sizing = {.width = CLAY_SIZING_GROW(0)}, .padding = {CLAY__DEBUGVIEW_INDENT_WIDTH / 2, 0} })) {
|
||||
CLAY(CLAY_IDI("Clay__DebugView_EmptyRow", rootIndex), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED((float)CLAY__DEBUGVIEW_ROW_HEIGHT) }}), CLAY_BORDER({ .top = { .width = 1, .color = CLAY__DEBUGVIEW_COLOR_3 } })) {}
|
||||
}
|
||||
layoutData.rowCount++;
|
||||
}
|
||||
@ -3088,8 +3084,8 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||
}
|
||||
|
||||
if (highlightedElementId) {
|
||||
CLAY(CLAY_ID("Clay__DebugView_ElementHighlight"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT)} }), CLAY_FLOATING({ .zIndex = 65535, .parentId = highlightedElementId })) {
|
||||
CLAY(CLAY_ID("Clay__DebugView_ElementHighlightRectangle"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT)} }), CLAY_RECTANGLE({.color = Clay__debugViewHighlightColor })) {}
|
||||
CLAY(CLAY_ID("Clay__DebugView_ElementHighlight"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }), CLAY_FLOATING({ .zIndex = 65535, .parentId = highlightedElementId })) {
|
||||
CLAY(CLAY_ID("Clay__DebugView_ElementHighlightRectangle"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }), CLAY_RECTANGLE({.color = Clay__debugViewHighlightColor })) {}
|
||||
}
|
||||
}
|
||||
return layoutData;
|
||||
@ -3124,11 +3120,11 @@ void Clay__RenderDebugViewElementConfigHeader(Clay_String elementId, Clay__Eleme
|
||||
Clay__DebugElementConfigTypeLabelConfig config = Clay__DebugGetElementConfigTypeLabel(type);
|
||||
Clay_Color backgroundColor = config.color;
|
||||
backgroundColor.a = 90;
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = { .x = CLAY__DEBUGVIEW_OUTER_PADDING }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = { .x = CLAY__DEBUGVIEW_OUTER_PADDING }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } })) {
|
||||
CLAY(CLAY_LAYOUT({ .padding = { 8, 2 } }), CLAY_RECTANGLE({ .color = backgroundColor, .cornerRadius = CLAY_CORNER_RADIUS(4) }), CLAY_BORDER_OUTSIDE_RADIUS(1, config.color, 4)) {
|
||||
CLAY_TEXT(config.label, CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||
}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT) } })) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0) } })) {}
|
||||
CLAY_TEXT(elementId, CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE }));
|
||||
}
|
||||
}
|
||||
@ -3224,9 +3220,9 @@ void Clay__RenderDebugView() {
|
||||
CLAY_LAYOUT({ .sizing = { CLAY_SIZING_FIXED((float)Clay__debugViewWidth) , CLAY_SIZING_FIXED(context->layoutDimensions.height) }, .layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
||||
CLAY_BORDER({ .bottom = { .width = 1, .color = CLAY__DEBUGVIEW_COLOR_3 }})
|
||||
) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_2 })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_2 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Clay Debug Tools"), infoTextConfig);
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY__DEFAULT_STRUCT } })) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), {0} } })) {}
|
||||
// Close button
|
||||
CLAY(CLAY_BORDER_OUTSIDE_RADIUS(1, (CLAY__INIT(Clay_Color){217,91,67,255}), 4),
|
||||
CLAY_LAYOUT({ .sizing = {CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10)}, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER} }),
|
||||
@ -3236,13 +3232,13 @@ void Clay__RenderDebugView() {
|
||||
CLAY_TEXT(CLAY_STRING("x"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||
}
|
||||
}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_FIXED(1)} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_3 })) {}
|
||||
CLAY(Clay__AttachId(scrollId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT)} }), CLAY_SCROLL({ .horizontal = true, .vertical = true })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(1)} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_3 })) {}
|
||||
CLAY(Clay__AttachId(scrollId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }), CLAY_SCROLL({ .horizontal = true, .vertical = true })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 })) {
|
||||
Clay_ElementId panelContentsId = Clay__HashString(CLAY_STRING("Clay__DebugViewPaneOuter"), 0, 0);
|
||||
// Element list
|
||||
CLAY(Clay__AttachId(panelContentsId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT)} }), CLAY_FLOATING({ .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT)}, .padding = {.x = CLAY__DEBUGVIEW_OUTER_PADDING }, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
||||
CLAY(Clay__AttachId(panelContentsId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }), CLAY_FLOATING({ .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = {.x = CLAY__DEBUGVIEW_OUTER_PADDING }, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
||||
layoutData = Clay__RenderDebugLayoutElementsList((int32_t)initialRootsLength, highlightedRow);
|
||||
}
|
||||
}
|
||||
@ -3258,22 +3254,22 @@ void Clay__RenderDebugView() {
|
||||
rowColor.g *= 1.25f;
|
||||
rowColor.b *= 1.25f;
|
||||
}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = rowColor })) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = rowColor })) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {.width = CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), .height = CLAY_SIZING_FIXED(1)} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_3 })) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(1)} }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_3 })) {}
|
||||
if (context->debugSelectedElementId != 0) {
|
||||
Clay_LayoutElementHashMapItem *selectedItem = Clay__GetHashMapItem(context->debugSelectedElementId);
|
||||
CLAY(
|
||||
CLAY_SCROLL({ .vertical = true }),
|
||||
CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_FIXED(300)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
||||
CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(300)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
||||
CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_2 }),
|
||||
CLAY_BORDER({ .betweenChildren = { .width = 1, .color = CLAY__DEBUGVIEW_COLOR_3 }})
|
||||
) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} })) {
|
||||
CLAY_TEXT(CLAY_STRING("Layout Config"), infoTextConfig);
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY__DEFAULT_STRUCT } })) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), {0} } })) {}
|
||||
if (selectedItem->elementId.stringId.length != 0) {
|
||||
CLAY_TEXT(selectedItem->elementId.stringId, infoTitleConfig);
|
||||
if (selectedItem->elementId.offset != 0) {
|
||||
@ -3406,7 +3402,7 @@ void Clay__RenderDebugView() {
|
||||
}
|
||||
// Image Preview
|
||||
CLAY_TEXT(CLAY_STRING("Preview"), infoTitleConfig);
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = imageConfig->sourceDimensions.width }), CLAY__DEFAULT_STRUCT }}), Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .imageElementConfig = imageConfig }, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0, imageConfig->sourceDimensions.width), {0} }}), Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .imageElementConfig = imageConfig }, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)) {}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3483,13 +3479,13 @@ void Clay__RenderDebugView() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CLAY(CLAY_ID("Clay__DebugViewWarningsScrollPane"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), CLAY_SIZING_FIXED(300)}, .childGap = 6, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_SCROLL({ .horizontal = true, .vertical = true }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_2 })) {
|
||||
CLAY(CLAY_ID("Clay__DebugViewWarningsScrollPane"), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(300)}, .childGap = 6, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_SCROLL({ .horizontal = true, .vertical = true }), CLAY_RECTANGLE({ .color = CLAY__DEBUGVIEW_COLOR_2 })) {
|
||||
Clay_TextElementConfig *warningConfig = CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE });
|
||||
CLAY(CLAY_ID("Clay__DebugViewWarningItemHeader"), CLAY_LAYOUT({ .sizing = {.height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childGap = 8, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} })) {
|
||||
CLAY_TEXT(CLAY_STRING("Warnings"), warningConfig);
|
||||
}
|
||||
CLAY(CLAY_ID("Clay__DebugViewWarningsTopBorder"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(CLAY__DEFAULT_STRUCT), .height = CLAY_SIZING_FIXED(1)} }), CLAY_RECTANGLE({ .color = {200, 200, 200, 255} })) {}
|
||||
int32_t previousWarningsLength = (int)context->warnings.length;
|
||||
CLAY(CLAY_ID("Clay__DebugViewWarningsTopBorder"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(1)} }), CLAY_RECTANGLE({ .color = {200, 200, 200, 255} })) {}
|
||||
int32_t previousWarningsLength = context->warnings.length;
|
||||
for (int32_t i = 0; i < previousWarningsLength; i++) {
|
||||
Clay__Warning warning = context->warnings.internalArray[i];
|
||||
CLAY(CLAY_IDI("Clay__DebugViewWarningItem", i), CLAY_LAYOUT({ .sizing = {.height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, 0}, .childGap = 8, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} })) {
|
||||
@ -3707,8 +3703,8 @@ Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions
|
||||
.maxElementCount = oldContext ? oldContext->maxElementCount : Clay__defaultMaxElementCount,
|
||||
.maxMeasureTextCacheWordCount = oldContext ? oldContext->maxMeasureTextCacheWordCount : Clay__defaultMaxElementCount * 2,
|
||||
.errorHandler = errorHandler.errorHandlerFunction ? errorHandler : CLAY__INIT(Clay_ErrorHandler) { Clay__ErrorHandlerFunctionDefault },
|
||||
.internalArena = arena,
|
||||
.layoutDimensions = layoutDimensions,
|
||||
.internalArena = arena,
|
||||
};
|
||||
Clay_SetCurrentContext(context);
|
||||
Clay__InitializePersistentMemory(context);
|
||||
|
@ -34,8 +34,12 @@ target_link_libraries(SDL2_video_demo PUBLIC
|
||||
SDL2_ttf::SDL2_ttf-static
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS_DEBUG "/D CLAY_DEBUG")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -Wno-error=missing-braces -DCLAY_DEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
TARGET SDL2_video_demo POST_BUILD
|
||||
|
@ -74,8 +74,8 @@ void HandleSidebarInteraction(
|
||||
static Clay_RenderCommandArray CreateLayout() {
|
||||
Clay_BeginLayout();
|
||||
Clay_Sizing layoutExpand = {
|
||||
.width = CLAY_SIZING_GROW(),
|
||||
.height = CLAY_SIZING_GROW()
|
||||
.width = CLAY_SIZING_GROW(0),
|
||||
.height = CLAY_SIZING_GROW(0)
|
||||
};
|
||||
|
||||
Clay_RectangleElementConfig contentBackgroundConfig = {
|
||||
@ -102,7 +102,7 @@ static Clay_RenderCommandArray CreateLayout() {
|
||||
CLAY_LAYOUT({
|
||||
.sizing = {
|
||||
.height = CLAY_SIZING_FIXED(60),
|
||||
.width = CLAY_SIZING_GROW()
|
||||
.width = CLAY_SIZING_GROW(0)
|
||||
},
|
||||
.padding = { 16 },
|
||||
.childGap = 16,
|
||||
@ -164,7 +164,7 @@ static Clay_RenderCommandArray CreateLayout() {
|
||||
}
|
||||
}
|
||||
RenderHeaderButton(CLAY_STRING("Edit"));
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }})) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }})) {}
|
||||
RenderHeaderButton(CLAY_STRING("Upload"));
|
||||
RenderHeaderButton(CLAY_STRING("Media"));
|
||||
RenderHeaderButton(CLAY_STRING("Support"));
|
||||
@ -183,14 +183,14 @@ static Clay_RenderCommandArray CreateLayout() {
|
||||
.childGap = 8,
|
||||
.sizing = {
|
||||
.width = CLAY_SIZING_FIXED(250),
|
||||
.height = CLAY_SIZING_GROW()
|
||||
.height = CLAY_SIZING_GROW(0)
|
||||
}
|
||||
})
|
||||
) {
|
||||
for (int i = 0; i < documents.length; i++) {
|
||||
Document document = documents.documents[i];
|
||||
Clay_LayoutConfig sidebarButtonLayout = {
|
||||
.sizing = { .width = CLAY_SIZING_GROW() },
|
||||
.sizing = { .width = CLAY_SIZING_GROW(0) },
|
||||
.padding = { 16, 16 }
|
||||
};
|
||||
|
||||
@ -262,7 +262,7 @@ void HandleClayErrors(Clay_ErrorData errorData) {
|
||||
printf("%s", errorData.errorText.chars);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int main(int argc, char *argv[]) {
|
||||
documents.documents = (Document[]) {
|
||||
{ .title = CLAY_STRING("Squirrels"), .contents = CLAY_STRING("The Secret Life of Squirrels: Nature's Clever Acrobats\n""Squirrels are often overlooked creatures, dismissed as mere park inhabitants or backyard nuisances. Yet, beneath their fluffy tails and twitching noses lies an intricate world of cunning, agility, and survival tactics that are nothing short of fascinating. As one of the most common mammals in North America, squirrels have adapted to a wide range of environments from bustling urban centers to tranquil forests and have developed a variety of unique behaviors that continue to intrigue scientists and nature enthusiasts alike.\n""\n""Master Tree Climbers\n""At the heart of a squirrel's skill set is its impressive ability to navigate trees with ease. Whether they're darting from branch to branch or leaping across wide gaps, squirrels possess an innate talent for acrobatics. Their powerful hind legs, which are longer than their front legs, give them remarkable jumping power. With a tail that acts as a counterbalance, squirrels can leap distances of up to ten times the length of their body, making them some of the best aerial acrobats in the animal kingdom.\n""But it's not just their agility that makes them exceptional climbers. Squirrels' sharp, curved claws allow them to grip tree bark with precision, while the soft pads on their feet provide traction on slippery surfaces. Their ability to run at high speeds and scale vertical trunks with ease is a testament to the evolutionary adaptations that have made them so successful in their arboreal habitats.\n""\n""Food Hoarders Extraordinaire\n""Squirrels are often seen frantically gathering nuts, seeds, and even fungi in preparation for winter. While this behavior may seem like instinctual hoarding, it is actually a survival strategy that has been honed over millions of years. Known as \"scatter hoarding,\" squirrels store their food in a variety of hidden locations, often burying it deep in the soil or stashing it in hollowed-out tree trunks.\n""Interestingly, squirrels have an incredible memory for the locations of their caches. Research has shown that they can remember thousands of hiding spots, often returning to them months later when food is scarce. However, they don't always recover every stash some forgotten caches eventually sprout into new trees, contributing to forest regeneration. This unintentional role as forest gardeners highlights the ecological importance of squirrels in their ecosystems.\n""\n""The Great Squirrel Debate: Urban vs. Wild\n""While squirrels are most commonly associated with rural or wooded areas, their adaptability has allowed them to thrive in urban environments as well. In cities, squirrels have become adept at finding food sources in places like parks, streets, and even garbage cans. However, their urban counterparts face unique challenges, including traffic, predators, and the lack of natural shelters. Despite these obstacles, squirrels in urban areas are often observed using human infrastructure such as buildings, bridges, and power lines as highways for their acrobatic escapades.\n""There is, however, a growing concern regarding the impact of urban life on squirrel populations. Pollution, deforestation, and the loss of natural habitats are making it more difficult for squirrels to find adequate food and shelter. As a result, conservationists are focusing on creating squirrel-friendly spaces within cities, with the goal of ensuring these resourceful creatures continue to thrive in both rural and urban landscapes.\n""\n""A Symbol of Resilience\n""In many cultures, squirrels are symbols of resourcefulness, adaptability, and preparation. Their ability to thrive in a variety of environments while navigating challenges with agility and grace serves as a reminder of the resilience inherent in nature. Whether you encounter them in a quiet forest, a city park, or your own backyard, squirrels are creatures that never fail to amaze with their endless energy and ingenuity.\n""In the end, squirrels may be small, but they are mighty in their ability to survive and thrive in a world that is constantly changing. So next time you spot one hopping across a branch or darting across your lawn, take a moment to appreciate the remarkable acrobat at work a true marvel of the natural world.\n") },
|
||||
{ .title = CLAY_STRING("Lorem Ipsum"), .contents = CLAY_STRING("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") },
|
||||
|
@ -37,11 +37,11 @@ void Layout() {
|
||||
static Clay_Color BACKGROUND = { 0xF4, 0xEB, 0xE6, 255 };
|
||||
static Clay_Color ACCENT = { 0xFA, 0xE0, 0xD4, 255 };
|
||||
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) },
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
||||
CLAY_RECTANGLE({ .color = BACKGROUND })) {
|
||||
CLAY(CLAY_ID("PageMargins"),
|
||||
CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() },
|
||||
CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) },
|
||||
.padding = { 70., 50. }, // Some nice looking page margins
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||
.childGap = 10})) {
|
||||
@ -57,8 +57,8 @@ void Layout() {
|
||||
));
|
||||
|
||||
// Feature Box
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT() }, .childGap = 10 })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT() }}), CLAY_RECTANGLE({
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(0) }, .childGap = 10 })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(0) }}), CLAY_RECTANGLE({
|
||||
.color = ACCENT,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(12),
|
||||
})) {
|
||||
@ -76,7 +76,7 @@ void Layout() {
|
||||
}
|
||||
}
|
||||
CLAY(CLAY_LAYOUT({
|
||||
.sizing = {CLAY_SIZING_FIT(), CLAY_SIZING_GROW()},
|
||||
.sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)},
|
||||
.padding = { 10, 10 },
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER },
|
||||
@ -84,7 +84,7 @@ void Layout() {
|
||||
}), CLAY_RECTANGLE({ .color = ACCENT, .cornerRadius = CLAY_CORNER_RADIUS(8) })) {
|
||||
// Profile picture
|
||||
CLAY(CLAY_LAYOUT({
|
||||
.sizing = {CLAY_SIZING_FIT(), CLAY_SIZING_GROW()},
|
||||
.sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)},
|
||||
.padding = { 30, 0 },
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }}), CLAY_BORDER_OUTSIDE_RADIUS(2, PRIMARY, 10)) {
|
||||
@ -93,9 +93,9 @@ void Layout() {
|
||||
}
|
||||
}
|
||||
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIXED(16) } }));
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(16) } }));
|
||||
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() }, .childGap = 10, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childGap = 10, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
||||
CLAY_TEXT(CLAY_STRING("Cairo"), CLAY_TEXT_CONFIG({ .fontFamily = CLAY_STRING("Calistoga"), .fontSize = 24, .textColor = PRIMARY }));
|
||||
CLAY(CLAY_LAYOUT({ .padding = { 10, 10 } }), CLAY_RECTANGLE({ .color = ACCENT, .cornerRadius = CLAY_CORNER_RADIUS(10) })) {
|
||||
CLAY_TEXT(CLAY_STRING("Officiis quia quia qui inventore ratione voluptas et. Quidem sunt unde similique. Qui est et exercitationem cumque harum illum. Numquam placeat aliquid quo voluptatem. "
|
||||
|
Binary file not shown.
@ -41,18 +41,18 @@ Clay_TextElementConfig headerTextConfig = (Clay_TextElementConfig) { .fontId = 2
|
||||
Clay_TextElementConfig blobTextConfig = (Clay_TextElementConfig) { .fontId = 2, .fontSize = 30, .textColor = {244, 235, 230, 255} };
|
||||
|
||||
void LandingPageBlob(int index, int fontSize, Clay_Color color, Clay_String text, Clay_String imageURL) {
|
||||
CLAY(CLAY_IDI("HeroBlob", index), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 480 }) }, .padding = {16, 16}, .childGap = 16, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }), CLAY_BORDER_OUTSIDE_RADIUS(2, color, 10)) {
|
||||
CLAY(CLAY_IDI("HeroBlob", index), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 480) }, .padding = {16, 16}, .childGap = 16, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }), CLAY_BORDER_OUTSIDE_RADIUS(2, color, 10)) {
|
||||
CLAY(CLAY_IDI("CheckImage", index), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_FIXED(32) } }), CLAY_IMAGE({ .sourceDimensions = { 128, 128 }, .sourceURL = imageURL })) {}
|
||||
CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .fontSize = fontSize, .fontId = FONT_ID_BODY_24, .textColor = color }));
|
||||
}
|
||||
}
|
||||
|
||||
void LandingPageDesktop() {
|
||||
CLAY(CLAY_ID("LandingPage1Desktop"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIT({ .min = windowHeight - 70 }) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = { .x = 50 } })) {
|
||||
CLAY(CLAY_ID("LandingPage1"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = { 32, 32 }, .childGap = 32 }), CLAY_BORDER({ .left = { 2, COLOR_RED }, .right = { 2, COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("LandingPage1Desktop"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = windowHeight - 70) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = { .x = 50 } })) {
|
||||
CLAY(CLAY_ID("LandingPage1"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = { 32, 32 }, .childGap = 32 }), CLAY_BORDER({ .left = { 2, COLOR_RED }, .right = { 2, COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("LeftText"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_PERCENT(0.55f) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance."), CLAY_TEXT_CONFIG({ .fontSize = 56, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||
CLAY(CLAY_ID("LandingPageSpacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(32) } })) {}
|
||||
CLAY(CLAY_ID("LandingPageSpacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } })) {}
|
||||
CLAY_TEXT(CLAY_STRING("Clay is laying out this webpage right now!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
||||
}
|
||||
CLAY(CLAY_ID("HeroImageOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_PERCENT(0.45f) }, .childAlignment = { CLAY_ALIGN_X_CENTER }, .childGap = 16 })) {
|
||||
@ -67,13 +67,13 @@ void LandingPageDesktop() {
|
||||
}
|
||||
|
||||
void LandingPageMobile() {
|
||||
CLAY(CLAY_ID("LandingPage1Mobile"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIT({ .min = windowHeight - 70 }) }, .childAlignment = {CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = { 16, 32 }, .childGap = 32 })) {
|
||||
CLAY(CLAY_ID("LeftText"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW() }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("LandingPage1Mobile"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = windowHeight - 70) }, .childAlignment = {CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = { 16, 32 }, .childGap = 32 })) {
|
||||
CLAY(CLAY_ID("LeftText"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance."), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||
CLAY(CLAY_ID("LandingPageSpacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(32) } })) {}
|
||||
CLAY(CLAY_ID("LandingPageSpacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } })) {}
|
||||
CLAY_TEXT(CLAY_STRING("Clay is laying out this webpage right now!"), CLAY_TEXT_CONFIG({ .fontSize = 32, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
||||
}
|
||||
CLAY(CLAY_ID("HeroImageOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW() }, .childAlignment = { CLAY_ALIGN_X_CENTER }, .childGap = 16 })) {
|
||||
CLAY(CLAY_ID("HeroImageOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .childAlignment = { CLAY_ALIGN_X_CENTER }, .childGap = 16 })) {
|
||||
LandingPageBlob(1, 28, COLOR_BLOB_BORDER_5, CLAY_STRING("High performance"), CLAY_STRING("/clay/images/check_5.png"));
|
||||
LandingPageBlob(2, 28, COLOR_BLOB_BORDER_4, CLAY_STRING("Flexbox-style responsive layout"), CLAY_STRING("/clay/images/check_4.png"));
|
||||
LandingPageBlob(3, 28, COLOR_BLOB_BORDER_3, CLAY_STRING("Declarative syntax"), CLAY_STRING("/clay/images/check_3.png"));
|
||||
@ -84,8 +84,8 @@ void LandingPageMobile() {
|
||||
}
|
||||
|
||||
void FeatureBlocksDesktop() {
|
||||
CLAY(CLAY_ID("FeatureBlocksOuter"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() } })) {
|
||||
CLAY(CLAY_ID("FeatureBlocksInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }), CLAY_BORDER({ .betweenChildren = { .width = 2, .color = COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("FeatureBlocksOuter"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) } })) {
|
||||
CLAY(CLAY_ID("FeatureBlocksInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }), CLAY_BORDER({ .betweenChildren = { .width = 2, .color = COLOR_RED } })) {
|
||||
Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_RED });
|
||||
CLAY(CLAY_ID("HFileBoxOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_PERCENT(0.5f) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {50, 32}, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("HFileIncludeOuter"), CLAY_LAYOUT({ .padding = {8, 4} }), CLAY_RECTANGLE({ .color = COLOR_RED, .cornerRadius = CLAY_CORNER_RADIUS(8) })) {
|
||||
@ -104,16 +104,16 @@ void FeatureBlocksDesktop() {
|
||||
}
|
||||
|
||||
void FeatureBlocksMobile() {
|
||||
CLAY(CLAY_ID("FeatureBlocksInner"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW() } }), CLAY_BORDER({ .betweenChildren = { .width = 2, .color = COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("FeatureBlocksInner"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) } }), CLAY_BORDER({ .betweenChildren = { .width = 2, .color = COLOR_RED } })) {
|
||||
Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_RED });
|
||||
CLAY(CLAY_ID("HFileBoxOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW() }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {16, 32}, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("HFileBoxOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {16, 32}, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("HFileIncludeOuter"), CLAY_LAYOUT({ .padding = {8, 4} }), CLAY_RECTANGLE({ .color = COLOR_RED, .cornerRadius = CLAY_CORNER_RADIUS(8) })) {
|
||||
CLAY_TEXT(CLAY_STRING("#include clay.h"), CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_LIGHT }));
|
||||
}
|
||||
CLAY_TEXT(CLAY_STRING("~2000 lines of C99."), textConfig);
|
||||
CLAY_TEXT(CLAY_STRING("Zero dependencies, including no C standard library."), textConfig);
|
||||
}
|
||||
CLAY(CLAY_ID("BringYourOwnRendererOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW() }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 16, .y = 32}, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("BringYourOwnRendererOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 16, .y = 32}, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Renderer agnostic."), CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = COLOR_ORANGE }));
|
||||
CLAY_TEXT(CLAY_STRING("Layout with clay, then render with Raylib, WebGL Canvas or even as HTML."), textConfig);
|
||||
CLAY_TEXT(CLAY_STRING("Flexible output for easy compositing in your custom engine or environment."), textConfig);
|
||||
@ -122,33 +122,33 @@ void FeatureBlocksMobile() {
|
||||
}
|
||||
|
||||
void DeclarativeSyntaxPageDesktop() {
|
||||
CLAY(CLAY_ID("SyntaxPageDesktop"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT({ .min = windowHeight - 50 }) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 50} })) {
|
||||
CLAY(CLAY_ID("SyntaxPage"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = { 32, 32 }, .childGap = 32 }), CLAY_BORDER({ .left = { 2, COLOR_RED }, .right = { 2, COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("SyntaxPageDesktop"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 50} })) {
|
||||
CLAY(CLAY_ID("SyntaxPage"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = { 32, 32 }, .childGap = 32 }), CLAY_BORDER({ .left = { 2, COLOR_RED }, .right = { 2, COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("SyntaxPageLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||
CLAY(CLAY_ID("SyntaxSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 16 }) } })) {}
|
||||
CLAY(CLAY_ID("SyntaxSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 16) } })) {}
|
||||
CLAY_TEXT(CLAY_STRING("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
}
|
||||
CLAY(CLAY_ID("SyntaxPageRightImage"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} })) {
|
||||
CLAY(CLAY_ID("SyntaxPageRightImageInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 568 }) } }), CLAY_IMAGE({ .sourceDimensions = {1136, 1194}, .sourceURL = CLAY_STRING("/clay/images/declarative.png") })) {}
|
||||
CLAY(CLAY_ID("SyntaxPageRightImageInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 568) } }), CLAY_IMAGE({ .sourceDimensions = {1136, 1194}, .sourceURL = CLAY_STRING("/clay/images/declarative.png") })) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DeclarativeSyntaxPageMobile() {
|
||||
CLAY(CLAY_ID("SyntaxPageDesktop"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT({ .min = windowHeight - 50 }) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {16, 32}, .childGap = 16 })) {
|
||||
CLAY(CLAY_ID("SyntaxPageLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("SyntaxPageDesktop"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {16, 32}, .childGap = 16 })) {
|
||||
CLAY(CLAY_ID("SyntaxPageLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||
CLAY(CLAY_ID("SyntaxSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 16 }) } })) {}
|
||||
CLAY(CLAY_ID("SyntaxSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 16) } })) {}
|
||||
CLAY_TEXT(CLAY_STRING("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
}
|
||||
CLAY(CLAY_ID("SyntaxPageRightImage"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} })) {
|
||||
CLAY(CLAY_ID("SyntaxPageRightImageInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 568 }) } }), CLAY_IMAGE({ .sourceDimensions = {1136, 1194}, .sourceURL = CLAY_STRING("/clay/images/declarative.png") } )) {}
|
||||
CLAY(CLAY_ID("SyntaxPageRightImage"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} })) {
|
||||
CLAY(CLAY_ID("SyntaxPageRightImageInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 568) } }), CLAY_IMAGE({ .sourceDimensions = {1136, 1194}, .sourceURL = CLAY_STRING("/clay/images/declarative.png") } )) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,20 +165,20 @@ Clay_Color ColorLerp(Clay_Color a, Clay_Color b, float amount) {
|
||||
Clay_String LOREM_IPSUM_TEXT = CLAY_STRING("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
||||
|
||||
void HighPerformancePageDesktop(float lerpValue) {
|
||||
CLAY(CLAY_ID("PerformancePageOuter"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT({ .min = windowHeight - 50 }) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 82, 32}, .childGap = 64 }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("PerformanceDesktop"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 82, 32}, .childGap = 64 }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("PerformanceLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||
CLAY(CLAY_ID("PerformanceSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 16 }) }})) {}
|
||||
CLAY(CLAY_ID("PerformanceSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 16) }})) {}
|
||||
CLAY_TEXT(CLAY_STRING("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
}
|
||||
CLAY(CLAY_ID("PerformanceRightImageOuter"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIXED(400) } }), CLAY_BORDER_ALL({ .width = 2, .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("AnimationDemoContainerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.3f + 0.4f * lerpValue), CLAY_SIZING_GROW() }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {32, 32} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) })) {
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }), CLAY_BORDER_ALL({ .width = 2, .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("AnimationDemoContainerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.3f + 0.4f * lerpValue), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {32, 32} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) })) {
|
||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||
}
|
||||
CLAY(CLAY_ID("AnimationDemoContainerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {32, 32} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) })) {
|
||||
CLAY(CLAY_ID("AnimationDemoContainerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {32, 32} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) })) {
|
||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||
}
|
||||
}
|
||||
@ -187,20 +187,20 @@ void HighPerformancePageDesktop(float lerpValue) {
|
||||
}
|
||||
|
||||
void HighPerformancePageMobile(float lerpValue) {
|
||||
CLAY(CLAY_ID("PerformancePageOuter"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT({ .min = windowHeight - 50 }) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 16, 32}, .childGap = 32 }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("PerformanceLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("PerformanceMobile"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 16, 32}, .childGap = 32 }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("PerformanceLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||
CLAY(CLAY_ID("PerformanceSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 16 }) }})) {}
|
||||
CLAY(CLAY_ID("PerformanceSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 16) }})) {}
|
||||
CLAY_TEXT(CLAY_STRING("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
}
|
||||
CLAY(CLAY_ID("PerformanceRightImageOuter"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }, .childAlignment = {CLAY_ALIGN_X_CENTER} })) {
|
||||
CLAY(CLAY_ID(""), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIXED(400) } }), CLAY_BORDER_ALL({ .width = 2, .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("AnimationDemoContainerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.35f + 0.3f * lerpValue), CLAY_SIZING_GROW() }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {16, 16} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) })) {
|
||||
CLAY(CLAY_ID("PerformanceRightImageOuter"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {CLAY_ALIGN_X_CENTER} })) {
|
||||
CLAY(CLAY_ID(""), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }), CLAY_BORDER_ALL({ .width = 2, .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("AnimationDemoContainerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.35f + 0.3f * lerpValue), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {16, 16} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) })) {
|
||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||
}
|
||||
CLAY(CLAY_ID("AnimationDemoContainerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {16, 16} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) })) {
|
||||
CLAY(CLAY_ID("AnimationDemoContainerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = {16, 16} }), CLAY_RECTANGLE({ .color = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) })) {
|
||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||
}
|
||||
}
|
||||
@ -235,18 +235,18 @@ void RendererButtonInactive(Clay_String text, size_t rendererIndex) {
|
||||
}
|
||||
|
||||
void RendererPageDesktop() {
|
||||
CLAY(CLAY_ID("RendererPageDesktop"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT({ .min = windowHeight - 50 }) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 50} })) {
|
||||
CLAY(CLAY_ID("RendererPage"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = { 32, 32 }, .childGap = 32 }), CLAY_BORDER({ .left = { 2, COLOR_RED }, .right = { 2, COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("RendererPageDesktop"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 50} })) {
|
||||
CLAY(CLAY_ID("RendererPage"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = { 32, 32 }, .childGap = 32 }), CLAY_BORDER({ .left = { 2, COLOR_RED }, .right = { 2, COLOR_RED } })) {
|
||||
CLAY(CLAY_ID("RendererLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||
CLAY(CLAY_ID("RendererSpacerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 16 }) }})) {}
|
||||
CLAY(CLAY_ID("RendererSpacerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 16) }})) {}
|
||||
CLAY_TEXT(CLAY_STRING("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("Write your own renderer in a few hundred lines of code, or use the provided examples for Raylib, WebGL canvas and more."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
}
|
||||
CLAY(CLAY_ID("RendererRightText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childAlignment = {CLAY_ALIGN_X_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_BODY_36, .textColor = COLOR_ORANGE }));
|
||||
CLAY(CLAY_ID("RendererSpacerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 32 }) } })) {}
|
||||
CLAY(CLAY_ID("RendererSpacerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 32) } })) {}
|
||||
if (ACTIVE_RENDERER_INDEX == 0) {
|
||||
RendererButtonActive(CLAY_STRING("HTML Renderer"));
|
||||
RendererButtonInactive(CLAY_STRING("Canvas Renderer"), 1);
|
||||
@ -260,17 +260,17 @@ void RendererPageDesktop() {
|
||||
}
|
||||
|
||||
void RendererPageMobile() {
|
||||
CLAY(CLAY_ID("RendererMobile"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT({ .min = windowHeight - 50 }) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = {.x = 16, 32}, .childGap = 32 }), CLAY_RECTANGLE({ .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("RendererLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY(CLAY_ID("RendererMobile"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = {.x = 16, 32}, .childGap = 32 }), CLAY_RECTANGLE({ .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("RendererLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||
CLAY(CLAY_ID("RendererSpacerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 16 }) }})) {}
|
||||
CLAY(CLAY_ID("RendererSpacerLeft"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 16) }})) {}
|
||||
CLAY_TEXT(CLAY_STRING("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("Write your own renderer in a few hundred lines of code, or use the provided examples for Raylib, WebGL canvas and more."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||
}
|
||||
CLAY(CLAY_ID("RendererRightText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 })) {
|
||||
CLAY(CLAY_ID("RendererRightText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_BODY_36, .textColor = COLOR_ORANGE }));
|
||||
CLAY(CLAY_ID("RendererSpacerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 32}) }})) {}
|
||||
CLAY(CLAY_ID("RendererSpacerRight"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 32) }})) {}
|
||||
if (ACTIVE_RENDERER_INDEX == 0) {
|
||||
RendererButtonActive(CLAY_STRING("HTML Renderer"));
|
||||
RendererButtonInactive(CLAY_STRING("Canvas Renderer"), 1);
|
||||
@ -283,17 +283,17 @@ void RendererPageMobile() {
|
||||
}
|
||||
|
||||
void DebuggerPageDesktop() {
|
||||
CLAY(CLAY_ID("DebuggerDesktop"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIT({ .min = windowHeight - 50 }) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 82, 32}, .childGap = 64 }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("DebuggerDesktop"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {.x = 82, 32}, .childGap = 64 }), CLAY_RECTANGLE({ .color = COLOR_RED })) {
|
||||
CLAY(CLAY_ID("DebuggerLeftText"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 })) {
|
||||
CLAY_TEXT(CLAY_STRING("Integrated Debug Tools"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||
CLAY(CLAY_ID("DebuggerSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 16 }) }})) {}
|
||||
CLAY(CLAY_ID("DebuggerSpacer"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 16) }})) {}
|
||||
CLAY_TEXT(CLAY_STRING("Clay includes built in \"Chrome Inspector\"-style debug tooling."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
CLAY_TEXT(CLAY_STRING("View your layout hierarchy and config in real time."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||
CLAY(CLAY_ID("DebuggerPageSpacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(32) } })) {}
|
||||
CLAY(CLAY_ID("DebuggerPageSpacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } })) {}
|
||||
CLAY_TEXT(CLAY_STRING("Press the \"d\" key to try it out now!"), CLAY_TEXT_CONFIG({ .fontSize = 32, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
||||
}
|
||||
CLAY(CLAY_ID("DebuggerRightImageOuter"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} })) {
|
||||
CLAY(CLAY_ID("DebuggerPageRightImageInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW({ .max = 558 }) } }), CLAY_IMAGE({ .sourceDimensions = {1620, 1474}, .sourceURL = CLAY_STRING("/clay/images/debugger.png") })) {}
|
||||
CLAY(CLAY_ID("DebuggerPageRightImageInner"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(.max = 558) } }), CLAY_IMAGE({ .sourceDimensions = {1620, 1474}, .sourceURL = CLAY_STRING("/clay/images/debugger.png") })) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,10 +310,10 @@ float animationLerpValue = -1.0f;
|
||||
|
||||
Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) {
|
||||
Clay_BeginLayout();
|
||||
CLAY(CLAY_ID("OuterContainer"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() } }), CLAY_RECTANGLE({ .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("Header"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIXED(50) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .childGap = 16, .padding = { 32 } })) {
|
||||
CLAY(CLAY_ID("OuterContainer"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) } }), CLAY_RECTANGLE({ .color = COLOR_LIGHT })) {
|
||||
CLAY(CLAY_ID("Header"), CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(50) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .childGap = 16, .padding = { 32 } })) {
|
||||
CLAY_TEXT(CLAY_STRING("Clay"), &headerTextConfig);
|
||||
CLAY(CLAY_ID("Spacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW() } })) {}
|
||||
CLAY(CLAY_ID("Spacer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0) } })) {}
|
||||
if (!mobileScreen) {
|
||||
CLAY(CLAY_ID("LinkExamplesOuter"), CLAY_LAYOUT({ .padding = {8} }), CLAY_RECTANGLE({ .link = CLAY_STRING("https://github.com/nicbarker/clay/tree/main/examples"), .color = {0,0,0,0} })) {
|
||||
CLAY_TEXT(CLAY_STRING("Examples"), CLAY_TEXT_CONFIG({ .disablePointerEvents = true, .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} }));
|
||||
@ -338,14 +338,14 @@ Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) {
|
||||
CLAY_TEXT(CLAY_STRING("Github"), CLAY_TEXT_CONFIG({ .disablePointerEvents = true, .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} }));
|
||||
}
|
||||
}
|
||||
Clay_LayoutConfig topBorderConfig = (Clay_LayoutConfig) { .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_FIXED(4) }};
|
||||
Clay_LayoutConfig topBorderConfig = (Clay_LayoutConfig) { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(4) }};
|
||||
CLAY(CLAY_ID("TopBorder1"), CLAY_LAYOUT(topBorderConfig), CLAY_RECTANGLE({ .color = COLOR_TOP_BORDER_5 })) {}
|
||||
CLAY(CLAY_ID("TopBorder2"), CLAY_LAYOUT(topBorderConfig), CLAY_RECTANGLE({ .color = COLOR_TOP_BORDER_4 })) {}
|
||||
CLAY(CLAY_ID("TopBorder3"), CLAY_LAYOUT(topBorderConfig), CLAY_RECTANGLE({ .color = COLOR_TOP_BORDER_3 })) {}
|
||||
CLAY(CLAY_ID("TopBorder4"), CLAY_LAYOUT(topBorderConfig), CLAY_RECTANGLE({ .color = COLOR_TOP_BORDER_2 })) {}
|
||||
CLAY(CLAY_ID("TopBorder5"), CLAY_LAYOUT(topBorderConfig), CLAY_RECTANGLE({ .color = COLOR_TOP_BORDER_1 })) {}
|
||||
CLAY(CLAY_ID("OuterScrollContainer"),
|
||||
CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(), CLAY_SIZING_GROW() }, .layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
||||
CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM }),
|
||||
CLAY_SCROLL({ .vertical = true }),
|
||||
CLAY_BORDER({ .betweenChildren = {2, COLOR_RED} })
|
||||
) {
|
||||
|
@ -2,11 +2,15 @@ cmake_minimum_required(VERSION 3.27)
|
||||
project(clay_examples_cpp_project_example CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g")
|
||||
endif()
|
||||
|
||||
add_executable(clay_examples_cpp_project_example main.cpp)
|
||||
|
||||
target_include_directories(clay_examples_cpp_project_example PUBLIC .)
|
||||
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Werror -Wall")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
endif()
|
||||
|
@ -25,8 +25,12 @@ target_include_directories(clay_examples_introducing_clay_video_demo PUBLIC .)
|
||||
|
||||
target_link_libraries(clay_examples_introducing_clay_video_demo PUBLIC raylib)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS_DEBUG "/D CLAY_DEBUG")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -Wno-error=missing-braces -DCLAY_DEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
TARGET clay_examples_introducing_clay_video_demo POST_BUILD
|
||||
|
@ -111,8 +111,8 @@ int main(void) {
|
||||
);
|
||||
|
||||
Clay_Sizing layoutExpand = {
|
||||
.width = CLAY_SIZING_GROW(),
|
||||
.height = CLAY_SIZING_GROW()
|
||||
.width = CLAY_SIZING_GROW(0),
|
||||
.height = CLAY_SIZING_GROW(0)
|
||||
};
|
||||
|
||||
Clay_RectangleElementConfig contentBackgroundConfig = {
|
||||
@ -139,7 +139,7 @@ int main(void) {
|
||||
CLAY_LAYOUT({
|
||||
.sizing = {
|
||||
.height = CLAY_SIZING_FIXED(60),
|
||||
.width = CLAY_SIZING_GROW()
|
||||
.width = CLAY_SIZING_GROW(0)
|
||||
},
|
||||
.padding = { 16 },
|
||||
.childGap = 16,
|
||||
@ -201,7 +201,7 @@ int main(void) {
|
||||
}
|
||||
}
|
||||
RenderHeaderButton(CLAY_STRING("Edit"));
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW() }})) {}
|
||||
CLAY(CLAY_LAYOUT({ .sizing = { CLAY_SIZING_GROW(0) }})) {}
|
||||
RenderHeaderButton(CLAY_STRING("Upload"));
|
||||
RenderHeaderButton(CLAY_STRING("Media"));
|
||||
RenderHeaderButton(CLAY_STRING("Support"));
|
||||
@ -220,14 +220,14 @@ int main(void) {
|
||||
.childGap = 8,
|
||||
.sizing = {
|
||||
.width = CLAY_SIZING_FIXED(250),
|
||||
.height = CLAY_SIZING_GROW()
|
||||
.height = CLAY_SIZING_GROW(0)
|
||||
}
|
||||
})
|
||||
) {
|
||||
for (int i = 0; i < documents.length; i++) {
|
||||
Document document = documents.documents[i];
|
||||
Clay_LayoutConfig sidebarButtonLayout = {
|
||||
.sizing = { .width = CLAY_SIZING_GROW() },
|
||||
.sizing = { .width = CLAY_SIZING_GROW(0) },
|
||||
.padding = { 16, 16 }
|
||||
};
|
||||
|
||||
|
@ -25,8 +25,12 @@ target_include_directories(clay_examples_raylib_sidebar_scrolling_container PUBL
|
||||
|
||||
target_link_libraries(clay_examples_raylib_sidebar_scrolling_container PUBLIC raylib)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS_DEBUG "/D CLAY_DEBUG")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -Wno-error=missing-braces -DCLAY_DEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
TARGET clay_examples_raylib_sidebar_scrolling_container POST_BUILD
|
||||
|
@ -10,7 +10,7 @@ const uint32_t FONT_ID_BODY_16 = 1;
|
||||
Texture2D profilePicture;
|
||||
#define RAYLIB_VECTOR2_TO_CLAY_VECTOR2(vector) (Clay_Vector2) { .x = vector.x, .y = vector.y }
|
||||
|
||||
Clay_String profileText = {.length = 101, .chars = "Profile Page one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen" };
|
||||
Clay_String profileText = CLAY_STRING_CONST("Profile Page one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen");
|
||||
Clay_TextElementConfig headerTextConfig = { .fontId = 1, .fontSize = 16, .textColor = {0,0,0,255} };
|
||||
|
||||
void HandleHeaderButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerData, intptr_t userData) {
|
||||
@ -40,27 +40,27 @@ void RenderDropdownTextItem(int index) {
|
||||
|
||||
Clay_RenderCommandArray CreateLayout() {
|
||||
Clay_BeginLayout();
|
||||
CLAY(CLAY_ID("OuterContainer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_GROW() }, .padding = { 16, 16 }, .childGap = 16 }), CLAY_RECTANGLE({ .color = {200, 200, 200, 255} })) {
|
||||
CLAY(CLAY_ID("SideBar"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW() }, .padding = {16, 16}, .childGap = 16 }), CLAY_RECTANGLE({ .color = {150, 150, 255, 255} })) {
|
||||
CLAY(CLAY_ID("ProfilePictureOuter"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW() }, .padding = { 8, 8 }, .childGap = 8, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }), CLAY_RECTANGLE({ .color = {130, 130, 255, 255} })) {
|
||||
CLAY(CLAY_ID("OuterContainer"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) }, .padding = { 16, 16 }, .childGap = 16 }), CLAY_RECTANGLE({ .color = {200, 200, 200, 255} })) {
|
||||
CLAY(CLAY_ID("SideBar"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = {16, 16}, .childGap = 16 }), CLAY_RECTANGLE({ .color = {150, 150, 255, 255} })) {
|
||||
CLAY(CLAY_ID("ProfilePictureOuter"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = { 8, 8 }, .childGap = 8, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }), CLAY_RECTANGLE({ .color = {130, 130, 255, 255} })) {
|
||||
CLAY(CLAY_ID("ProfilePicture"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) } }), CLAY_IMAGE({ .imageData = &profilePicture, .sourceDimensions = {60, 60} })) {}
|
||||
CLAY_TEXT(profileText, CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {0, 0, 0, 255} }));
|
||||
}
|
||||
CLAY(CLAY_ID("SidebarBlob1"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
CLAY(CLAY_ID("SidebarBlob2"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
CLAY(CLAY_ID("SidebarBlob3"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
CLAY(CLAY_ID("SidebarBlob4"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
CLAY(CLAY_ID("SidebarBlob1"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
CLAY(CLAY_ID("SidebarBlob2"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
CLAY(CLAY_ID("SidebarBlob3"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
CLAY(CLAY_ID("SidebarBlob4"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) }}), CLAY_RECTANGLE({ .color = {110, 110, 255, 255} })) {}
|
||||
}
|
||||
|
||||
CLAY(CLAY_ID("RightPanel"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_GROW() }, .childGap = 16 })) {
|
||||
CLAY(CLAY_ID("HeaderBar"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW() }, .childAlignment = { .x = CLAY_ALIGN_X_RIGHT }, .padding = {8, 8}, .childGap = 8 }), CLAY_RECTANGLE({ .color = {180, 180, 180, 255} })) {
|
||||
CLAY(CLAY_ID("RightPanel"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) }, .childGap = 16 })) {
|
||||
CLAY(CLAY_ID("HeaderBar"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0) }, .childAlignment = { .x = CLAY_ALIGN_X_RIGHT }, .padding = {8, 8}, .childGap = 8 }), CLAY_RECTANGLE({ .color = {180, 180, 180, 255} })) {
|
||||
RenderHeaderButton(CLAY_STRING("Header Item 1"));
|
||||
RenderHeaderButton(CLAY_STRING("Header Item 2"));
|
||||
RenderHeaderButton(CLAY_STRING("Header Item 3"));
|
||||
}
|
||||
CLAY(CLAY_ID("MainContent"),
|
||||
CLAY_SCROLL({ .vertical = true }),
|
||||
CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .padding = {16, 16}, .childGap = 16, .sizing = { CLAY_SIZING_GROW() } }),
|
||||
CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .padding = {16, 16}, .childGap = 16, .sizing = { CLAY_SIZING_GROW(0) } }),
|
||||
CLAY_RECTANGLE({ .color = {200, 200, 255, 255} }))
|
||||
{
|
||||
CLAY(CLAY_ID("FloatingContainer"),
|
||||
@ -87,7 +87,7 @@ Clay_RenderCommandArray CreateLayout() {
|
||||
CLAY_TEXT(CLAY_STRING("Suspendisse in est ante in nibh. Amet venenatis urna cursus eget nunc scelerisque viverra. Elementum sagittis vitae et leo duis ut diam quam nulla. Enim nulla aliquet porttitor lacus. Pellentesque habitant morbi tristique senectus et. Facilisi nullam vehicula ipsum a arcu cursus vitae.\nSem fringilla ut morbi tincidunt. Euismod quis viverra nibh cras pulvinar mattis nunc sed. Velit sed ullamcorper morbi tincidunt ornare massa. Varius quam quisque id diam vel quam. Nulla pellentesque dignissim enim sit amet venenatis. Enim lobortis scelerisque fermentum dui faucibus in. Pretium viverra suspendisse potenti nullam ac tortor vitae. Lectus vestibulum mattis ullamcorper velit sed. Eget mauris pharetra et ultrices neque ornare aenean euismod elementum. Habitant morbi tristique senectus et. Integer vitae justo eget magna fermentum iaculis eu. Semper quis lectus nulla at volutpat diam. Enim praesent elementum facilisis leo. Massa vitae tortor condimentum lacinia quis vel."),
|
||||
CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {0,0,0,255} }));
|
||||
|
||||
CLAY(CLAY_ID("Photos"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW() }, .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER }, .childGap = 16, .padding = {16, 16} }), CLAY_RECTANGLE({ .color = {180, 180, 220, 255} })) {
|
||||
CLAY(CLAY_ID("Photos"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_GROW(0) }, .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER }, .childGap = 16, .padding = {16, 16} }), CLAY_RECTANGLE({ .color = {180, 180, 220, 255} })) {
|
||||
CLAY(CLAY_ID("Picture2"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_FIXED(120), .height = CLAY_SIZING_FIXED(120) }}), CLAY_IMAGE({ .imageData = &profilePicture, .sourceDimensions = {120, 120} })) {}
|
||||
CLAY(CLAY_ID("Picture1"), CLAY_LAYOUT({ .childAlignment = { .x = CLAY_ALIGN_X_CENTER }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .padding = {8, 8} }), CLAY_RECTANGLE({ .color = {170, 170, 220, 255} })) {
|
||||
CLAY(CLAY_ID("ProfilePicture2"), CLAY_LAYOUT({ .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}), CLAY_IMAGE({ .imageData = &profilePicture, .sourceDimensions = {60, 60} })) {}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "../../clay.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user