From 1cdd4f10aa8f2669657b4ab49068f43cd063a9d0 Mon Sep 17 00:00:00 2001 From: luknw Date: Sat, 7 Dec 2019 01:33:14 +0100 Subject: [PATCH] [#18] Fix off-by-one error in NK_INTERSECT --- nuklear.h | 4 +++- package.json | 2 +- src/CHANGELOG | 1 + src/nuklear.h | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nuklear.h b/nuklear.h index f2ebba2..94939bd 100644 --- a/nuklear.h +++ b/nuklear.h @@ -5622,7 +5622,8 @@ struct nk_context { #define NK_INBOX(px, py, x, y, w, h)\ (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h)) #define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \ - (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0))) + ((x1 < (x0 + w0)) && (x0 < (x1 + w1)) && \ + (y1 < (y0 + h0)) && (y0 < (y1 + h1))) #define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\ (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh)) @@ -25475,6 +25476,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 /// +/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT /// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit /// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header /// when NK_BUTTON_TRIGGER_ON_RELEASE is defined. diff --git a/package.json b/package.json index f962f5c..adbf8bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nuklear", - "version": "4.01.4", + "version": "4.01.5", "repo": "vurtun/nuklear", "description": "A small ANSI C gui toolkit", "keywords": ["gl", "ui", "toolkit"], diff --git a/src/CHANGELOG b/src/CHANGELOG index cf54d68..05a65d8 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -8,6 +8,7 @@ /// - [yy]: Minor version with non-breaking API and library changes /// - [zz]: Bug fix version with no direct changes to API /// +/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT /// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit /// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header /// when NK_BUTTON_TRIGGER_ON_RELEASE is defined. diff --git a/src/nuklear.h b/src/nuklear.h index a88044d..2a9f45d 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -5403,7 +5403,8 @@ struct nk_context { #define NK_INBOX(px, py, x, y, w, h)\ (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h)) #define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \ - (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0))) + ((x1 < (x0 + w0)) && (x0 < (x1 + w1)) && \ + (y1 < (y0 + h0)) && (y0 < (y1 + h1))) #define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\ (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))