Nuklear
This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI.
 
Loading...
Searching...
No Matches
nuklear_9slice.c
1#include "nuklear.h"
2#include "nuklear_internal.h"
3
4/* ===============================================================
5 *
6 * 9-SLICE
7 *
8 * ===============================================================*/
9NK_API struct nk_nine_slice
10nk_sub9slice_ptr(void *ptr, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
11{
12 struct nk_nine_slice s;
13 struct nk_image *i = &s.img;
14 nk_zero(&s, sizeof(s));
15 i->handle.ptr = ptr;
16 i->w = w; i->h = h;
17 i->region[0] = (nk_ushort)rgn.x;
18 i->region[1] = (nk_ushort)rgn.y;
19 i->region[2] = (nk_ushort)rgn.w;
20 i->region[3] = (nk_ushort)rgn.h;
21 s.l = l; s.t = t; s.r = r; s.b = b;
22 return s;
23}
24NK_API struct nk_nine_slice
25nk_sub9slice_id(int id, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
26{
27 struct nk_nine_slice s;
28 struct nk_image *i = &s.img;
29 nk_zero(&s, sizeof(s));
30 i->handle.id = id;
31 i->w = w; i->h = h;
32 i->region[0] = (nk_ushort)rgn.x;
33 i->region[1] = (nk_ushort)rgn.y;
34 i->region[2] = (nk_ushort)rgn.w;
35 i->region[3] = (nk_ushort)rgn.h;
36 s.l = l; s.t = t; s.r = r; s.b = b;
37 return s;
38}
39NK_API struct nk_nine_slice
40nk_sub9slice_handle(nk_handle handle, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
41{
42 struct nk_nine_slice s;
43 struct nk_image *i = &s.img;
44 nk_zero(&s, sizeof(s));
45 i->handle = handle;
46 i->w = w; i->h = h;
47 i->region[0] = (nk_ushort)rgn.x;
48 i->region[1] = (nk_ushort)rgn.y;
49 i->region[2] = (nk_ushort)rgn.w;
50 i->region[3] = (nk_ushort)rgn.h;
51 s.l = l; s.t = t; s.r = r; s.b = b;
52 return s;
53}
54NK_API struct nk_nine_slice
55nk_nine_slice_handle(nk_handle handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
56{
57 struct nk_nine_slice s;
58 struct nk_image *i = &s.img;
59 nk_zero(&s, sizeof(s));
60 i->handle = handle;
61 i->w = 0; i->h = 0;
62 i->region[0] = 0;
63 i->region[1] = 0;
64 i->region[2] = 0;
65 i->region[3] = 0;
66 s.l = l; s.t = t; s.r = r; s.b = b;
67 return s;
68}
69NK_API struct nk_nine_slice
70nk_nine_slice_ptr(void *ptr, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
71{
72 struct nk_nine_slice s;
73 struct nk_image *i = &s.img;
74 nk_zero(&s, sizeof(s));
75 NK_ASSERT(ptr);
76 i->handle.ptr = ptr;
77 i->w = 0; i->h = 0;
78 i->region[0] = 0;
79 i->region[1] = 0;
80 i->region[2] = 0;
81 i->region[3] = 0;
82 s.l = l; s.t = t; s.r = r; s.b = b;
83 return s;
84}
85NK_API struct nk_nine_slice
86nk_nine_slice_id(int id, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
87{
88 struct nk_nine_slice s;
89 struct nk_image *i = &s.img;
90 nk_zero(&s, sizeof(s));
91 i->handle.id = id;
92 i->w = 0; i->h = 0;
93 i->region[0] = 0;
94 i->region[1] = 0;
95 i->region[2] = 0;
96 i->region[3] = 0;
97 s.l = l; s.t = t; s.r = r; s.b = b;
98 return s;
99}
100NK_API int
101nk_nine_slice_is_sub9slice(const struct nk_nine_slice* slice)
102{
103 NK_ASSERT(slice);
104 return !(slice->img.w == 0 && slice->img.h == 0);
105}
106
main API and documentation file