From ab9d0ffc5f5c7a98ec6dff36e4e60db82399808e Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sun, 21 Dec 2025 11:53:47 +0900 Subject: [PATCH] improve submenu --- src/widget/submenu.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/widget/submenu.c b/src/widget/submenu.c index 09a0274..3172084 100644 --- a/src/widget/submenu.c +++ b/src/widget/submenu.c @@ -160,14 +160,14 @@ static void click(MwWidget handle) { } static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) { - int i, w = 0, h = 0; + int i, w = 0, h = 0; + MwRect rc; + MwPoint p = *point; + + MwGetScreenSize(handle, &rc); handle->internal = menu; - MwLLMakeToolWindow(handle->lowlevel); - MwLLDetach(handle->lowlevel, point); - MwLLEndStateChange(handle->lowlevel); - for(i = 0; i < arrlen(menu->sub); i++) { if(strcmp(menu->sub[i]->name, "----") == 0) { h += MwDefaultBorderWidth(handle) * 2 + 2; @@ -183,6 +183,16 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) { w += 10 + 15; h += 3; + MwLLMakeToolWindow(handle->lowlevel); + MwLLDetach(handle->lowlevel, &p); + + if(MwGetInteger(handle, MwNy) + h > rc.height) { + MwVaApply(handle, + MwNy, rc.height - h, + NULL); + } + MwLLEndStateChange(handle->lowlevel); + MwVaApply(handle, MwNwidth, w, MwNheight, h,