mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
22 lines
620 B
JavaScript
22 lines
620 B
JavaScript
(function() {
|
|
if (!global.WIDGETS) return;
|
|
var w=g.getWidth(), h=g.getHeight(), pos={
|
|
tl:{x:28, y:0, r:0, c:0}, // if r==1, we're right->left
|
|
tr:{x:w-28, y:0, r:1, c:0},
|
|
bl:{x:24, y:h-24, r:0, c:0},
|
|
br:{x:w-24, y:h-24, r:1, c:0}
|
|
}, p;
|
|
for (var wd of WIDGETS) {
|
|
p = pos[wd.area];
|
|
if (!p || wd.width == 0) continue;
|
|
wd.x = p.x - p.r*wd.width;
|
|
wd.y = p.y;
|
|
p.x += wd.width*(1-2*p.r);
|
|
p.c++;
|
|
}
|
|
g.reset();
|
|
if (pos.tl.c || pos.tr.c) g.clearRect(0,0,w-1,23);
|
|
if (pos.bl.c || pos.br.c) g.clearRect(0,h-24,w-1,h-1);
|
|
try { for (wd of WIDGETS) wd.draw(wd); } catch(e) {print(e);}
|
|
})
|