git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@763 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-21 09:59:28 +00:00
parent 75c73e98e1
commit 8ed8e51ba7
2 changed files with 11 additions and 20 deletions

View File

@@ -6,23 +6,14 @@
static void set_xywh(MwWidget handle) { static void set_xywh(MwWidget handle) {
int height = 0; int height = 0;
int i;
MwMenu m = handle->internal;
for(i = 0; i < arrlen(m->sub); i++) { height = MwTextHeight(handle, "M") + 10;
int h = MwTextHeight(handle, m->sub[i]->name);
if(height < h) {
height = h;
}
}
height += 20;
MwVaApply(handle, MwVaApply(handle,
MwNx, 0, MwNx, -MwDefaultBorderWidth(handle),
MwNy, 0, MwNy, -MwDefaultBorderWidth(handle),
MwNwidth, MwGetInteger(handle->parent, MwNwidth), MwNwidth, MwGetInteger(handle->parent, MwNwidth) + MwDefaultBorderWidth(handle),
MwNheight, height, MwNheight, height + MwDefaultBorderWidth(handle),
NULL); NULL);
} }
@@ -66,15 +57,15 @@ static void destroy(MwWidget handle) {
MwRect r; \ MwRect r; \
int rx; \ int rx; \
\ \
p.x = 10; \ p.x = 5; \
p.y = MwGetInteger(handle, MwNheight) / 2; \ p.y = (MwGetInteger(handle, MwNheight) - MwDefaultBorderWidth(handle)) / 2 + MwDefaultBorderWidth(handle); \
\ \
r.x = 0; \ r.x = 0; \
r.y = 0; \ r.y = 0; \
r.width = MwGetInteger(handle, MwNwidth); \ r.width = MwGetInteger(handle, MwNwidth); \
r.height = MwGetInteger(handle, MwNheight); \ r.height = MwGetInteger(handle, MwNheight); \
\ \
rx = r.width - 10; rx = r.width - 5;
#define BEGIN_MENU_LOOP \ #define BEGIN_MENU_LOOP \
for(i = 0; i < arrlen(m->sub); i++) { \ for(i = 0; i < arrlen(m->sub); i++) { \
@@ -85,7 +76,7 @@ static void destroy(MwWidget handle) {
\ \
if(incr) { \ if(incr) { \
p.x = rx -= tw; \ p.x = rx -= tw; \
rx -= 20; \ rx -= 10; \
} \ } \
\ \
r.x = p.x - 5; \ r.x = p.x - 5; \
@@ -115,7 +106,7 @@ static void draw(MwWidget handle) {
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE); MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
} }
MwDrawText(handle, &p, m->sub[i]->name + incr, 1, MwALIGNMENT_BEGINNING, text); MwDrawText(handle, &p, m->sub[i]->name + incr, m->sub[i]->wsub != NULL || (in_area && handle->pressed) ? 1 : 0, MwALIGNMENT_BEGINNING, text);
END_MENU_LOOP; END_MENU_LOOP;
MwLLFreeColor(text); MwLLFreeColor(text);

View File

@@ -75,7 +75,7 @@ static void draw(MwWidget handle) {
p.x = 5 + tw / 2; p.x = 5 + tw / 2;
p.y += th / 2; p.y += th / 2;
MwDrawText(handle, &p, menu->sub[i]->name, 1, MwALIGNMENT_CENTER, text); MwDrawText(handle, &p, menu->sub[i]->name, menu->sub[i]->wsub != NULL ? 1 : 0, MwALIGNMENT_CENTER, text);
if(arrlen(menu->sub[i]->sub) > 0) { if(arrlen(menu->sub[i]->sub) > 0) {
MwRect tr; MwRect tr;