fix(color): allow negative width & height for Lua rectangle (#7161)

This commit is contained in:
philmoz
2026-03-10 15:23:06 +10:00
committed by GitHub
parent 48e3b2ac7b
commit e6b98a0164
2 changed files with 36 additions and 0 deletions
+32
View File
@@ -1525,6 +1525,37 @@ coord_t LvglWidgetBox::getScrollY()
return lv_obj_get_scroll_y(window->getLvObj());
}
void LvglWidgetBox::setPosAndSize()
{
if (window) {
coord_t px = x, py = y, pw = w, ph = h;
if (pw < 0) {
pw = -pw;
px = px - pw + 1;
}
if (ph < 0) {
ph = -ph;
py = py - ph + 1;
}
window->setPos(px, py);
window->setSize(pw, ph);
}
}
void LvglWidgetBox::setPos(coord_t x, coord_t y)
{
this->x = x;
this->y = y;
setPosAndSize();
}
void LvglWidgetBox::setSize(coord_t w, coord_t h)
{
this->w = w;
this->h = h;
setPosAndSize();
}
bool LvglWidgetBox::callRefs(lua_State *L)
{
if (!LvglWidgetObject::callRefs(L)) return false;
@@ -1568,6 +1599,7 @@ void LvglWidgetBox::build(lua_State *L)
else
lv_obj_set_flex_align(window->getLvObj(), align1, align1, align2);
}
setPosAndSize();
setColor(color.flags);
setOpacity(opacity.value);
}
+4
View File
@@ -517,6 +517,10 @@ class LvglWidgetBox : public LvglWidgetObject, public LvglScrollableParams, publ
coord_t getScrollX() override;
coord_t getScrollY() override;
void setPos(coord_t x, coord_t y) override;
void setSize(coord_t w, coord_t h) override;
void setPosAndSize();
bool callRefs(lua_State *L) override;
void clearRefs(lua_State *L) override;