introduce MwNleftPadding to label

This commit is contained in:
NishiOwO
2025-12-25 15:39:54 +09:00
parent 0d79141a49
commit e895e96941
2 changed files with 7 additions and 1 deletions

View File

@@ -544,6 +544,7 @@
<property name="bold" /> <property name="bold" />
<property name="sevenSegment" /> <property name="sevenSegment" />
<property name="length" /> <property name="length" />
<property name="leftPadding" />
</properties> </properties>
<functions> <functions>
<function name="SetSevenSegment"> <function name="SetSevenSegment">

View File

@@ -15,6 +15,7 @@ static int create(MwWidget handle) {
MwSetInteger(handle, MwNbold, 0); MwSetInteger(handle, MwNbold, 0);
MwSetInteger(handle, MwNsevenSegment, 0); MwSetInteger(handle, MwNsevenSegment, 0);
MwSetInteger(handle, MwNlength, 4); MwSetInteger(handle, MwNlength, 4);
MwSetInteger(handle, MwNleftPadding, 0);
return 0; return 0;
} }
@@ -309,6 +310,8 @@ static void draw(MwWidget handle) {
MwLLDestroyPixmap(px); MwLLDestroyPixmap(px);
} else { } else {
r.width -= MwGetInteger(handle, MwNleftPadding);
if(align == MwALIGNMENT_CENTER) { if(align == MwALIGNMENT_CENTER) {
p.x = r.width / 2; p.x = r.width / 2;
} else if(align == MwALIGNMENT_BEGINNING) { } else if(align == MwALIGNMENT_BEGINNING) {
@@ -318,6 +321,8 @@ static void draw(MwWidget handle) {
} }
p.y = r.height / 2; p.y = r.height / 2;
p.x += MwGetInteger(handle, MwNleftPadding);
p.x += 1; p.x += 1;
p.y += 1; p.y += 1;
MwDrawText(handle, &p, str, MwGetInteger(handle, MwNbold), MwALIGNMENT_CENTER, shadow); MwDrawText(handle, &p, str, MwGetInteger(handle, MwNbold), MwALIGNMENT_CENTER, shadow);
@@ -333,7 +338,7 @@ static void draw(MwWidget handle) {
} }
static void prop_change(MwWidget handle, const char* key) { static void prop_change(MwWidget handle, const char* key) {
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNalignment) == 0 || strcmp(key, MwNsevenSegment) == 0) MwForceRender(handle); if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNalignment) == 0 || strcmp(key, MwNsevenSegment) == 0 || strcmp(key, MwNlength) == 0 || strcmp(key, MwNleftPadding) == 0) MwForceRender(handle);
} }
static void mwLabelSetSevenSegmentImpl(MwWidget handle, int index, unsigned char data) { static void mwLabelSetSevenSegmentImpl(MwWidget handle, int index, unsigned char data) {