WiP: remove legacy fonts
This commit is contained in:
committed by
Raphael Coeffic
parent
6376f8295a
commit
77382ba406
@@ -0,0 +1 @@
|
|||||||
|
src/thirdparty/stb/
|
||||||
@@ -11,7 +11,6 @@ if(SOFTWARE_KEYBOARD)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBOPENUI_SRC
|
set(LIBOPENUI_SRC
|
||||||
libopenui_globals.cpp
|
|
||||||
libopenui_file.cpp
|
libopenui_file.cpp
|
||||||
bitmapbuffer.cpp
|
bitmapbuffer.cpp
|
||||||
window.cpp
|
window.cpp
|
||||||
|
|||||||
+37
-61
@@ -20,7 +20,6 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "bitmapbuffer.h"
|
#include "bitmapbuffer.h"
|
||||||
#include "libopenui_depends.h"
|
#include "libopenui_depends.h"
|
||||||
#include "libopenui_globals.h"
|
|
||||||
#include "libopenui_helpers.h"
|
#include "libopenui_helpers.h"
|
||||||
#include "libopenui_file.h"
|
#include "libopenui_file.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
@@ -1008,21 +1007,13 @@ void BitmapBuffer::drawBitmapPattern(coord_t x, coord_t y, const uint8_t * bmp,
|
|||||||
srcx, srcy, srcw, srch, COLOR_VAL(flags));
|
srcx, srcy, srcw, srch, COLOR_VAL(flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t BitmapBuffer::drawChar(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, unsigned int index, LcdFlags flags)
|
// TODO: find a better place to define this
|
||||||
{
|
extern lv_color_t makeLvColor(uint32_t colorFlags);
|
||||||
coord_t offset = spec[index + 1];
|
|
||||||
coord_t width = spec[index + 2] - offset;
|
|
||||||
if (width > 0) {
|
|
||||||
drawBitmapPattern(x, y, font, flags, offset, width);
|
|
||||||
}
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define INCREMENT_POS(delta) do { if (flags & VERTICAL) y -= delta; else x += delta; } while(0)
|
coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char *s,
|
||||||
|
uint8_t len, LcdFlags flags)
|
||||||
coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags)
|
|
||||||
{
|
{
|
||||||
if (!s) return (flags & VERTICAL) ? y : x;
|
if (!s) return x;
|
||||||
MOVE_OFFSET();
|
MOVE_OFFSET();
|
||||||
|
|
||||||
int height = getFontHeight(flags);
|
int height = getFontHeight(flags);
|
||||||
@@ -1032,61 +1023,46 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t fontindex = FONT_INDEX(flags);
|
coord_t pos = x;
|
||||||
const unsigned char * font = fontsTable[fontindex];
|
|
||||||
const uint16_t * fontspecs = fontspecsTable[fontindex];
|
|
||||||
|
|
||||||
if (flags & (RIGHT | CENTERED)) {
|
|
||||||
int width = getTextWidth(s, len, flags);
|
|
||||||
if (flags & RIGHT) {
|
|
||||||
INCREMENT_POS(-width);
|
|
||||||
}
|
|
||||||
else if (flags & CENTERED) {
|
|
||||||
INCREMENT_POS(-width / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
coord_t & pos = (flags & VERTICAL) ? y : x;
|
|
||||||
const coord_t orig_pos = pos;
|
const coord_t orig_pos = pos;
|
||||||
|
|
||||||
while (len--) {
|
lv_draw_label_dsc_t label_draw_dsc;
|
||||||
unsigned c = uint8_t(*s);
|
lv_draw_label_dsc_init(&label_draw_dsc);
|
||||||
// TRACE("c = %d %o 0x%X '%c'", c, c, c, c);
|
|
||||||
|
|
||||||
if (!c) {
|
const lv_font_t* font = getFont(flags);
|
||||||
break;
|
label_draw_dsc.font = font;
|
||||||
}
|
label_draw_dsc.color = makeLvColor(flags);
|
||||||
else if (c >= 0xFE) {
|
|
||||||
// CJK char
|
|
||||||
s++;
|
|
||||||
c = uint8_t(*s) + ((c & 0x01u) << 8u) - 1;
|
|
||||||
// TRACE("CJK = %d", c);
|
|
||||||
if (c >= 0x100)
|
|
||||||
c -= 1;
|
|
||||||
c += CJK_FIRST_LETTER_INDEX;
|
|
||||||
uint8_t width = drawChar(x, y, font, fontspecs, c, flags);
|
|
||||||
INCREMENT_POS(width + CHAR_SPACING);
|
|
||||||
}
|
|
||||||
else if ((c >= 0x20u) && (c < fontCharactersTable[FONT_INDEX(flags)] + 0x20u)) {
|
|
||||||
uint8_t width = drawChar(x, y, font, fontspecs, getMappedChar(c), flags);
|
|
||||||
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;
|
|
||||||
if (flags & VERTICAL)
|
|
||||||
x += height;
|
|
||||||
else
|
|
||||||
y += height;
|
|
||||||
}
|
|
||||||
|
|
||||||
s++;
|
x += draw_ctx->buf_area->x1;
|
||||||
|
y += draw_ctx->buf_area->y1;
|
||||||
|
|
||||||
|
lv_point_t p;
|
||||||
|
lv_txt_get_size(&p, s, font, label_draw_dsc.letter_space,
|
||||||
|
label_draw_dsc.line_space, LV_COORD_MAX, 0);
|
||||||
|
|
||||||
|
lv_coord_t lv_x = (lv_coord_t)x;
|
||||||
|
lv_coord_t lv_y = (lv_coord_t)y;
|
||||||
|
|
||||||
|
lv_area_t coords = {
|
||||||
|
lv_x, lv_y, lv_x, lv_y,
|
||||||
|
};
|
||||||
|
|
||||||
|
coords.x2 += p.x - 1;
|
||||||
|
coords.y2 += p.y - 1;
|
||||||
|
|
||||||
|
if (flags & RIGHT) {
|
||||||
|
label_draw_dsc.align = LV_TEXT_ALIGN_RIGHT;
|
||||||
|
} else if (flags & CENTERED) {
|
||||||
|
label_draw_dsc.align = LV_TEXT_ALIGN_CENTER;
|
||||||
|
coords.x1 -= p.x / 2;
|
||||||
|
coords.x2 -= p.x / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lv_draw_label(draw_ctx, &label_draw_dsc, &coords, s, nullptr);
|
||||||
|
|
||||||
RESTORE_OFFSET();
|
RESTORE_OFFSET();
|
||||||
|
|
||||||
|
pos += p.x;
|
||||||
return ((flags & RIGHT) ? orig_pos : pos) - offsetX;
|
return ((flags & RIGHT) ? orig_pos : pos) - offsetX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -52,6 +52,9 @@ enum BitmapFormats
|
|||||||
BMP_ARGB4444
|
BMP_ARGB4444
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _lv_draw_ctx_t;
|
||||||
|
typedef _lv_draw_ctx_t lv_draw_ctx_t;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class BitmapBufferBase
|
class BitmapBufferBase
|
||||||
{
|
{
|
||||||
@@ -196,6 +199,7 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>
|
|||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
bool leakReported;
|
bool leakReported;
|
||||||
#endif
|
#endif
|
||||||
|
lv_draw_ctx_t* draw_ctx = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BitmapBuffer(uint8_t format, uint16_t width, uint16_t height);
|
BitmapBuffer(uint8_t format, uint16_t width, uint16_t height);
|
||||||
@@ -203,6 +207,8 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>
|
|||||||
|
|
||||||
~BitmapBuffer();
|
~BitmapBuffer();
|
||||||
|
|
||||||
|
void setDrawCtx(lv_draw_ctx_t* ctx) { draw_ctx = ctx; }
|
||||||
|
|
||||||
inline void setFormat(uint8_t format)
|
inline void setFormat(uint8_t format)
|
||||||
{
|
{
|
||||||
this->format = format;
|
this->format = format;
|
||||||
@@ -313,8 +319,8 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>
|
|||||||
|
|
||||||
coord_t drawText(coord_t x, coord_t y, const char * s, LcdFlags flags = 0)
|
coord_t drawText(coord_t x, coord_t y, const char * s, LcdFlags flags = 0)
|
||||||
{
|
{
|
||||||
if (!s) return (flags & VERTICAL) ? y : x;
|
if (!s) return x;
|
||||||
return drawSizedText(x, y, s, 255, flags);
|
return drawSizedText(x, y, s, strlen(s), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
coord_t drawTextAtIndex(coord_t x, coord_t y, const char * s, uint8_t idx, LcdFlags flags = 0)
|
coord_t drawTextAtIndex(coord_t x, coord_t y, const char * s, uint8_t idx, LcdFlags flags = 0)
|
||||||
@@ -384,8 +390,6 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>
|
|||||||
coord_t srcy = 0, coord_t srcw = 0, coord_t srch = 0,
|
coord_t srcy = 0, coord_t srcw = 0, coord_t srch = 0,
|
||||||
float scale = 0);
|
float scale = 0);
|
||||||
|
|
||||||
uint8_t drawChar(coord_t x, coord_t y, const uint8_t * font, const uint16_t * spec, unsigned int index, LcdFlags flags);
|
|
||||||
|
|
||||||
inline void drawPixel(pixel_t * p, pixel_t value)
|
inline void drawPixel(pixel_t * p, pixel_t value)
|
||||||
{
|
{
|
||||||
if (data && (data <= p || p < data_end)) {
|
if (data && (data <= p || p < data_end)) {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "coloredit.h"
|
#include "coloredit.h"
|
||||||
#include "libopenui_globals.h"
|
|
||||||
#include "numberedit.h"
|
#include "numberedit.h"
|
||||||
#include "bitfield.h"
|
#include "bitfield.h"
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
#include "libopenui_types.h"
|
#include "libopenui_types.h"
|
||||||
|
|
||||||
uint8_t getMappedChar(uint8_t c);
|
const lv_font_t* getFont(LcdFlags flags);
|
||||||
uint8_t getFontHeight(LcdFlags flags);
|
uint8_t getFontHeight(LcdFlags flags);
|
||||||
int getCharWidth(uint8_t c, const uint16_t * spec);
|
|
||||||
int getTextWidth(const char * s, int len = 0, LcdFlags flags = 0);
|
int getTextWidth(const char * s, int len = 0, LcdFlags flags = 0);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "keyboard_number.h"
|
#include "keyboard_number.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "libopenui_globals.h"
|
|
||||||
|
|
||||||
constexpr coord_t KEYBOARD_HEIGHT = 90;
|
constexpr coord_t KEYBOARD_HEIGHT = 90;
|
||||||
NumberKeyboard * NumberKeyboard::_instance = nullptr;
|
NumberKeyboard * NumberKeyboard::_instance = nullptr;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "keyboard_text.h"
|
#include "keyboard_text.h"
|
||||||
#include "libopenui_globals.h"
|
|
||||||
#include "textedit.h"
|
#include "textedit.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -66,12 +66,6 @@ class TextKeyboard : public Keyboard {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static TextKeyboard * _instance;
|
static TextKeyboard * _instance;
|
||||||
const char * const * layout;
|
// const char * const * layout;
|
||||||
private:
|
|
||||||
int calculateMaxWidth();
|
|
||||||
int getCharWidth(const char c);
|
|
||||||
|
|
||||||
char touch_key = -128;
|
|
||||||
bool touched = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
#define SHADOWED 0x80u /* black copy at +1 +1 */
|
#define SHADOWED 0x80u /* black copy at +1 +1 */
|
||||||
// 0x1000u used by Lua in api_colorlcd.h
|
// 0x1000u used by Lua in api_colorlcd.h
|
||||||
#define SPACING_NUMBERS_CONST 0x2000u
|
#define SPACING_NUMBERS_CONST 0x2000u
|
||||||
#define VERTICAL 0x4000u
|
|
||||||
// 0x8000u used by Lua in api_colorlcd.h
|
// 0x8000u used by Lua in api_colorlcd.h
|
||||||
|
|
||||||
/* drawNumber flags */
|
/* drawNumber flags */
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) OpenTX
|
|
||||||
*
|
|
||||||
* Source:
|
|
||||||
* https://github.com/opentx/libopenui
|
|
||||||
*
|
|
||||||
* This file is a part of libopenui library.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "libopenui_globals.h"
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) OpenTX
|
|
||||||
*
|
|
||||||
* Source:
|
|
||||||
* https://github.com/opentx/libopenui
|
|
||||||
*
|
|
||||||
* This file is a part of libopenui library.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include "libopenui_config.h"
|
|
||||||
|
|
||||||
extern const uint16_t fontCharactersTable[FONTS_COUNT];
|
|
||||||
extern const uint16_t * const fontspecsTable[FONTS_COUNT];
|
|
||||||
extern const uint8_t * fontsTable[FONTS_COUNT];
|
|
||||||
|
|
||||||
-1
@@ -24,7 +24,6 @@
|
|||||||
#include <font.h>
|
#include <font.h>
|
||||||
#include <static.h>
|
#include <static.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "libopenui_globals.h"
|
|
||||||
#include "libopenui_config.h"
|
#include "libopenui_config.h"
|
||||||
|
|
||||||
constexpr WindowFlags ROLLER_SEPARATION_LINES = (FORM_FLAGS_LAST << 1u);
|
constexpr WindowFlags ROLLER_SEPARATION_LINES = (FORM_FLAGS_LAST << 1u);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "textedit.h"
|
#include "textedit.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "libopenui_globals.h"
|
|
||||||
#include "libopenui_config.h"
|
#include "libopenui_config.h"
|
||||||
|
|
||||||
#if !defined(STR_EDIT)
|
#if !defined(STR_EDIT)
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ static void window_event_cb(lv_event_t * e)
|
|||||||
BitmapBuffer buf = {BMP_RGB565, (uint16_t)w, (uint16_t)h,
|
BitmapBuffer buf = {BMP_RGB565, (uint16_t)w, (uint16_t)h,
|
||||||
(uint16_t *)draw_ctx->buf};
|
(uint16_t *)draw_ctx->buf};
|
||||||
|
|
||||||
|
buf.setDrawCtx(draw_ctx);
|
||||||
|
|
||||||
buf.setOffset(obj_coords.x1 - a.x1, obj_coords.y1 - a.y1);
|
buf.setOffset(obj_coords.x1 - a.x1, obj_coords.y1 - a.y1);
|
||||||
buf.setClippingRect(clipping.x1 - a.x1, clipping.x2 + 1 - a.x1,
|
buf.setClippingRect(clipping.x1 - a.x1, clipping.x2 + 1 - a.x1,
|
||||||
clipping.y1 - a.y1, clipping.y2 + 1 - a.y1);
|
clipping.y1 - a.y1, clipping.y2 + 1 - a.y1);
|
||||||
|
|||||||
Reference in New Issue
Block a user