From 63ac88d0a79b052e8b9a2d097e00be1cea8aa51c Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 24 Sep 2020 11:58:25 +0200 Subject: [PATCH] Possibility to have a constant width for numbers --- .../thirdparty/libopenui/src/bitmapbuffer.cpp | 7 +++++-- .../libopenui/src/libopenui_defines.h | 20 ++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp b/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp index 0e2e50de8..956b9abd3 100755 --- a/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp +++ b/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp @@ -557,7 +557,7 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_ else if (c >= 0xFE) { // CJK char s++; - c = uint8_t(*s) + ((c & 0x01) << 8) - 1; + c = uint8_t(*s) + ((c & 0x01u) << 8u) - 1; if (c >= 0x101) c -= 1; c += CJK_FIRST_LETTER_INDEX; @@ -566,7 +566,10 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_ } else if (c >= 0x20) { uint8_t width = drawChar(x, y, font, fontspecs, getMappedChar(c), flags); - INCREMENT_POS(width + CHAR_SPACING); + if ((flags & SPACING_NUMBERS_CONST) && c >= '0' && c <= '9') + INCREMENT_POS(getCharWidth('9', fontspecs) + CHAR_SPACING); + else + INCREMENT_POS(width + CHAR_SPACING); } else if (c == '\n') { pos = orig_pos; diff --git a/radio/src/thirdparty/libopenui/src/libopenui_defines.h b/radio/src/thirdparty/libopenui/src/libopenui_defines.h index ecb80dbe1..67e6111df 100644 --- a/radio/src/thirdparty/libopenui/src/libopenui_defines.h +++ b/radio/src/thirdparty/libopenui/src/libopenui_defines.h @@ -22,8 +22,10 @@ #include "libopenui_types.h" -/* lcd common flags */ -#define BLINK 0x01u +/* obsolete flags */ +#define BLINK 0 +#define EXPANDED 0 +#define TIMEHOUR 0 /* drawText flags */ #define LEFT 0x00u /* align left */ @@ -31,6 +33,10 @@ #define CENTERED 0x04u /* align center */ #define RIGHT 0x08u /* align right */ #define SHADOWED 0x80u /* black copy at +1 +1 */ +// unused 0x1000u +#define SPACING_NUMBERS_CONST 0x2000u +#define VERTICAL 0x4000u +// unused 0x8000u /* drawNumber flags */ #define LEADING0 0x10u @@ -41,13 +47,9 @@ /* telemetry flags */ #define NO_UNIT 0x40u -#define FONT_MASK 0x0F00u -#define FONT_INDEX(flags) (((flags) & FONT_MASK) >> 8u) -#define FONT(xx) (unsigned(FONT_ ## xx ## _INDEX) << 8u) - -#define TIMEHOUR 0x2000u -#define EXPANDED 0x2000u -#define VERTICAL 0x4000u +#define FONT_MASK 0x0F00u +#define FONT_INDEX(flags) (((flags) & FONT_MASK) >> 8u) +#define FONT(xx) (unsigned(FONT_ ## xx ## _INDEX) << 8u) #define ARGB_SPLIT(color, a, r, g, b) \ uint16_t a = ((color) & 0xF000) >> 12; \