-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for 9-slice/9-patch (#304)
- Loading branch information
Showing
22 changed files
with
983 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ docs/src | |
*.tmp | ||
*.swo | ||
*.swp | ||
/private/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#include "nuklear.h" | ||
#include "nuklear_internal.h" | ||
|
||
/* =============================================================== | ||
* | ||
* 9-SLICE | ||
* | ||
* ===============================================================*/ | ||
NK_API struct nk_nine_slice | ||
nk_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) | ||
{ | ||
struct nk_nine_slice s; | ||
nk_zero(&s, sizeof(s)); | ||
struct nk_image *i = &s.img; | ||
i->handle.ptr = ptr; | ||
i->w = w; i->h = h; | ||
i->region[0] = (nk_ushort)rgn.x; | ||
i->region[1] = (nk_ushort)rgn.y; | ||
i->region[2] = (nk_ushort)rgn.w; | ||
i->region[3] = (nk_ushort)rgn.h; | ||
s.l = l; s.t = t; s.r = r; s.b = b; | ||
return s; | ||
} | ||
NK_API struct nk_nine_slice | ||
nk_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) | ||
{ | ||
struct nk_nine_slice s; | ||
nk_zero(&s, sizeof(s)); | ||
struct nk_image *i = &s.img; | ||
i->handle.id = id; | ||
i->w = w; i->h = h; | ||
i->region[0] = (nk_ushort)rgn.x; | ||
i->region[1] = (nk_ushort)rgn.y; | ||
i->region[2] = (nk_ushort)rgn.w; | ||
i->region[3] = (nk_ushort)rgn.h; | ||
s.l = l; s.t = t; s.r = r; s.b = b; | ||
return s; | ||
} | ||
NK_API struct nk_nine_slice | ||
nk_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) | ||
{ | ||
struct nk_nine_slice s; | ||
nk_zero(&s, sizeof(s)); | ||
struct nk_image *i = &s.img; | ||
i->handle = handle; | ||
i->w = w; i->h = h; | ||
i->region[0] = (nk_ushort)rgn.x; | ||
i->region[1] = (nk_ushort)rgn.y; | ||
i->region[2] = (nk_ushort)rgn.w; | ||
i->region[3] = (nk_ushort)rgn.h; | ||
s.l = l; s.t = t; s.r = r; s.b = b; | ||
return s; | ||
} | ||
NK_API struct nk_nine_slice | ||
nk_nine_slice_handle(nk_handle handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b) | ||
{ | ||
struct nk_nine_slice s; | ||
nk_zero(&s, sizeof(s)); | ||
struct nk_image *i = &s.img; | ||
i->handle = handle; | ||
i->w = 0; i->h = 0; | ||
i->region[0] = 0; | ||
i->region[1] = 0; | ||
i->region[2] = 0; | ||
i->region[3] = 0; | ||
s.l = l; s.t = t; s.r = r; s.b = b; | ||
return s; | ||
} | ||
NK_API struct nk_nine_slice | ||
nk_nine_slice_ptr(void *ptr, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b) | ||
{ | ||
struct nk_nine_slice s; | ||
nk_zero(&s, sizeof(s)); | ||
struct nk_image *i = &s.img; | ||
NK_ASSERT(ptr); | ||
i->handle.ptr = ptr; | ||
i->w = 0; i->h = 0; | ||
i->region[0] = 0; | ||
i->region[1] = 0; | ||
i->region[2] = 0; | ||
i->region[3] = 0; | ||
s.l = l; s.t = t; s.r = r; s.b = b; | ||
return s; | ||
} | ||
NK_API struct nk_nine_slice | ||
nk_nine_slice_id(int id, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b) | ||
{ | ||
struct nk_nine_slice s; | ||
nk_zero(&s, sizeof(s)); | ||
struct nk_image *i = &s.img; | ||
i->handle.id = id; | ||
i->w = 0; i->h = 0; | ||
i->region[0] = 0; | ||
i->region[1] = 0; | ||
i->region[2] = 0; | ||
i->region[3] = 0; | ||
s.l = l; s.t = t; s.r = r; s.b = b; | ||
return s; | ||
} | ||
NK_API int | ||
nk_nine_slice_is_sub9slice(const struct nk_nine_slice* slice) | ||
{ | ||
NK_ASSERT(slice); | ||
return !(slice->img.w == 0 && slice->img.h == 0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.