feat(lua): support for using LVGL objects on colorlcd (#4887)
This commit is contained in:
Vendored
+3
@@ -43,6 +43,7 @@ extern LROT_TABLE(modellib);
|
||||
extern LROT_TABLE(bitmaplib);
|
||||
|
||||
#if defined(COLORLCD)
|
||||
extern LROT_TABLE(lvgllib);
|
||||
extern LROT_TABLE(tablib);
|
||||
#endif
|
||||
|
||||
@@ -99,6 +100,7 @@ LROT_BEGIN(rotables, LROT_TABLEREF(rotables_meta), 0)
|
||||
LROT_TABENTRY( bitmap, bitmaplib )
|
||||
LROT_TABENTRY( Bitmap, bitmaplib ) /* TODO: obsolete after 2.9 */
|
||||
#if defined(COLORLCD)
|
||||
LROT_TABENTRY( lvgl, lvgllib )
|
||||
LROT_TABENTRY( table, tablib )
|
||||
#endif
|
||||
LROT_TABENTRY( ROM, rotables )
|
||||
@@ -110,6 +112,7 @@ LROT_BEGIN(lua_libs, NULL, 0)
|
||||
LROT_FUNCENTRY( dir, luaopen_etxdir )
|
||||
LROT_FUNCENTRY( bitmap_mt, luaopen_bitmap )
|
||||
#if defined(COLORLCD)
|
||||
LROT_FUNCENTRY( lvgl_mt, luaopen_lvgl )
|
||||
LROT_FUNCENTRY( package, luaopen_package )
|
||||
#endif
|
||||
#if defined(LUA_ENABLE_STRLIB_MT)
|
||||
|
||||
+3
-3
@@ -183,8 +183,8 @@ void StaticIcon::center(coord_t w, coord_t h)
|
||||
// Display image from file system using LVGL with LVGL scaling
|
||||
// - LVGL scaling is slow so don't use this if there are many images
|
||||
StaticImage::StaticImage(Window* parent, const rect_t& rect,
|
||||
const char* filename, bool dontEnlarge) :
|
||||
Window(parent, rect), dontEnlarge(dontEnlarge)
|
||||
const char* filename, bool fillFrame, bool dontEnlarge) :
|
||||
Window(parent, rect), fillFrame(fillFrame), dontEnlarge(dontEnlarge)
|
||||
{
|
||||
setWindowFlag(NO_FOCUS);
|
||||
|
||||
@@ -234,7 +234,7 @@ void StaticImage::setZoom()
|
||||
if (img && img->w && img->h) {
|
||||
uint16_t zw = (width() * 256) / img->w;
|
||||
uint16_t zh = (height() * 256) / img->h;
|
||||
uint16_t z = min(zw, zh);
|
||||
uint16_t z = fillFrame ? max(zw, zh) : min(zw, zh);
|
||||
if (dontEnlarge) z = min(z, (uint16_t)256);
|
||||
lv_img_set_zoom(image, z);
|
||||
}
|
||||
|
||||
+2
-1
@@ -142,7 +142,7 @@ class StaticImage : public Window
|
||||
{
|
||||
public:
|
||||
StaticImage(Window *parent, const rect_t &rect,
|
||||
const char *filename = nullptr, bool dontEnlarge = false);
|
||||
const char *filename = nullptr, bool fillFrame = false, bool dontEnlarge = false);
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override { return "StaticImage"; }
|
||||
@@ -154,6 +154,7 @@ class StaticImage : public Window
|
||||
bool hasImage() const;
|
||||
|
||||
protected:
|
||||
bool fillFrame;
|
||||
bool dontEnlarge = false;
|
||||
lv_obj_t *image = nullptr;
|
||||
};
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class Window
|
||||
typedef std::function<void(bool)> FocusHandler;
|
||||
void setFocusHandler(FocusHandler h) { focusHandler = std::move(h); }
|
||||
|
||||
void clear();
|
||||
virtual void clear();
|
||||
virtual void deleteLater(bool detach = true, bool trash = true);
|
||||
|
||||
bool hasFocus() const;
|
||||
|
||||
Reference in New Issue
Block a user