add MwNleftPadding to SubMenu

This commit is contained in:
NishiOwO
2025-12-25 03:56:04 +09:00
parent 22b4737c33
commit e77c4f3c38
2 changed files with 11 additions and 3 deletions

View File

@@ -640,6 +640,9 @@
</functions> </functions>
</widget> </widget>
<widget name="SubMenu"> <widget name="SubMenu">
<properties>
<property name="leftPadding" />
</properties>
<functions> <functions>
<function name="Appear"> <function name="Appear">
<arguments> <arguments>

View File

@@ -6,6 +6,7 @@ static int create(MwWidget handle) {
MwLLBeginStateChange(handle->lowlevel); MwLLBeginStateChange(handle->lowlevel);
MwSetDefault(handle); MwSetDefault(handle);
MwSetInteger(handle, MwNleftPadding, 16);
return 0; return 0;
} }
@@ -53,9 +54,11 @@ static void draw(MwWidget handle) {
rc.x = MwDefaultBorderWidth(handle) * 2; rc.x = MwDefaultBorderWidth(handle) * 2;
rc.y = p.y; rc.y = p.y;
rc.width = r.width - (rc.x * 2); rc.width = r.width - (rc.x * 2) - MwGetInteger(handle, MwNleftPadding);
rc.height = 2; rc.height = 2;
rc.x += MwGetInteger(handle, MwNleftPadding);
MwDrawFrameEx(handle, &rc, base, 1, 1, 0, 0); MwDrawFrameEx(handle, &rc, base, 1, 1, 0, 0);
p.y += 2 + 1; p.y += 2 + 1;
@@ -71,7 +74,7 @@ static void draw(MwWidget handle) {
MwDrawWidgetBack(handle, &r, base, 0, MwTRUE); MwDrawWidgetBack(handle, &r, base, 0, MwTRUE);
} }
p.x = 5 + tw / 2; p.x = 5 + tw / 2 + MwGetInteger(handle, MwNleftPadding);
p.y += th / 2; p.y += th / 2;
MwDrawText(handle, &p, menu->sub[i]->name, menu->sub[i]->wsub != NULL ? 1 : 0, MwALIGNMENT_CENTER, text); MwDrawText(handle, &p, menu->sub[i]->name, menu->sub[i]->wsub != NULL ? 1 : 0, MwALIGNMENT_CENTER, text);
@@ -120,7 +123,7 @@ static void click(MwWidget handle) {
rc.height = 2 - 1; rc.height = 2 - 1;
} }
if(rc.y <= handle->mouse_point.y && handle->mouse_point.y <= (int)(rc.y + rc.height)) { if(MwGetInteger(handle, MwNleftPadding) <= handle->mouse_point.x && rc.y <= handle->mouse_point.y && handle->mouse_point.y <= (int)(rc.y + rc.height)) {
if(menu->sub[i]->wsub == NULL && arrlen(menu->sub[i]->sub) > 0) { if(menu->sub[i]->wsub == NULL && arrlen(menu->sub[i]->sub) > 0) {
MwPoint p; MwPoint p;
int j; int j;
@@ -184,6 +187,8 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point, in
} }
} }
w += MwGetInteger(handle, MwNleftPadding);
w += 10 + 15; w += 10 + 15;
h += 3; h += 3;