mirror of
https://github.com/nicbarker/clay.git
synced 2025-05-03 17:08:06 +00:00
Compare commits
6 Commits
a61fbea400
...
c83851e3a3
Author | SHA1 | Date | |
---|---|---|---|
|
c83851e3a3 | ||
|
44fb89c8b6 | ||
|
bc9ef8b02d | ||
|
0989aeee06 | ||
|
e11a394c25 | ||
|
5c01540234 |
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-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")
|
||||
add_subdirectory("examples/introducing-clay-video-demo")
|
||||
add_subdirectory("examples/SDL2-video-demo")
|
||||
endif()
|
||||
add_subdirectory("examples/introducing-clay-video-demo")
|
||||
add_subdirectory("examples/SDL2-video-demo")
|
||||
|
118
README.md
118
README.md
@ -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
|
||||
@ -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)`
|
||||
@ -665,6 +750,8 @@ CLAY(CLAY_ID("Outer"), CLAY_LAYOUT({ .padding = {16, 16} })) {
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_ID
|
||||
|
||||
**Usage**
|
||||
@ -699,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**
|
||||
@ -816,6 +907,8 @@ CLAY(CLAY_ID("Button"), CLAY_LAYOUT({ .layoutDirection = CLAY_TOP_TO_BOTTOM, .si
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_RECTANGLE
|
||||
**Usage**
|
||||
|
||||
@ -897,6 +990,8 @@ CLAY(
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_TEXT
|
||||
**Usage**
|
||||
|
||||
@ -1018,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**
|
||||
|
||||
@ -1115,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**
|
||||
|
||||
@ -1174,6 +1273,8 @@ CLAY(CLAY_SCROLL(.vertical = true)) {
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CLAY_BORDER
|
||||
**Usage**
|
||||
|
||||
@ -1291,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**
|
||||
|
||||
@ -1502,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**
|
||||
|
||||
@ -1628,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
|
||||
@ -1665,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
|
||||
|
||||
@ -1698,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
|
||||
@ -1764,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
|
||||
@ -1813,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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
clay.h
6
clay.h
@ -93,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 -----------------------------------------------------
|
||||
@ -2086,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;
|
||||
|
@ -34,8 +34,12 @@ target_link_libraries(SDL2_video_demo PUBLIC
|
||||
SDL2_ttf::SDL2_ttf-static
|
||||
)
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -Wno-error=missing-braces -DCLAY_DEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
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
|
||||
|
@ -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.") },
|
||||
|
@ -2,10 +2,32 @@ cmake_minimum_required(VERSION 3.27)
|
||||
project(clay_official_website C)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
|
||||
# Specify WebAssembly as target
|
||||
set(CMAKE_C_FLAGS
|
||||
"${CMAKE_C_FLAGS} -Wall -Werror -Os -DCLAY_WASM -mbulk-memory --target=wasm32 -nostdlib"
|
||||
)
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -Wl,--strip-all,--export-dynamic,--no-entry,--export=__heap_base,--export=ACTIVE_RENDERER_INDEX,--initial-memory=6553600"
|
||||
)
|
||||
|
||||
add_executable(clay_official_website main.c)
|
||||
|
||||
target_compile_options(clay_official_website PUBLIC -Wall -Werror -Wno-unknown-pragmas -Wno-error=missing-braces)
|
||||
target_include_directories(clay_official_website PUBLIC .)
|
||||
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
# Adjust WebAssembly output binary name
|
||||
set_target_properties(clay_official_website PROPERTIES
|
||||
OUTPUT_NAME index.wasm
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/clay
|
||||
)
|
||||
|
||||
# Custom commands to copy additional resources
|
||||
add_custom_command(TARGET clay_official_website POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/index.html ${CMAKE_BINARY_DIR}/clay/index.html
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/fonts ${CMAKE_BINARY_DIR}/clay/fonts
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/images ${CMAKE_BINARY_DIR}/clay/images
|
||||
)
|
||||
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
|
Binary file not shown.
@ -2,11 +2,15 @@ cmake_minimum_required(VERSION 3.27)
|
||||
project(clay_examples_cpp_project_example CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g")
|
||||
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 .)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Werror -Wall")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
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)
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -Wno-error=missing-braces -DCLAY_DEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
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
|
||||
|
@ -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)
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -Wno-error=missing-braces -DCLAY_DEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
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) {
|
||||
|
@ -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