Improve textView on colorlcd (#7395)
This commit is contained in:
@@ -41,6 +41,14 @@ typedef int coord_t;
|
||||
typedef uint32_t LcdFlags;
|
||||
typedef uint16_t display_t;
|
||||
|
||||
int getTextWidth(const char * s, int len=0, LcdFlags flags=0);
|
||||
|
||||
#if LCD_W >= 480
|
||||
#define LCD_COLS 80
|
||||
#else
|
||||
#define LCD_COLS 30
|
||||
#endif
|
||||
|
||||
enum BitmapFormats
|
||||
{
|
||||
BMP_RGB565,
|
||||
@@ -275,6 +283,16 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
|
||||
uint8_t drawCharWithCache(coord_t x, coord_t y, const BitmapBuffer * font, const uint16_t * spec, int index, LcdFlags flags);
|
||||
|
||||
void drawTextMaxWidth(coord_t x, coord_t y, const char * s, LcdFlags flags, coord_t maxWidth)
|
||||
{
|
||||
for (int col = LCD_COLS; col > 0; col--) {
|
||||
if (getTextWidth(s, col, flags) <= maxWidth) {
|
||||
drawSizedText(x, y, s, col, flags);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawText(coord_t x, coord_t y, const char * s, LcdFlags flags)
|
||||
{
|
||||
drawSizedText(x, y, s, 255, flags);
|
||||
|
||||
Reference in New Issue
Block a user