fix(lua): Store and update the 'zone' rectangle for Lua widgets. (#3060)
* Store 'zone' rectangle dat in Lua registry and update it when the screen layout changes or full screen mode changes. Allows Lua widgets to adjust to layout changes. * Call widget 'update' function is layout has changed.
This commit is contained in:
@@ -98,10 +98,6 @@ void Widget::onCancel()
|
||||
|
||||
void Widget::update()
|
||||
{
|
||||
auto container = dynamic_cast<WidgetsContainer*>(parent);
|
||||
if (container) {
|
||||
container->updateZones();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setFullscreen(bool enable)
|
||||
@@ -113,7 +109,10 @@ void Widget::setFullscreen(bool enable)
|
||||
if (!enable) {
|
||||
|
||||
// Reset all zones in container
|
||||
Widget::update();
|
||||
auto container = dynamic_cast<WidgetsContainer*>(parent);
|
||||
if (container)
|
||||
container->updateZones();
|
||||
|
||||
setWindowFlags(getWindowFlags() & ~OPAQUE);
|
||||
lv_obj_set_style_bg_opa(lvobj, LV_OPA_0, LV_PART_MAIN);
|
||||
|
||||
@@ -135,9 +134,10 @@ void Widget::setFullscreen(bool enable)
|
||||
// Enter Fullscreen Mode
|
||||
else {
|
||||
|
||||
// Set window opaque (inhibits redraw from windows bellow)
|
||||
// Set window opaque (inhibits redraw from windows below)
|
||||
setWindowFlags(getWindowFlags() | OPAQUE);
|
||||
lv_obj_set_style_bg_opa(lvobj, LV_OPA_MAX, LV_PART_MAIN);
|
||||
updateZoneRect(parent->getRect());
|
||||
setRect(parent->getRect());
|
||||
fullscreen = true;
|
||||
|
||||
|
||||
@@ -106,6 +106,9 @@ class Widget : public Button
|
||||
// Called at regular time interval, even if the widget cannot be seen
|
||||
virtual void background() {}
|
||||
|
||||
// Update widget 'zone' data (for Lua widgets)
|
||||
virtual void updateZoneRect(rect_t rect) {}
|
||||
|
||||
protected:
|
||||
const WidgetFactory * factory;
|
||||
PersistentData * persistentData;
|
||||
|
||||
@@ -136,6 +136,7 @@ class WidgetsContainerImpl : public WidgetsContainer
|
||||
if (widgets[i]) {
|
||||
auto zone = getZone(i);
|
||||
widgets[i]->setRect(zone);
|
||||
widgets[i]->updateZoneRect(zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user