voldisp: fix logic re hide/show widgets and how to `goAway`
Also small optimization.master
parent
500296af19
commit
1fa489b918
|
|
@ -26,6 +26,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let isWeHidingTheWidgets = false;
|
||||||
let timeout;
|
let timeout;
|
||||||
let onMusicVolume = (volPercent)=>{
|
let onMusicVolume = (volPercent)=>{
|
||||||
if (timeout) {clearTimeout(timeout);}
|
if (timeout) {clearTimeout(timeout);}
|
||||||
|
|
@ -33,6 +34,7 @@
|
||||||
if (Bangle.CLOCK) {
|
if (Bangle.CLOCK) {
|
||||||
|
|
||||||
let isAllWidgetsHidden = true;
|
let isAllWidgetsHidden = true;
|
||||||
|
if (!timeout) { // No need to do this if we already did it before and it wasn't undone. I.e. the timout to execute `goAway` never ran out.
|
||||||
if (global.WIDGETS) {
|
if (global.WIDGETS) {
|
||||||
for (var w of global.WIDGETS) {
|
for (var w of global.WIDGETS) {
|
||||||
if (!w._draw) {
|
if (!w._draw) {
|
||||||
|
|
@ -41,7 +43,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!timeout) {WIDGET_UTILS_HIDE();}
|
if (!isAllWidgetsHidden) {
|
||||||
|
WIDGET_UTILS_HIDE();
|
||||||
|
isWeHidingTheWidgets = true; // Remember if it was we who hid the widgets between draws of the volume bar.
|
||||||
|
}
|
||||||
|
}
|
||||||
let barWidth = g.getWidth()*volPercent/100;
|
let barWidth = g.getWidth()*volPercent/100;
|
||||||
g.
|
g.
|
||||||
setColor(0x0000).fillRect(0,0,g.getWidth(),24).
|
setColor(0x0000).fillRect(0,0,g.getWidth(),24).
|
||||||
|
|
@ -50,9 +56,10 @@
|
||||||
drawString("volume",barWidth,1);
|
drawString("volume",barWidth,1);
|
||||||
|
|
||||||
let goAway = ()=>{
|
let goAway = ()=>{
|
||||||
if (!isAllWidgetsHidden) {
|
if (isWeHidingTheWidgets) {
|
||||||
g.reset().clearRect(0,0,g.getWidth(),24);
|
g.reset().clearRect(0,0,g.getWidth(),24);
|
||||||
WIDGET_UTILS_SHOW();
|
WIDGET_UTILS_SHOW();
|
||||||
|
isWeHidingTheWidgets = false;
|
||||||
} else if (Bangle.uiRedraw) {
|
} else if (Bangle.uiRedraw) {
|
||||||
Bangle.uiRedraw();
|
Bangle.uiRedraw();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue