diff --git a/apps/voldisp/boot.js b/apps/voldisp/boot.js index 1d41eec13..ec025cf31 100644 --- a/apps/voldisp/boot.js +++ b/apps/voldisp/boot.js @@ -4,6 +4,44 @@ if (timeout) {clearTimeout(timeout); timeout=undefined;} if (Bangle.CLOCK) { + + const WIDGET_UTILS_HIDE = function() { + //exports.cleanup(); + if (!global.WIDGETS) return; + g.reset(); // reset colors + for (var w of global.WIDGETS) { + if (w._draw) return; // already hidden + w._draw = w.draw; + w.draw = () => {}; + w._area = w.area; + w.area = ""; + if (w.x!=undefined) g.clearRect(w.x,w.y,w.x+w.width-1,w.y+23); + } + }; + /// Show any hidden widgets + const WIDGET_UTILS_SHOW = function() { + //exports.cleanup(); + if (!global.WIDGETS) return; + for (var w of global.WIDGETS) { + if (!w._draw) return; // not hidden + w.draw = w._draw; + w.area = w._area; + delete w._draw; + delete w._area; + w.draw(w); + } + }; + + let isAllWidgetsHidden = true; + if (global.WIDGETS) { + for (var w of global.WIDGETS) { + if (!w._draw) { + isAllWidgetsHidden = false; + break; + } + } + } + WIDGET_UTILS_HIDE(); let barWidth = g.getWidth()*volPercent/100; g. setColor(0x0000).fillRect(0,0,g.getWidth(),24). @@ -12,17 +50,9 @@ drawString("volume",barWidth,1); let goAway = ()=>{ - let isAllWidgetsHidden = true; - if (global.WIDGETS) { - for (var w of global.WIDGETS) { - if (!w._draw) { - isAllWidgetsHidden = false; - break; - } - } - } if (!isAllWidgetsHidden) { - Bangle.drawWidgets(); + g.reset().clearRect(0,0,g.getWidth(),24); + WIDGET_UTILS_SHOW(); } else if (Bangle.uiRedraw) { Bangle.uiRedraw(); } else { @@ -33,5 +63,5 @@ } }; Bangle.on("musicVolume", onMusicVolume); - //GB({t:"audio",v:10}); + //GB({t:"audio",v:66}); }