From ee98be1cc154cb4649b183856cd2ce793db6d4e9 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Tue, 21 Jun 2022 09:22:49 +0100 Subject: [PATCH] jwidget: fix bad display of border of size 0 This is caused by drect() flipping arguments in the order is incorrect, so x2 < x1 gives you a rectangle instead of nothing. --- src/jwidget.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jwidget.c b/src/jwidget.c index ddb50b6..e39e4a8 100644 --- a/src/jwidget.c +++ b/src/jwidget.c @@ -609,11 +609,15 @@ void jwidget_render(void *w0, int x, int y) if(g->border_style == J_BORDER_NONE || color == C_NONE) { } else if(g->border_style == J_BORDER_SOLID) { - drect(x1, y1, x2 + b.right - 1, y1 + b.top - 1, color); - drect(x1, y2, x2 + b.right - 1, y2 + b.bottom - 1, color); + if(b.top > 0) + drect(x1, y1, x2 + b.right - 1, y1 + b.top - 1, color); + if(b.bottom > 0) + drect(x1, y2, x2 + b.right - 1, y2 + b.bottom - 1, color); - drect(x1, y1 + b.top, x1 + b.left - 1, y2 - 1, color); - drect(x2, y1 + b.top, x2 + b.right - 1, y2 - 1, color); + if(b.left > 0) + drect(x1, y1 + b.top, x1 + b.left - 1, y2 - 1, color); + if(b.right > 0) + drect(x2, y1 + b.top, x2 + b.right - 1, y2 - 1, color); } /* TODO: jwidget_render(): More border types */