From fa7240a788d361dfdd39016b38468836834cfd46 Mon Sep 17 00:00:00 2001 From: Robert Winkler Date: Fri, 4 Sep 2026 19:43:59 -0700 Subject: [PATCH] Fix unnecessary combo flips When user given height is less than content height, use that (will have a scrollbar) so we don't flip unnecessarily Opposite of Menu example of larger than needed requested height, in which case we use real content height to determine whether to flip --- nuklear.h | 6 ++++++ src/nuklear_popup.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/nuklear.h b/nuklear.h index bfc9fe17..507b92c8 100644 --- a/nuklear.h +++ b/nuklear.h @@ -21571,6 +21571,12 @@ nk_fit_popup_rect(const struct nk_context *ctx, struct nk_rect body, d_right = d.x + d.w; d_bottom = d.y + d.h; req_h = body.h; + /* last_h is unclamped layout height (every row, including those that + * would scroll). Combos pass a smaller panel (e.g. 200 with 370px of + * items); menus pass a larger max (e.g. 600 with 80px of trees). + * Judge the visible panel: min(content, caller max). */ + if (known_h > req_h) + known_h = req_h; need_h = (known_h > 0.0f) ? known_h : req_h; overlap = (anchor.y + anchor.h) - body.y; diff --git a/src/nuklear_popup.c b/src/nuklear_popup.c index 6ec7bc7a..94465e0e 100644 --- a/src/nuklear_popup.c +++ b/src/nuklear_popup.c @@ -27,6 +27,12 @@ nk_fit_popup_rect(const struct nk_context *ctx, struct nk_rect body, d_right = d.x + d.w; d_bottom = d.y + d.h; req_h = body.h; + /* last_h is unclamped layout height (every row, including those that + * would scroll). Combos pass a smaller panel (e.g. 200 with 370px of + * items); menus pass a larger max (e.g. 600 with 80px of trees). + * Judge the visible panel: min(content, caller max). */ + if (known_h > req_h) + known_h = req_h; need_h = (known_h > 0.0f) ? known_h : req_h; overlap = (anchor.y + anchor.h) - body.y;