feat: initial
This commit is contained in:
commit
80e1b84cb4
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
build/
|
||||||
|
bin/
|
||||||
|
compile_commands/
|
||||||
|
compile_commands.json
|
||||||
|
.cache
|
48
Makefile
Normal file
48
Makefile
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# Alternative GNU Make workspace makefile autogenerated by Premake
|
||||||
|
|
||||||
|
ifndef config
|
||||||
|
config=debug
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef verbose
|
||||||
|
SILENT = @
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(config),debug)
|
||||||
|
datacomp_config = debug
|
||||||
|
|
||||||
|
else ifeq ($(config),release)
|
||||||
|
datacomp_config = release
|
||||||
|
|
||||||
|
else
|
||||||
|
$(error "invalid configuration $(config)")
|
||||||
|
endif
|
||||||
|
|
||||||
|
PROJECTS := datacomp
|
||||||
|
|
||||||
|
.PHONY: all clean help $(PROJECTS)
|
||||||
|
|
||||||
|
all: $(PROJECTS)
|
||||||
|
|
||||||
|
datacomp:
|
||||||
|
ifneq (,$(datacomp_config))
|
||||||
|
@echo "==== Building datacomp ($(datacomp_config)) ===="
|
||||||
|
@${MAKE} --no-print-directory -C build -f Makefile config=$(datacomp_config)
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@${MAKE} --no-print-directory -C build -f Makefile clean
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "Usage: make [config=name] [target]"
|
||||||
|
@echo ""
|
||||||
|
@echo "CONFIGURATIONS:"
|
||||||
|
@echo " debug"
|
||||||
|
@echo " release"
|
||||||
|
@echo ""
|
||||||
|
@echo "TARGETS:"
|
||||||
|
@echo " all (default)"
|
||||||
|
@echo " clean"
|
||||||
|
@echo " datacomp"
|
||||||
|
@echo ""
|
||||||
|
@echo "For more information, see https://github.com/premake/premake-core/wiki"
|
BIN
documentation/ux.pdf
Normal file
BIN
documentation/ux.pdf
Normal file
Binary file not shown.
21
premake5.lua
Normal file
21
premake5.lua
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
workspace "datacomp"
|
||||||
|
configurations { "debug", "release" }
|
||||||
|
location "."
|
||||||
|
|
||||||
|
project "datacomp"
|
||||||
|
kind "WindowedApp"
|
||||||
|
language "C"
|
||||||
|
location "build/"
|
||||||
|
files { "src/**.c" }
|
||||||
|
includedirs { "src/", "vendor/" }
|
||||||
|
links { "raylib", "m" }
|
||||||
|
targetdir "bin/"
|
||||||
|
postbuildcommands "{COPYDIR} ../resources %{cfg.targetdir}"
|
||||||
|
filter "configurations:debug"
|
||||||
|
defines { "DEBUG" }
|
||||||
|
optimize "Off"
|
||||||
|
symbols "On"
|
||||||
|
filter "configurations:release"
|
||||||
|
defines { "NDEBUG" }
|
||||||
|
optimize "On"
|
||||||
|
symbols "Off"
|
BIN
resources/Inter-Regular.ttf
Normal file
BIN
resources/Inter-Regular.ttf
Normal file
Binary file not shown.
BIN
resources/InterVariable.ttf
Normal file
BIN
resources/InterVariable.ttf
Normal file
Binary file not shown.
59
src/library.c
Normal file
59
src/library.c
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#include "library.h"
|
||||||
|
#include "clay.h"
|
||||||
|
|
||||||
|
bool static sidebar_open = true;
|
||||||
|
|
||||||
|
Clay_Color const SIDEBAR_COLOR = {120.f, 120.f, 120.f, 255.f};
|
||||||
|
|
||||||
|
Clay_LayoutConfig const SIDEBAR_LAYOUT = {
|
||||||
|
.sizing={
|
||||||
|
.height=CLAY_SIZING_GROW(),
|
||||||
|
.width=CLAY_SIZING_FIXED(300)
|
||||||
|
},
|
||||||
|
.layoutDirection=CLAY_TOP_TO_BOTTOM
|
||||||
|
};
|
||||||
|
|
||||||
|
Clay_RectangleElementConfig const SIDEBAR_RECTANGLE = {
|
||||||
|
.color=SIDEBAR_COLOR,
|
||||||
|
};
|
||||||
|
|
||||||
|
static
|
||||||
|
void render_composit_library_sidebar() {
|
||||||
|
CLAY(CLAY_ID("Sidebar"),
|
||||||
|
CLAY_LAYOUT(SIDEBAR_LAYOUT),
|
||||||
|
CLAY_RECTANGLE(SIDEBAR_RECTANGLE)
|
||||||
|
) {
|
||||||
|
CLAY(CLAY_ID("SidebarTab"),
|
||||||
|
CLAY_FLOATING({
|
||||||
|
.attachment={
|
||||||
|
.element=CLAY_ATTACH_POINT_LEFT_TOP,
|
||||||
|
.parent=CLAY_ATTACH_POINT_RIGHT_TOP
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
CLAY_LAYOUT({
|
||||||
|
.sizing={.width=CLAY_SIZING_FIXED(10), .height=CLAY_SIZING_FIXED(40)},
|
||||||
|
}),
|
||||||
|
CLAY_RECTANGLE({
|
||||||
|
.color=SIDEBAR_COLOR,
|
||||||
|
.cornerRadius={
|
||||||
|
.topRight=16,
|
||||||
|
.bottomRight=16,
|
||||||
|
.topLeft=16,
|
||||||
|
.bottomLeft=16
|
||||||
|
}
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void render_composit_library_content() {
|
||||||
|
CLAY(CLAY_ID("Content")) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_composit_library() {
|
||||||
|
render_composit_library_sidebar();
|
||||||
|
render_composit_library_content();
|
||||||
|
}
|
6
src/library.h
Normal file
6
src/library.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef LIBRARY_H
|
||||||
|
#define LIBRARY_H
|
||||||
|
|
||||||
|
extern void render_composit_library();
|
||||||
|
|
||||||
|
#endif // !LIBRARY_H
|
78
src/main.c
Normal file
78
src/main.c
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#include "styles.h"
|
||||||
|
#include "clay_renderer_raylib.c"
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "library.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define CLAY_IMPLEMENTATION
|
||||||
|
#include "clay.h"
|
||||||
|
|
||||||
|
Clay_LayoutConfig const APPLICATION_LAYOUT = {
|
||||||
|
.sizing={
|
||||||
|
.width=CLAY_SIZING_GROW(),
|
||||||
|
.height=CLAY_SIZING_GROW()
|
||||||
|
},
|
||||||
|
.childGap=16,
|
||||||
|
.layoutDirection=CLAY_LEFT_TO_RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
|
Color const BACKGROUND_COLOR = {220.f, 226.f, 233.f, 255.f};
|
||||||
|
|
||||||
|
bool static clay_debug_enabled = false;
|
||||||
|
|
||||||
|
void handle_clay_errors(Clay_ErrorData error) {
|
||||||
|
printf("Clay Error: %s\n", error.errorText.chars);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_clay(Clay_Arena *o_arena) {
|
||||||
|
uint64_t memory_required = Clay_MinMemorySize();
|
||||||
|
*o_arena = Clay_CreateArenaWithCapacityAndMemory(memory_required, malloc(memory_required));
|
||||||
|
Clay_SetMeasureTextFunction(Raylib_MeasureText);
|
||||||
|
Clay_Initialize(*o_arena,
|
||||||
|
(Clay_Dimensions){
|
||||||
|
(float)GetScreenWidth(),
|
||||||
|
(float)GetScreenHeight()},
|
||||||
|
(Clay_ErrorHandler){handle_clay_errors});
|
||||||
|
Clay_Raylib_Initialize(1920, 1080, "DataComp", FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT);
|
||||||
|
Raylib_fonts[0] = (Raylib_Font){
|
||||||
|
.font = LoadFontEx("resources/Inter-Regular.ttf", 48, NULL, 400),
|
||||||
|
.fontId = 0
|
||||||
|
};
|
||||||
|
SetTextureFilter(Raylib_fonts[0].font.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
Clay_RenderCommandArray create_layout() {
|
||||||
|
Clay_BeginLayout();
|
||||||
|
CLAY(CLAY_ID("ApplicationContainer"),
|
||||||
|
CLAY_LAYOUT(APPLICATION_LAYOUT)) {
|
||||||
|
render_composit_library();
|
||||||
|
}
|
||||||
|
return Clay_EndLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_ui() {
|
||||||
|
if(IsKeyPressed(KEY_D) && IsKeyDown(KEY_LEFT_CONTROL))
|
||||||
|
Clay_SetDebugModeEnabled(clay_debug_enabled = !clay_debug_enabled);
|
||||||
|
Vector2 const scroll_delta = GetMouseWheelMoveV();
|
||||||
|
Vector2 const mouse_position = GetMousePosition();
|
||||||
|
Clay_SetPointerState((Clay_Vector2){mouse_position.x, mouse_position.y}, IsMouseButtonDown(0));
|
||||||
|
Clay_SetLayoutDimensions((Clay_Dimensions){.width=(float)GetScreenWidth(), .height=(float)GetScreenHeight()});
|
||||||
|
Clay_UpdateScrollContainers(true, (Clay_Vector2){scroll_delta.x, scroll_delta.y}, GetFrameTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
Clay_Arena clay_mem;
|
||||||
|
init_clay(&clay_mem);
|
||||||
|
while(!WindowShouldClose()) {
|
||||||
|
update_ui();
|
||||||
|
Clay_RenderCommandArray commands = create_layout();
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(BACKGROUND_COLOR);
|
||||||
|
Clay_Raylib_Render(commands);
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
3
src/styles.c
Normal file
3
src/styles.c
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include "styles.h"
|
||||||
|
|
||||||
|
Clay_Color const TRANSPARENT = {0.f, 0.f, 0.f, 0.f};
|
8
src/styles.h
Normal file
8
src/styles.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef DATACOMP_STYLES_H
|
||||||
|
#define DATACOMP_STYLES_H
|
||||||
|
|
||||||
|
#include "clay.h"
|
||||||
|
|
||||||
|
extern Clay_Color const TRANSPARENT;
|
||||||
|
|
||||||
|
#endif // !DATACOMP_STYLES_H
|
3900
vendor/clay.h
vendored
Normal file
3900
vendor/clay.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
233
vendor/clay_renderer_raylib.c
vendored
Normal file
233
vendor/clay_renderer_raylib.c
vendored
Normal file
|
@ -0,0 +1,233 @@
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "raymath.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
#define CLAY_RECTANGLE_TO_RAYLIB_RECTANGLE(rectangle) (Rectangle) { .x = rectangle.x, .y = rectangle.y, .width = rectangle.width, .height = rectangle.height }
|
||||||
|
#define CLAY_COLOR_TO_RAYLIB_COLOR(color) (Color) { .r = (unsigned char)roundf(color.r), .g = (unsigned char)roundf(color.g), .b = (unsigned char)roundf(color.b), .a = (unsigned char)roundf(color.a) }
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t fontId;
|
||||||
|
Font font;
|
||||||
|
} Raylib_Font;
|
||||||
|
|
||||||
|
Raylib_Font Raylib_fonts[10];
|
||||||
|
Camera Raylib_camera;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CUSTOM_LAYOUT_ELEMENT_TYPE_3D_MODEL
|
||||||
|
} CustomLayoutElementType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Model model;
|
||||||
|
float scale;
|
||||||
|
Vector3 position;
|
||||||
|
Matrix rotation;
|
||||||
|
} CustomLayoutElement_3DModel;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CustomLayoutElementType type;
|
||||||
|
union {
|
||||||
|
CustomLayoutElement_3DModel model;
|
||||||
|
};
|
||||||
|
} CustomLayoutElement;
|
||||||
|
|
||||||
|
// Get a ray trace from the screen position (i.e mouse) within a specific section of the screen
|
||||||
|
Ray GetScreenToWorldPointWithZDistance(Vector2 position, Camera camera, int screenWidth, int screenHeight, float zDistance)
|
||||||
|
{
|
||||||
|
Ray ray = { 0 };
|
||||||
|
|
||||||
|
// Calculate normalized device coordinates
|
||||||
|
// NOTE: y value is negative
|
||||||
|
float x = (2.0f*position.x)/(float)screenWidth - 1.0f;
|
||||||
|
float y = 1.0f - (2.0f*position.y)/(float)screenHeight;
|
||||||
|
float z = 1.0f;
|
||||||
|
|
||||||
|
// Store values in a vector
|
||||||
|
Vector3 deviceCoords = { x, y, z };
|
||||||
|
|
||||||
|
// Calculate view matrix from camera look at
|
||||||
|
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||||
|
|
||||||
|
Matrix matProj = MatrixIdentity();
|
||||||
|
|
||||||
|
if (camera.projection == CAMERA_PERSPECTIVE)
|
||||||
|
{
|
||||||
|
// Calculate projection matrix from perspective
|
||||||
|
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)screenWidth/(double)screenHeight), 0.01f, zDistance);
|
||||||
|
}
|
||||||
|
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
|
||||||
|
{
|
||||||
|
double aspect = (double)screenWidth/(double)screenHeight;
|
||||||
|
double top = camera.fovy/2.0;
|
||||||
|
double right = top*aspect;
|
||||||
|
|
||||||
|
// Calculate projection matrix from orthographic
|
||||||
|
matProj = MatrixOrtho(-right, right, -top, top, 0.01, 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unproject far/near points
|
||||||
|
Vector3 nearPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 0.0f }, matProj, matView);
|
||||||
|
Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
|
||||||
|
|
||||||
|
// Calculate normalized direction vector
|
||||||
|
Vector3 direction = Vector3Normalize(Vector3Subtract(farPoint, nearPoint));
|
||||||
|
|
||||||
|
ray.position = farPoint;
|
||||||
|
|
||||||
|
// Apply calculated vectors to ray
|
||||||
|
ray.direction = direction;
|
||||||
|
|
||||||
|
return ray;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t measureCalls = 0;
|
||||||
|
|
||||||
|
static inline Clay_Dimensions Raylib_MeasureText(Clay_String *text, Clay_TextElementConfig *config) {
|
||||||
|
measureCalls++;
|
||||||
|
// Measure string size for Font
|
||||||
|
Clay_Dimensions textSize = { 0 };
|
||||||
|
|
||||||
|
float maxTextWidth = 0.0f;
|
||||||
|
float lineTextWidth = 0;
|
||||||
|
|
||||||
|
float textHeight = config->fontSize;
|
||||||
|
Font fontToUse = Raylib_fonts[config->fontId].font;
|
||||||
|
float scaleFactor = config->fontSize/(float)fontToUse.baseSize;
|
||||||
|
|
||||||
|
for (int i = 0; i < text->length; ++i)
|
||||||
|
{
|
||||||
|
if (text->chars[i] == '\n') {
|
||||||
|
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||||
|
lineTextWidth = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int index = text->chars[i] - 32;
|
||||||
|
if (fontToUse.glyphs[index].advanceX != 0) lineTextWidth += fontToUse.glyphs[index].advanceX;
|
||||||
|
else lineTextWidth += (fontToUse.recs[index].width + fontToUse.glyphs[index].offsetX);
|
||||||
|
}
|
||||||
|
|
||||||
|
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||||
|
|
||||||
|
textSize.width = maxTextWidth * scaleFactor;
|
||||||
|
textSize.height = textHeight;
|
||||||
|
|
||||||
|
return textSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clay_Raylib_Initialize(int width, int height, const char *title, unsigned int flags) {
|
||||||
|
SetConfigFlags(flags);
|
||||||
|
InitWindow(width, height, title);
|
||||||
|
// EnableEventWaiting();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands)
|
||||||
|
{
|
||||||
|
measureCalls = 0;
|
||||||
|
for (int j = 0; j < renderCommands.length; j++)
|
||||||
|
{
|
||||||
|
Clay_RenderCommand *renderCommand = Clay_RenderCommandArray_Get(&renderCommands, j);
|
||||||
|
Clay_BoundingBox boundingBox = renderCommand->boundingBox;
|
||||||
|
switch (renderCommand->commandType)
|
||||||
|
{
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_TEXT: {
|
||||||
|
// Raylib uses standard C strings so isn't compatible with cheap slices, we need to clone the string to append null terminator
|
||||||
|
Clay_String text = renderCommand->text;
|
||||||
|
char *cloned = (char *)malloc(text.length + 1);
|
||||||
|
memcpy(cloned, text.chars, text.length);
|
||||||
|
cloned[text.length] = '\0';
|
||||||
|
Font fontToUse = Raylib_fonts[renderCommand->config.textElementConfig->fontId].font;
|
||||||
|
DrawTextEx(fontToUse, cloned, (Vector2){boundingBox.x, boundingBox.y}, (float)renderCommand->config.textElementConfig->fontSize, (float)renderCommand->config.textElementConfig->letterSpacing, CLAY_COLOR_TO_RAYLIB_COLOR(renderCommand->config.textElementConfig->textColor));
|
||||||
|
free(cloned);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_IMAGE: {
|
||||||
|
Texture2D imageTexture = *(Texture2D *)renderCommand->config.imageElementConfig->imageData;
|
||||||
|
DrawTextureEx(
|
||||||
|
imageTexture,
|
||||||
|
(Vector2){boundingBox.x, boundingBox.y},
|
||||||
|
0,
|
||||||
|
boundingBox.width / (float)imageTexture.width,
|
||||||
|
WHITE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_START: {
|
||||||
|
BeginScissorMode((int)roundf(boundingBox.x), (int)roundf(boundingBox.y), (int)roundf(boundingBox.width), (int)roundf(boundingBox.height));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_END: {
|
||||||
|
EndScissorMode();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
|
||||||
|
Clay_RectangleElementConfig *config = renderCommand->config.rectangleElementConfig;
|
||||||
|
if (config->cornerRadius.topLeft > 0) {
|
||||||
|
float radius = (config->cornerRadius.topLeft * 2) / (float)((boundingBox.width > boundingBox.height) ? boundingBox.height : boundingBox.width);
|
||||||
|
DrawRectangleRounded((Rectangle) { boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height }, radius, 8, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
} else {
|
||||||
|
DrawRectangle(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_BORDER: {
|
||||||
|
Clay_BorderElementConfig *config = renderCommand->config.borderElementConfig;
|
||||||
|
// Left border
|
||||||
|
if (config->left.width > 0) {
|
||||||
|
DrawRectangle((int)roundf(boundingBox.x), (int)roundf(boundingBox.y + config->cornerRadius.topLeft), (int)config->left.width, (int)roundf(boundingBox.height - config->cornerRadius.topLeft - config->cornerRadius.bottomLeft), CLAY_COLOR_TO_RAYLIB_COLOR(config->left.color));
|
||||||
|
}
|
||||||
|
// Right border
|
||||||
|
if (config->right.width > 0) {
|
||||||
|
DrawRectangle((int)roundf(boundingBox.x + boundingBox.width - config->right.width), (int)roundf(boundingBox.y + config->cornerRadius.topRight), (int)config->right.width, (int)roundf(boundingBox.height - config->cornerRadius.topRight - config->cornerRadius.bottomRight), CLAY_COLOR_TO_RAYLIB_COLOR(config->right.color));
|
||||||
|
}
|
||||||
|
// Top border
|
||||||
|
if (config->top.width > 0) {
|
||||||
|
DrawRectangle((int)roundf(boundingBox.x + config->cornerRadius.topLeft), (int)roundf(boundingBox.y), (int)roundf(boundingBox.width - config->cornerRadius.topLeft - config->cornerRadius.topRight), (int)config->top.width, CLAY_COLOR_TO_RAYLIB_COLOR(config->top.color));
|
||||||
|
}
|
||||||
|
// Bottom border
|
||||||
|
if (config->bottom.width > 0) {
|
||||||
|
DrawRectangle((int)roundf(boundingBox.x + config->cornerRadius.bottomLeft), (int)roundf(boundingBox.y + boundingBox.height - config->bottom.width), (int)roundf(boundingBox.width - config->cornerRadius.bottomLeft - config->cornerRadius.bottomRight), (int)config->bottom.width, CLAY_COLOR_TO_RAYLIB_COLOR(config->bottom.color));
|
||||||
|
}
|
||||||
|
if (config->cornerRadius.topLeft > 0) {
|
||||||
|
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.topLeft), roundf(boundingBox.y + config->cornerRadius.topLeft) }, roundf(config->cornerRadius.topLeft - config->top.width), config->cornerRadius.topLeft, 180, 270, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->top.color));
|
||||||
|
}
|
||||||
|
if (config->cornerRadius.topRight > 0) {
|
||||||
|
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.topRight), roundf(boundingBox.y + config->cornerRadius.topRight) }, roundf(config->cornerRadius.topRight - config->top.width), config->cornerRadius.topRight, 270, 360, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->top.color));
|
||||||
|
}
|
||||||
|
if (config->cornerRadius.bottomLeft > 0) {
|
||||||
|
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.bottomLeft), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomLeft) }, roundf(config->cornerRadius.bottomLeft - config->top.width), config->cornerRadius.bottomLeft, 90, 180, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->bottom.color));
|
||||||
|
}
|
||||||
|
if (config->cornerRadius.bottomRight > 0) {
|
||||||
|
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.bottomRight), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomRight) }, roundf(config->cornerRadius.bottomRight - config->bottom.width), config->cornerRadius.bottomRight, 0.1, 90, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->bottom.color));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_CUSTOM: {
|
||||||
|
CustomLayoutElement *customElement = (CustomLayoutElement *)renderCommand->config.customElementConfig->customData;
|
||||||
|
if (!customElement) continue;
|
||||||
|
switch (customElement->type) {
|
||||||
|
case CUSTOM_LAYOUT_ELEMENT_TYPE_3D_MODEL: {
|
||||||
|
Clay_BoundingBox rootBox = renderCommands.internalArray[0].boundingBox;
|
||||||
|
float scaleValue = CLAY__MIN(CLAY__MIN(1, 768 / rootBox.height) * CLAY__MAX(1, rootBox.width / 1024), 1.5f);
|
||||||
|
Ray positionRay = GetScreenToWorldPointWithZDistance((Vector2) { renderCommand->boundingBox.x + renderCommand->boundingBox.width / 2, renderCommand->boundingBox.y + (renderCommand->boundingBox.height / 2) + 20 }, Raylib_camera, (int)roundf(rootBox.width), (int)roundf(rootBox.height), 140);
|
||||||
|
BeginMode3D(Raylib_camera);
|
||||||
|
DrawModel(customElement->model.model, positionRay.position, customElement->model.scale * scaleValue, WHITE); // Draw 3d model with texture
|
||||||
|
EndMode3D();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
printf("Error: unhandled render command.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2941
vendor/raymath.h
vendored
Normal file
2941
vendor/raymath.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue