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="margin" />
<property name="padding" />
<property name="hasBorder" />
<property name="inverted" />
</properties>
</widget>
<widget name="Button">

View File

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

View File

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