From 6f7374c2fa58c8692b51018864b802e6b876d305 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 23 Nov 2024 21:52:24 +0100 Subject: A new start --- src/ui/panel.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/ui/panel.c (limited to 'src/ui/panel.c') diff --git a/src/ui/panel.c b/src/ui/panel.c new file mode 100644 index 0000000..af24e66 --- /dev/null +++ b/src/ui/panel.c @@ -0,0 +1,29 @@ + +void panel_render(float scale, s32 x, s32 y, s32 w, s32 h) +{ + s32 cornor_size = img_panel_topleft->width*(scale/2); + log_assert(w > cornor_size*2, "Panel width too small"); + log_assert(h > cornor_size*2, "Panel height too small"); + s32 top_width = w - (cornor_size*2); + s32 size_height = h - (cornor_size*2); + + // top + renderer->render_image(img_panel_topleft, x, y, cornor_size, cornor_size); + renderer->render_image(img_panel_top, x + cornor_size, y, top_width, cornor_size); + renderer->render_image(img_panel_topright, x + cornor_size + top_width, y, cornor_size, cornor_size); + + // left + renderer->render_image(img_panel_left, x, y + cornor_size-1, cornor_size, size_height+2); + + // right + renderer->render_image(img_panel_right, x + cornor_size + top_width, y + cornor_size-1, cornor_size, size_height+2); + + // bottom + renderer->render_image(img_panel_bottomleft, x, y + cornor_size + size_height, cornor_size, cornor_size); + renderer->render_image(img_panel_bottom, x + cornor_size, y + cornor_size + size_height, top_width, cornor_size); + renderer->render_image(img_panel_bottomright, x + cornor_size + top_width, y + cornor_size + size_height, cornor_size, cornor_size); + + // fill + s32 pad = cornor_size-1; + renderer->render_rectangle(x+pad, y+pad, w-(pad*2), h-(pad*2), COLOR_PANEL_BACKGROUND); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2