diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-11-23 21:52:24 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-11-23 21:52:24 +0100 |
| commit | 6f7374c2fa58c8692b51018864b802e6b876d305 (patch) | |
| tree | a7e8ead757e9f4de1920395336dcac1c8a989576 /src/ui/panel.c | |
A new start
Diffstat (limited to 'src/ui/panel.c')
| -rw-r--r-- | src/ui/panel.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 |
