Skip to content

Commit

Permalink
Fix warnings in C89 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 authored and Hejsil committed Sep 9, 2021
1 parent a859103 commit 73a2062
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
24 changes: 16 additions & 8 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -9220,6 +9220,7 @@ NK_API void
nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
const struct nk_nine_slice *slc, struct nk_color col)
{
struct nk_image img;
const struct nk_image *slcimg = (const struct nk_image*)slc;
nk_ushort rgnX, rgnY, rgnW, rgnH;
rgnX = slcimg->region[0];
Expand All @@ -9228,8 +9229,14 @@ nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
rgnH = slcimg->region[3];

/* top-left */
struct nk_image img = {slcimg->handle, slcimg->w, slcimg->h,
{rgnX, rgnY, slc->l, slc->t}};
img.handle = slcimg->handle;
img.w = slcimg->w;
img.h = slcimg->h;
img.region[0] = rgnX;
img.region[1] = rgnY;
img.region[2] = slc->l;
img.region[3] = slc->t;

nk_draw_image(b,
nk_rect(r.x, r.y, (float)slc->l, (float)slc->t),
&img, col);
Expand Down Expand Up @@ -23487,8 +23494,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle.ptr = ptr;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
Expand All @@ -23502,8 +23509,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle.id = id;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
Expand All @@ -23517,8 +23524,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle = handle;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
Expand All @@ -23532,8 +23539,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle = handle;
i->w = 0; i->h = 0;
i->region[0] = 0;
Expand All @@ -23547,8 +23554,8 @@ 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_zero(&s, sizeof(s));
NK_ASSERT(ptr);
i->handle.ptr = ptr;
i->w = 0; i->h = 0;
Expand All @@ -23563,8 +23570,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle.id = id;
i->w = 0; i->h = 0;
i->region[0] = 0;
Expand Down Expand Up @@ -29529,6 +29536,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
///
/// - 2021/09/08 (4.08.2) - Fix warnings in C89 builds
/// - 2021/09/08 (4.08.1) - Use compiler builtins for NK_OFFSETOF when possible
/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuklear",
"version": "4.08.1",
"version": "4.08.2",
"repo": "Immediate-Mode-UI/Nuklear",
"description": "A small ANSI C gui toolkit",
"keywords": ["gl", "ui", "toolkit"],
Expand Down
1 change: 1 addition & 0 deletions src/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
///
/// - 2021/09/08 (4.08.2) - Fix warnings in C89 builds
/// - 2021/09/08 (4.08.1) - Use compiler builtins for NK_OFFSETOF when possible
/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
Expand Down
12 changes: 6 additions & 6 deletions src/nuklear_9slice.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle.ptr = ptr;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
Expand All @@ -25,8 +25,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle.id = id;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
Expand All @@ -40,8 +40,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle = handle;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
Expand All @@ -55,8 +55,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle = handle;
i->w = 0; i->h = 0;
i->region[0] = 0;
Expand All @@ -70,8 +70,8 @@ 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_zero(&s, sizeof(s));
NK_ASSERT(ptr);
i->handle.ptr = ptr;
i->w = 0; i->h = 0;
Expand All @@ -86,8 +86,8 @@ 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;
nk_zero(&s, sizeof(s));
i->handle.id = id;
i->w = 0; i->h = 0;
i->region[0] = 0;
Expand Down
11 changes: 9 additions & 2 deletions src/nuklear_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ NK_API void
nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
const struct nk_nine_slice *slc, struct nk_color col)
{
struct nk_image img;
const struct nk_image *slcimg = (const struct nk_image*)slc;
nk_ushort rgnX, rgnY, rgnW, rgnH;
rgnX = slcimg->region[0];
Expand All @@ -426,8 +427,14 @@ nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
rgnH = slcimg->region[3];

/* top-left */
struct nk_image img = {slcimg->handle, slcimg->w, slcimg->h,
{rgnX, rgnY, slc->l, slc->t}};
img.handle = slcimg->handle;
img.w = slcimg->w;
img.h = slcimg->h;
img.region[0] = rgnX;
img.region[1] = rgnY;
img.region[2] = slc->l;
img.region[3] = slc->t;

nk_draw_image(b,
nk_rect(r.x, r.y, (float)slc->l, (float)slc->t),
&img, col);
Expand Down

0 comments on commit 73a2062

Please sign in to comment.