widget_utils for widviz

master
thyttan 2023-01-11 20:23:08 +01:00
parent 737a3738d4
commit 9790084ffa
3 changed files with 5 additions and 11 deletions

View File

@ -1,3 +1,4 @@
0.01: New Widget 0.01: New Widget
0.02: swipe left,right update 0.02: swipe left,right update
0.03: Fix widget visibility code to the top bar isn't cleared by drawWidgets 0.03: Fix widget visibility code to the top bar isn't cleared by drawWidgets
0.04: Use widget_utils.

View File

@ -2,7 +2,7 @@
"id": "widviz", "id": "widviz",
"name": "Widget Visibility Widget", "name": "Widget Visibility Widget",
"shortName": "Viz Widget", "shortName": "Viz Widget",
"version": "0.03", "version": "0.04",
"description": "Swipe left to hide top bar widgets, swipe right to redisplay.", "description": "Swipe left to hide top bar widgets, swipe right to redisplay.",
"icon": "eye.png", "icon": "eye.png",
"type": "widget", "type": "widget",

View File

@ -1,26 +1,19 @@
(() => { (() => {
let widget_utils = require('widget_utils');
var saved = null; var saved = null;
function hide(){ function hide(){
if (!Bangle.isLCDOn() || saved) return; if (!Bangle.isLCDOn() || saved) return;
saved = []; saved = [];
for (var wd of WIDGETS) { widget_utils.hide();
saved.push({d:wd.draw,a:wd.area});
wd.draw=()=>{};
wd.area="";
}
g.setColor(0,0,0); g.setColor(0,0,0);
g.fillRect(0,0,g.getWidth(),23); g.fillRect(0,0,g.getWidth(),23);
} }
function reveal(){ function reveal(){
if (!Bangle.isLCDOn() || !saved) return; if (!Bangle.isLCDOn() || !saved) return;
for (var wd of WIDGETS) { widget_utils.show();
var o = saved.shift();
wd.draw = o.d;
wd.area = o.a;
}
Bangle.drawWidgets(); Bangle.drawWidgets();
saved=null; saved=null;
} }