From 3f1284dfcdacd59a65079a255a5fc5fb584a5a04 Mon Sep 17 00:00:00 2001 From: ryuukk Date: Wed, 25 Sep 2024 17:52:46 +0200 Subject: [PATCH 1/6] extend panel's clipping area to take into account the padding --- src/nuklear_panel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nuklear_panel.c b/src/nuklear_panel.c index 75b8eb47c..483ae4f64 100644 --- a/src/nuklear_panel.c +++ b/src/nuklear_panel.c @@ -319,6 +319,12 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan layout->clip = layout->bounds; nk_unify(&clip, &win->buffer.clip, layout->clip.x, layout->clip.y, layout->clip.x + layout->clip.w, layout->clip.y + layout->clip.h); + + clip.x -= style->window.padding.x; + clip.y -= style->window.padding.y; + clip.w += style->window.padding.x*2; + clip.h += style->window.padding.y*2; + nk_push_scissor(out, clip); layout->clip = clip;} return !(layout->flags & NK_WINDOW_HIDDEN) && !(layout->flags & NK_WINDOW_MINIMIZED); From 2b2ec491c4df31a599beb3afde06d875164bfa39 Mon Sep 17 00:00:00 2001 From: ryuukk Date: Wed, 25 Sep 2024 20:44:48 +0200 Subject: [PATCH 2/6] Add comments + limit checks --- src/nuklear_panel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nuklear_panel.c b/src/nuklear_panel.c index 483ae4f64..0b53cb9ad 100644 --- a/src/nuklear_panel.c +++ b/src/nuklear_panel.c @@ -320,10 +320,16 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan nk_unify(&clip, &win->buffer.clip, layout->clip.x, layout->clip.y, layout->clip.x + layout->clip.w, layout->clip.y + layout->clip.h); + /* extand clipping area to allow borders to be properly drawn */ clip.x -= style->window.padding.x; clip.y -= style->window.padding.y; clip.w += style->window.padding.x*2; clip.h += style->window.padding.y*2; + /* ensure clipping area doesn't exceed windows bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); nk_push_scissor(out, clip); layout->clip = clip;} From 2088e494e2fd3f148c907cdec3addd6a04ceebfe Mon Sep 17 00:00:00 2001 From: ryuukk Date: Wed, 25 Sep 2024 20:45:21 +0200 Subject: [PATCH 3/6] Fix typo --- src/nuklear_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nuklear_panel.c b/src/nuklear_panel.c index 0b53cb9ad..0651b6de4 100644 --- a/src/nuklear_panel.c +++ b/src/nuklear_panel.c @@ -320,7 +320,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan nk_unify(&clip, &win->buffer.clip, layout->clip.x, layout->clip.y, layout->clip.x + layout->clip.w, layout->clip.y + layout->clip.h); - /* extand clipping area to allow borders to be properly drawn */ + /* extend clipping area to allow borders to be properly drawn */ clip.x -= style->window.padding.x; clip.y -= style->window.padding.y; clip.w += style->window.padding.x*2; From bffdc139246ec3d8f8bdc93c9c4ce5895e8bf29d Mon Sep 17 00:00:00 2001 From: ryuukk Date: Thu, 26 Sep 2024 10:10:35 +0200 Subject: [PATCH 4/6] Only for windows --- src/nuklear_panel.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/nuklear_panel.c b/src/nuklear_panel.c index 0651b6de4..1222e0bfd 100644 --- a/src/nuklear_panel.c +++ b/src/nuklear_panel.c @@ -320,16 +320,19 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan nk_unify(&clip, &win->buffer.clip, layout->clip.x, layout->clip.y, layout->clip.x + layout->clip.w, layout->clip.y + layout->clip.h); - /* extend clipping area to allow borders to be properly drawn */ - clip.x -= style->window.padding.x; - clip.y -= style->window.padding.y; - clip.w += style->window.padding.x*2; - clip.h += style->window.padding.y*2; - /* ensure clipping area doesn't exceed windows bounds */ - clip.x = NK_MAX(clip.x, win->bounds.x); - clip.w = NK_MIN(clip.w, win->bounds.w); - clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); - clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + if (panel_type == NK_PANEL_WINDOW) + { + /* extend clipping area to allow borders to be properly drawn */ + clip.x -= style->window.padding.x; + clip.y -= style->window.padding.y; + clip.w += style->window.padding.x*2; + clip.h += style->window.padding.y*2; + /* ensure clipping area doesn't exceed windows bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + } nk_push_scissor(out, clip); layout->clip = clip;} From efc54115c36eb2a58f0b4eea36e9213312c7d745 Mon Sep 17 00:00:00 2001 From: ryuukk Date: Thu, 26 Sep 2024 10:13:55 +0200 Subject: [PATCH 5/6] Typo --- src/nuklear_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nuklear_panel.c b/src/nuklear_panel.c index 1222e0bfd..5f77973f2 100644 --- a/src/nuklear_panel.c +++ b/src/nuklear_panel.c @@ -327,7 +327,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan clip.y -= style->window.padding.y; clip.w += style->window.padding.x*2; clip.h += style->window.padding.y*2; - /* ensure clipping area doesn't exceed windows bounds */ + /* ensure clipping area doesn't exceed window bounds */ clip.x = NK_MAX(clip.x, win->bounds.x); clip.w = NK_MIN(clip.w, win->bounds.w); clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); From a4590db1427ebf482ca7fcf02f293ed33f10b759 Mon Sep 17 00:00:00 2001 From: ryuukk <44361234+ryuukk@users.noreply.github.com> Date: Sun, 29 Sep 2024 10:16:02 +0200 Subject: [PATCH 6/6] Do the same for all other kind of panel --- src/nuklear_panel.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/nuklear_panel.c b/src/nuklear_panel.c index 5f77973f2..be92ce2ae 100644 --- a/src/nuklear_panel.c +++ b/src/nuklear_panel.c @@ -320,6 +320,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan nk_unify(&clip, &win->buffer.clip, layout->clip.x, layout->clip.y, layout->clip.x + layout->clip.w, layout->clip.y + layout->clip.h); + if (panel_type == NK_PANEL_WINDOW) { /* extend clipping area to allow borders to be properly drawn */ @@ -333,6 +334,84 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); } + else if (panel_type == NK_PANEL_GROUP) + { + /* extend clipping area to allow borders to be properly drawn */ + clip.x -= style->window.group_padding.x; + clip.y -= style->window.group_padding.y; + clip.w += style->window.group_padding.x*2; + clip.h += style->window.group_padding.y*2; + /* ensure clipping area doesn't exceed window bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + } + else if (panel_type == NK_PANEL_POPUP) + { + /* extend clipping area to allow borders to be properly drawn */ + clip.x -= style->window.popup_padding.x; + clip.y -= style->window.popup_padding.y; + clip.w += style->window.popup_padding.x*2; + clip.h += style->window.popup_padding.y*2; + /* ensure clipping area doesn't exceed window bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + } + else if (panel_type == NK_PANEL_CONTEXTUAL) + { + /* extend clipping area to allow borders to be properly drawn */ + clip.x -= style->window.contextual_padding.x; + clip.y -= style->window.contextual_padding.y; + clip.w += style->window.contextual_padding.x*2; + clip.h += style->window.contextual_padding.y*2; + /* ensure clipping area doesn't exceed window bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + } + else if (panel_type == NK_PANEL_MENU) + { + /* extend clipping area to allow borders to be properly drawn */ + clip.x -= style->window.menu_padding.x; + clip.y -= style->window.menu_padding.y; + clip.w += style->window.menu_padding.x*2; + clip.h += style->window.menu_padding.y*2; + /* ensure clipping area doesn't exceed window bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + } + else if (panel_type == NK_PANEL_TOOLTIP) + { + /* extend clipping area to allow borders to be properly drawn */ + clip.x -= style->window.tooltip_padding.x; + clip.y -= style->window.tooltip_padding.y; + clip.w += style->window.tooltip_padding.x*2; + clip.h += style->window.tooltip_padding.y*2; + /* ensure clipping area doesn't exceed window bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + } + else if (panel_type == NK_PANEL_COMBO) + { + /* extend clipping area to allow borders to be properly drawn */ + clip.x -= style->window.combo_padding.x; + clip.y -= style->window.combo_padding.y; + clip.w += style->window.combo_padding.x*2; + clip.h += style->window.combo_padding.y*2; + /* ensure clipping area doesn't exceed window bounds */ + clip.x = NK_MAX(clip.x, win->bounds.x); + clip.w = NK_MIN(clip.w, win->bounds.w); + clip.y = NK_MAX(clip.y, win->bounds.y+layout->header_height); + clip.h = NK_MIN(clip.h, win->bounds.h-layout->header_height); + } nk_push_scissor(out, clip); layout->clip = clip;}