widget_utils - Remove exports.overlayRemoved

master
Martin Boonk 2024-05-20 14:29:07 +02:00
parent 76fd49dad7
commit 2a6b428344
1 changed files with 7 additions and 10 deletions

View File

@ -1,4 +1,3 @@
exports.overlayRemoved = false;
exports.offset = 0; exports.offset = 0;
exports.hide = function() { exports.hide = function() {
exports.cleanup(); exports.cleanup();
@ -28,9 +27,8 @@ exports.show = function() {
} }
}; };
/// Remove anthing not needed if the overlay was removed /// Remove anything not needed if the overlay was removed
exports.cleanupOverlay = function() { exports.cleanupOverlay = function() {
exports.overlayRemoved = true;
exports.offset = -24; exports.offset = -24;
Bangle.setLCDOverlay(undefined, {id: "widget_utils"}); Bangle.setLCDOverlay(undefined, {id: "widget_utils"});
delete exports.autohide; delete exports.autohide;
@ -48,7 +46,6 @@ exports.cleanupOverlay = function() {
/// Remove any intervals/handlers/etc that we might have added. Does NOT re-show widgets that were hidden /// Remove any intervals/handlers/etc that we might have added. Does NOT re-show widgets that were hidden
exports.cleanup = function() { exports.cleanup = function() {
exports.cleanupOverlay(); exports.cleanupOverlay();
delete exports.overlayRemoved;
delete exports.offset; delete exports.offset;
if (exports.swipeHandler) { if (exports.swipeHandler) {
Bangle.removeListener("swipe", exports.swipeHandler); Bangle.removeListener("swipe", exports.swipeHandler);
@ -92,11 +89,12 @@ exports.swipeOn = function(autohide) {
exports.offset = -24; // where on the screen are we? -24=hidden, 0=full visible exports.offset = -24; // where on the screen are we? -24=hidden, 0=full visible
function queueDraw() { function queueDraw() {
if (!exports.overlayRemoved) { const o = exports.offset;
Bangle.appRect.y = exports.offset+24; if (o>-24) {
Bangle.appRect.y = o+24;
Bangle.appRect.h = 1 + Bangle.appRect.y2 - Bangle.appRect.y; Bangle.appRect.h = 1 + Bangle.appRect.y2 - Bangle.appRect.y;
if (exports.offset>-24) { if (o>-24) {
Bangle.setLCDOverlay(og, 0, exports.offset, { Bangle.setLCDOverlay(og, 0, o, {
id:"widget_utils", id:"widget_utils",
remove:()=>{ remove:()=>{
require("widget_utils").cleanupOverlay(); require("widget_utils").cleanupOverlay();
@ -114,7 +112,7 @@ exports.swipeOn = function(autohide) {
g=og; g=og;
this._draw(this); this._draw(this);
g=_g; g=_g;
if (exports.offset>-24) queueDraw(); if (o>-24) queueDraw();
}; };
w._area = w.area; w._area = w.area;
if (w.area.startsWith("b")) if (w.area.startsWith("b"))
@ -160,7 +158,6 @@ exports.swipeOn = function(autohide) {
anim(-4); anim(-4);
}, exports.autohide); }, exports.autohide);
}; };
exports.overlayRemoved = false;
if (ud>0 && exports.offset<0) anim(4, cb); if (ud>0 && exports.offset<0) anim(4, cb);
if (ud<0 && exports.offset>-24) anim(-4); if (ud<0 && exports.offset>-24) anim(-4);
}; };