From 5f5bb524ac7012d844c620a8f03db6c5afe9882a Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Wed, 1 Oct 2025 16:58:52 +0000 Subject: [PATCH] menu git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@109 b9cfdab3-6d41-4d17-bbe4-086880011989 --- examples/example.c | 3 ++- src/menu.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/example.c b/examples/example.c index 5b9f84f..90bc5dc 100644 --- a/examples/example.c +++ b/examples/example.c @@ -76,7 +76,8 @@ int main() { MwMenuAdd(menu, NULL, "test 2"); MwMenuAdd(menu, NULL, "test 3"); MwMenuAdd(menu, NULL, "test 4"); - MwMenuAdd(menu, NULL, "test 5"); + MwMenuAdd(menu, NULL, "?test 5"); + MwMenuAdd(menu, NULL, "test 6"); MwLoop(window); } diff --git a/src/menu.c b/src/menu.c index aa554be..a7a6609 100644 --- a/src/menu.c +++ b/src/menu.c @@ -81,9 +81,14 @@ static void draw(MwWidget handle) { MwDrawFrame(handle, &r, base, 0); MwDrawRect(handle, &r, base); for(i = 0; i < arrlen(m->sub); i++) { - int tw = MwTextWidth(handle, m->sub[i]->name); - int th = MwTextHeight(handle, m->sub[i]->name); + int incr = m->sub[i]->name[0] == '?' ? 1 : 0; + int tw = MwTextWidth(handle, m->sub[i]->name + incr); + int th = MwTextHeight(handle, m->sub[i]->name + incr); + int oldx = p.x; + if(incr) { + p.x = MwGetInteger(handle, MwNwidth) - tw - 10; + } p.x += tw / 2; r.x = p.x - tw / 2 - 5; @@ -95,9 +100,10 @@ static void draw(MwWidget handle) { MwDrawFrame(handle, &r, base, 0); } - MwDrawText(handle, &p, m->sub[i]->name, 1, text); + MwDrawText(handle, &p, m->sub[i]->name + incr, 1, text); p.x += tw / 2 + 20; + if(incr) p.x = oldx; } MwLLFreeColor(text);