Skip to content

Commit 13e58bd

Browse files
committed
Bangle.js: Modify handling of widgets to allow variable width widgets (requires new widget JS)
1 parent 1d2b166 commit 13e58bd

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
Add euro symbol to 6x8 and 4x6 fonts as char code 128 (ISO10646-1)
117117
Bangle.js: Use 'locale' library to translate E.showMenu/Prompt/Alert/etc
118118
Bangle.js: remove graphical_menu lib and inline specialised version into E.showMenu
119+
Bangle.js: Modify handling of widgets to allow variable width widgets (requires new widget JS)
119120

120121
2v04 : Allow \1..\9 escape codes in RegExp
121122
ESP8266: reading storage is not working for boot from user2 (fix #1507)
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
(function() {
2-
if (global.WIDGETS) for (var w of WIDGETS) w.draw();
2+
var w=g.getWidth(), h=g.getHeight();
3+
var pos = {
4+
tl:{x:32, y:0, r:0}, // if r==1, we're right->left
5+
tr:{x:w-32, y:0, r:1},
6+
bl:{x:32, y:h-24, r:0},
7+
br:{x:w-32, y:h-24, r:1}
8+
};
9+
g.reset().clearRect(0,0,w-1,23).clearRect(0,h-24,w-1,h-1);
10+
if (global.WIDGETS) for (var wd of WIDGETS) {
11+
var p = pos[wd.area];
12+
if (!p) return;
13+
wd.x = p.x - p.r*wd.width;
14+
wd.y = p.y;
15+
p.x += wd.width*(1-2*p.r);
16+
wd.draw(wd);
17+
}
318
})

libs/js/banglejs/Bangle_drawWidgets.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
(function() {
2-
global.WIDGETPOS={tl:32,tr:g.getWidth()-32,bl:32,br:g.getWidth()-32};
32
global.WIDGETS={};
43
require("Storage").list(/\.wid\.js$/).forEach(widget=>eval(require("Storage").read(widget)));
54
})

libs/js/banglejs/Bangle_loadWidgets.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)