Compare commits

...

3 Commits

Author SHA1 Message Date
Avinal Kumar
881ce68ff3
Merge 5c01540234 into 208c7cb3a0 2025-01-12 11:03:52 +00:00
Nic Barker
208c7cb3a0 Fix incorrect border between children after 2nd element
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 12s
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 11s
2025-01-12 19:16:09 +13:00
Avinal Kumar
5c01540234
[Examples/Website] Fix CMakeLists.txt to compile to wasm
- CMake was not compiling to WebAssembly
- This changes adds missing CMake directives for compiling to Wasm

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
2025-01-04 19:02:02 +05:30
2 changed files with 27 additions and 4 deletions

7
clay.h
View File

@ -2804,7 +2804,8 @@ void Clay__CalculateFinalLayout() {
Clay__AddRenderCommand(renderCommand);
if (borderConfig->betweenChildren.width > 0 && borderConfig->betweenChildren.color.a > 0) {
Clay_RectangleElementConfig *rectangleConfig = Clay__StoreRectangleElementConfig(CLAY__INIT(Clay_RectangleElementConfig) {.color = borderConfig->betweenChildren.color});
Clay_Vector2 borderOffset = { (float)layoutConfig->padding.x, (float)layoutConfig->padding.y };
float halfGap = layoutConfig->childGap / 2;
Clay_Vector2 borderOffset = { (float)layoutConfig->padding.x - halfGap, (float)layoutConfig->padding.y - halfGap };
if (layoutConfig->layoutDirection == CLAY_LEFT_TO_RIGHT) {
for (int32_t i = 0; i < currentElement->childrenOrTextContent.children.length; ++i) {
Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, currentElement->childrenOrTextContent.children.elements[i]);
@ -2816,7 +2817,7 @@ void Clay__CalculateFinalLayout() {
.commandType = CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
});
}
borderOffset.x += (childElement->dimensions.width + (float)layoutConfig->childGap / 2);
borderOffset.x += (childElement->dimensions.width + (float)layoutConfig->childGap);
}
} else {
for (int32_t i = 0; i < currentElement->childrenOrTextContent.children.length; ++i) {
@ -2829,7 +2830,7 @@ void Clay__CalculateFinalLayout() {
.commandType = CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
});
}
borderOffset.y += (childElement->dimensions.height + (float)layoutConfig->childGap / 2);
borderOffset.y += (childElement->dimensions.height + (float)layoutConfig->childGap);
}
}
}

View File

@ -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")