mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-04 13:28:07 +00:00
Updated rectangle border rendering
This commit is contained in:
parent
a92ec772e1
commit
6567f85eb3
@ -151,11 +151,7 @@ int APIENTRY WinMain(
|
|||||||
uint64_t clayRequiredMemory = Clay_MinMemorySize();
|
uint64_t clayRequiredMemory = Clay_MinMemorySize();
|
||||||
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory));
|
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory));
|
||||||
Clay_Initialize(clayMemory, (Clay_Dimensions){.width = 800, .height = 600}, (Clay_ErrorHandler){HandleClayErrors}); // This final argument is new since the video was published
|
Clay_Initialize(clayMemory, (Clay_Dimensions){.width = 800, .height = 600}, (Clay_ErrorHandler){HandleClayErrors}); // This final argument is new since the video was published
|
||||||
|
Clay_SetMeasureTextFunction(Clay_Win32_MeasureText, NULL);
|
||||||
// Font fonts[1];
|
|
||||||
// fonts[FONT_ID_BODY_16] = LoadFontEx("resources/Roboto-Regular.ttf", 48, 0, 400);
|
|
||||||
|
|
||||||
Clay_SetMeasureTextFunction(Clay_Win32_MeasureText, NULL); // was gettings fonts[] passed in
|
|
||||||
|
|
||||||
ZeroMemory(&wc, sizeof wc);
|
ZeroMemory(&wc, sizeof wc);
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "../../clay.h"
|
#include "../../clay.h"
|
||||||
|
|
||||||
|
|
||||||
HDC renderer_hdcMem = {0};
|
HDC renderer_hdcMem = {0};
|
||||||
HBITMAP renderer_hbmMem = {0};
|
HBITMAP renderer_hbmMem = {0};
|
||||||
HANDLE renderer_hOld = {0};
|
HANDLE renderer_hOld = {0};
|
||||||
@ -115,16 +114,73 @@ void Clay_Win32_Render(HWND hwnd, Clay_RenderCommandArray renderCommands)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // The renderer should draw a colored border inset into the bounding box.
|
// The renderer should draw a colored border inset into the bounding box.
|
||||||
// case CLAY_RENDER_COMMAND_TYPE_BORDER:
|
case CLAY_RENDER_COMMAND_TYPE_BORDER:
|
||||||
// {
|
{
|
||||||
// // TODO:
|
Clay_BorderRenderData brd = renderCommand->renderData.border;
|
||||||
// break;
|
RECT r = rc;
|
||||||
// }
|
|
||||||
|
r.left = boundingBox.x;
|
||||||
|
r.top = boundingBox.y;
|
||||||
|
r.right = boundingBox.x + boundingBox.width;
|
||||||
|
r.bottom = boundingBox.y + boundingBox.height;
|
||||||
|
|
||||||
|
HPEN topPen = CreatePen(PS_SOLID, brd.width.top, RGB(brd.color.r, brd.color.g, brd.color.b));
|
||||||
|
HPEN leftPen = CreatePen(PS_SOLID, brd.width.left, RGB(brd.color.r, brd.color.g, brd.color.b));
|
||||||
|
HPEN bottomPen = CreatePen(PS_SOLID, brd.width.bottom, RGB(brd.color.r, brd.color.g, brd.color.b));
|
||||||
|
HPEN rightPen = CreatePen(PS_SOLID, brd.width.right, RGB(brd.color.r, brd.color.g, brd.color.b));
|
||||||
|
|
||||||
|
HPEN oldPen = SelectObject(renderer_hdcMem, topPen);
|
||||||
|
|
||||||
|
if (brd.cornerRadius.topLeft == 0)
|
||||||
|
{
|
||||||
|
MoveToEx(renderer_hdcMem, r.left, r.top, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.right, r.top);
|
||||||
|
|
||||||
|
SelectObject(renderer_hdcMem, leftPen);
|
||||||
|
MoveToEx(renderer_hdcMem, r.left, r.top, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.left, r.bottom);
|
||||||
|
|
||||||
|
SelectObject(renderer_hdcMem, bottomPen);
|
||||||
|
MoveToEx(renderer_hdcMem, r.left, r.bottom, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.right, r.bottom);
|
||||||
|
|
||||||
|
SelectObject(renderer_hdcMem, rightPen);
|
||||||
|
MoveToEx(renderer_hdcMem, r.right, r.top, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.right, r.bottom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// todo: i should be rounded
|
||||||
|
MoveToEx(renderer_hdcMem, r.left, r.top, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.right, r.top);
|
||||||
|
|
||||||
|
SelectObject(renderer_hdcMem, leftPen);
|
||||||
|
MoveToEx(renderer_hdcMem, r.left, r.top, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.left, r.bottom);
|
||||||
|
|
||||||
|
SelectObject(renderer_hdcMem, bottomPen);
|
||||||
|
MoveToEx(renderer_hdcMem, r.left, r.bottom, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.right, r.bottom);
|
||||||
|
|
||||||
|
SelectObject(renderer_hdcMem, rightPen);
|
||||||
|
MoveToEx(renderer_hdcMem, r.right, r.top, NULL);
|
||||||
|
LineTo(renderer_hdcMem, r.right, r.bottom);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectObject(renderer_hdcMem, oldPen);
|
||||||
|
DeleteObject(topPen);
|
||||||
|
DeleteObject(leftPen);
|
||||||
|
DeleteObject(bottomPen);
|
||||||
|
DeleteObject(rightPen);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// case CLAY_RENDER_COMMAND_TYPE_IMAGE:
|
// case CLAY_RENDER_COMMAND_TYPE_IMAGE:
|
||||||
// {
|
// {
|
||||||
// // TODO:
|
// // TODO: i couldnt get the win 32 api to load a bitmap.... So im punting on this one :(
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -144,7 +200,6 @@ void Clay_Win32_Render(HWND hwnd, Clay_RenderCommandArray renderCommands)
|
|||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Hacks due to the windows api not making sence to use.... may measure too large, but never too small
|
Hacks due to the windows api not making sence to use.... may measure too large, but never too small
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user