adjust some stuff

This commit is contained in:
NishiOwO
2025-12-21 15:33:48 +09:00
parent 2304b493d1
commit 188da6803e
3 changed files with 17 additions and 8 deletions

View File

@@ -497,6 +497,8 @@
<property name="orientation" /> <property name="orientation" />
<property name="margin" /> <property name="margin" />
<property name="padding" /> <property name="padding" />
<property name="hasBorder" />
<property name="inverted" />
</properties> </properties>
</widget> </widget>
<widget name="Button"> <widget name="Button">

View File

@@ -8,6 +8,8 @@ static int create(MwWidget handle) {
MwSetInteger(handle, MwNorientation, MwHORIZONTAL); MwSetInteger(handle, MwNorientation, MwHORIZONTAL);
MwSetInteger(handle, MwNmargin, 0); MwSetInteger(handle, MwNmargin, 0);
MwSetInteger(handle, MwNpadding, 0); MwSetInteger(handle, MwNpadding, 0);
MwSetInteger(handle, MwNhasBorder, 0);
MwSetInteger(handle, MwNinverted, 1);
return 0; return 0;
} }
@@ -20,6 +22,11 @@ static void draw(MwWidget handle) {
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);
if(MwGetInteger(handle, MwNhasBorder)) {
MwDrawFrame(handle, &r, base, MwGetInteger(handle, MwNinverted));
}
MwDrawRect(handle, &r, base); MwDrawRect(handle, &r, base);
MwLLFreeColor(base); MwLLFreeColor(base);
@@ -31,9 +38,9 @@ static void layout(MwWidget handle) {
int i; int i;
int sum = 0; int sum = 0;
int horiz = MwGetInteger(handle, MwNorientation) == MwHORIZONTAL ? 1 : 0; int horiz = MwGetInteger(handle, MwNorientation) == MwHORIZONTAL ? 1 : 0;
int sz = MwGetInteger(handle, horiz ? MwNwidth : MwNheight) - MwGetInteger(handle, MwNpadding) * 2; int sz = MwGetInteger(handle, horiz ? MwNwidth : MwNheight) - (MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0)) * 2;
int fsz = MwGetInteger(handle, horiz ? MwNheight : MwNwidth) - MwGetInteger(handle, MwNpadding) * 2; int fsz = MwGetInteger(handle, horiz ? MwNheight : MwNwidth) - (MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0)) * 2;
int sk = MwGetInteger(handle, MwNpadding); int sk = MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0);
for(i = 0; i < arrlen(handle->children); i++) { for(i = 0; i < arrlen(handle->children); i++) {
int n = MwGetInteger(handle->children[i], MwNratio); int n = MwGetInteger(handle->children[i], MwNratio);
@@ -60,10 +67,10 @@ static void layout(MwWidget handle) {
} }
MwVaApply(handle->children[i], MwVaApply(handle->children[i],
horiz ? MwNx : MwNy, sk, /* this is what gets changed */ horiz ? MwNx : MwNy, sk, /* this is what gets changed */
horiz ? MwNy : MwNx, MwGetInteger(handle, MwNpadding), /* fixed between widgets */ horiz ? MwNy : MwNx, MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0), /* fixed between widgets */
horiz ? MwNwidth : MwNheight, wsz, /* this is what gets changed */ horiz ? MwNwidth : MwNheight, wsz, /* this is what gets changed */
horiz ? MwNheight : MwNwidth, fsz, /* fixed between widgets */ horiz ? MwNheight : MwNwidth, fsz, /* fixed between widgets */
NULL); NULL);
sk += wsz + Margin; sk += wsz + Margin;
} }

View File

@@ -295,7 +295,7 @@ static void draw(MwWidget handle) {
px = MwLoadRaw(handle, raw, w, h); px = MwLoadRaw(handle, raw, w, h);
r.y = 0; r.y = (r.height - h) / 2;
r.height = h; r.height = h;
if(align == MwALIGNMENT_CENTER) { if(align == MwALIGNMENT_CENTER) {
r.x = (r.width - w) / 2; r.x = (r.width - w) / 2;