Layout: Add `forgetLazyState` method

pull/825/head
Ben Whittaker 2021-10-05 20:57:10 -04:00
parent 3cfd94314e
commit cdf95566bd
2 changed files with 6 additions and 1 deletions

View File

@ -74,7 +74,7 @@ function update() {
if (current) {
draw();
} else {
delete layout.rects;
layout.forgetLazyState();
if (NRF.getSecurityStatus().connected) {
E.showMessage("Weather unknown\n\nIs Gadgetbridge\nweather reporting\nset up on your\nphone?");
} else {

View File

@ -73,6 +73,7 @@ Other functions:
* `layout.update()` - update positions of everything if contents have changed
* `layout.debug(obj)` - draw outlines for objects on screen
* `layout.clear(obj)` - clear the given object (you can also just specify `bgCol` to clear before each render)
* `layout.forgetLazyState()` - if lazy rendering is enabled, makes the next call to `render()` perform a full re-render
*/
@ -258,6 +259,10 @@ Layout.prototype.render = function (l) {
}
};
Layout.prototype.forgetLazyState = function () {
this.rects = {};
}
Layout.prototype.layout = function (l) {
// l = current layout element
// exw,exh = extra width/height available