From e895e9694187c11fd907e4b1786404a2032c9705 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Thu, 25 Dec 2025 15:39:54 +0900 Subject: [PATCH] introduce MwNleftPadding to label --- milsko.xml | 1 + src/widget/label.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/milsko.xml b/milsko.xml index 82b5b6b..f7dcf2c 100644 --- a/milsko.xml +++ b/milsko.xml @@ -544,6 +544,7 @@ + diff --git a/src/widget/label.c b/src/widget/label.c index 86aefe8..f85fb5d 100644 --- a/src/widget/label.c +++ b/src/widget/label.c @@ -15,6 +15,7 @@ static int create(MwWidget handle) { MwSetInteger(handle, MwNbold, 0); MwSetInteger(handle, MwNsevenSegment, 0); MwSetInteger(handle, MwNlength, 4); + MwSetInteger(handle, MwNleftPadding, 0); return 0; } @@ -309,6 +310,8 @@ static void draw(MwWidget handle) { MwLLDestroyPixmap(px); } else { + r.width -= MwGetInteger(handle, MwNleftPadding); + if(align == MwALIGNMENT_CENTER) { p.x = r.width / 2; } else if(align == MwALIGNMENT_BEGINNING) { @@ -318,6 +321,8 @@ static void draw(MwWidget handle) { } p.y = r.height / 2; + p.x += MwGetInteger(handle, MwNleftPadding); + p.x += 1; p.y += 1; 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) { - 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) {