Merge pull request #1188 from Ronin0000/master

Add Pro Menu App
master
Gordon Williams 2022-01-04 10:43:12 +00:00 committed by GitHub
commit a52c6cb4f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 205 additions and 1 deletions

View File

@ -5102,6 +5102,21 @@
{"name":"ltherm.img","url":"icon.js","evaluate":true}
]
},
{
"id": "promenu",
"name": "Pro Menu",
"version": "0.01",
"description": "Replace Bangle.js 1's built in menu function.",
"icon": "icons8-menu-48 (1).png",
"type": "boot",
"tags": "system",
"supports": ["BANGLEJS"],
"screenshots": [{"url":"pro-menu-screenshot.png"}],
"storage": [
{"name":"promenu.boot.js","url":"boot.js"},
{"name":"promenu.img","url":"promenuIcon.js","evaluate":true}
]
},
{
"id": "touchtimer",
"name": "Touch Timer",

View File

@ -1,8 +1,18 @@
# Desktop style App Launcher
Bangle 1:
![](screenshot.jpg)
In the picture above, the Settings app is selected.
Bangle 2:
![shot1](https://user-images.githubusercontent.com/89286474/146471756-ec6d16de-6916-4fde-b991-ba88c2c8fa1a.png)
![shot2](https://user-images.githubusercontent.com/89286474/146471758-3a9fce80-e047-4c7a-829a-e780c764b921.png)
![shot3](https://user-images.githubusercontent.com/89286474/146471760-5497fd1b-8e82-4fd5-a4e3-4734701a7dbd.png)
## Controls- Bangle
**BTN1** - move backward through app icons on a page
@ -21,4 +31,4 @@ In the picture above, the Settings app is selected.
**Swipe Left** - move to next page of app icons
**Swipe Right** - move to previous page of app icons
**Swipe Right** - move to previous page of app icons

1
apps/promenu/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New App!

1
apps/promenu/README.md Normal file
View File

@ -0,0 +1 @@

176
apps/promenu/boot.js Normal file
View File

@ -0,0 +1,176 @@
E.showMenu = function(items) {
function RectRnd(x1,y1,x2,y2,r) {
pp = [];
pp.push.apply(pp,g.quadraticBezier([x2-r,y1, x2,y1,x2,y1+r]));
pp.push.apply(pp,g.quadraticBezier([x2,y2-r,x2,y2,x2-r,y2]));
pp.push.apply(pp,g.quadraticBezier([x1+r,y2,x1,y2,x1,y2-r]));
pp.push.apply(pp,g.quadraticBezier([x1,y1+r,x1,y1,x1+r,y1]));
return pp;
}
function fillRectRnd(x1,y1,x2,y2,r,c) {
g.setColor(c);
g.fillPoly(RectRnd(x1,y1,x2,y2,r),1);
g.setColor(255,255,255);
}
function drawRectRnd(x1,y1,x2,y2,r,c) {
g.setColor(c);
g.drawPoly(RectRnd(x1,y1,x2,y2,r),1);
g.setColor(255,255,255);
}
g.reset().clearRect(Bangle.appRect); // clear if no menu supplied
Bangle.setLCDPower(1); // ensure screen is on
if (!items) {
Bangle.setUI();
return;
}
var menuItems = Object.keys(items);
var options = items[""];
if (options) menuItems.splice(menuItems.indexOf(""),1);
if (!(options instanceof Object)) options = {};
options.fontHeight = options.fontHeight||35;
if (options.selected === undefined)
options.selected = 0;
if (!options.fontHeight)
options.fontHeight = 6;
var ar = Bangle.appRect;
var x = ar.x;
var x2 = ar.x2-11; // padding at side for up/down
var y = ar.y;
var y2 = ar.y2 - 20; // padding at end for arrow
if (options.title)
y += options.fontHeight+2;
var loc = require("locale");
var l = {
lastIdx : 0,
draw : function(rowmin,rowmax) {
var rows = 0|Math.min((y2-y) / options.fontHeight,menuItems.length);
var idx = E.clip(options.selected-(rows>>1),0,menuItems.length-rows);
if (idx!=l.lastIdx) rowmin=undefined; // redraw all if we scrolled
l.lastIdx = idx;
var iy = y-5;
g.reset().setFont('6x8',2).setFontAlign(0,-1,0);
if (options.predraw) options.predraw(g);
if (rowmin===undefined && options.title) {
g.drawString(options.title,(x+x2)/2,y-options.fontHeight+5);
g.drawLine(x,y-7,x2,y-7);
}
if (rowmin!==undefined) {
if (idx<rowmin) {
iy += options.fontHeight*(rowmin-idx);
idx=rowmin;
}
if (idx+rows>rowmax) {
rows = 1+rowmax-rowmin;
}
}
while (rows--) {
var name = menuItems[idx];
var item = items[name];
var hl = (idx==options.selected && !l.selectEdit);
if(g.theme.dark){
fillRectRnd(x+2,iy+1,x2,iy+options.fontHeight-3,7,hl ? g.theme.bgH : g.theme.bg+20);
}else{
fillRectRnd(x+2,iy+1,x2,iy+options.fontHeight-3,7,hl ? g.theme.bgH : g.theme.bg-10);
}
g.setColor(hl ? g.theme.fgH : g.theme.fg);
g.setFontAlign(-1,-1);
if(loc.translate(name).length >= 11 && "object" == typeof item){
var v = item.value;
if (item.format) v=item.format(v);
v = loc.translate(""+v);
g.drawString(loc.translate(name).substring(0, 15-v.length)+"...",x+8,iy+7);
}else{
if(loc.translate(name).length >= 15){
g.drawString(loc.translate(name).substring(0, 15)+"...",x+8,iy+7);
}else{
g.drawString(loc.translate(name),x+8,iy+7);
}
}
if ("object" == typeof item) {
var xo = x2;
var v = item.value;
if (item.format) v=item.format(v);
v = loc.translate(""+v);
if (l.selectEdit && idx==options.selected) {
xo -= 24 + 1;
g.setColor(g.theme.fgH).drawImage("\x0c\x05\x81\x00 \x07\x00\xF9\xF0\x0E\x00@",xo,iy+(options.fontHeight-10)/2,{scale:2});
}
g.setFontAlign(1,-1);
g.drawString(v,xo-4,iy+8.5);
}
g.setColor(g.theme.fg);
iy += options.fontHeight;
idx++;
}
g.setFontAlign(-1,-1);
var more = idx<menuItems.length;
g.drawImage("\b\b\x01\x108|\xFE\x10\x10\x10\x10"/*E.toString(8,8,1,
0b00010000,
0b00111000,
0b01111100,
0b11111110,
0b00010000,
0b00010000,
0b00010000,
0b00010000
)*/,x2+2,40);
g.drawImage("\b\b\x01\x10\x10\x10\x10\xFE|8\x10"/*E.toString(8,8,1,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b11111110,
0b01111100,
0b00111000,
0b00010000
)*/,x2+2,194);
g.drawImage("\b\b\x01\x00\b\f\x0E\xFF\x0E\f\b"/*E.toString(8,8,1,
0b00000000,
0b00001000,
0b00001100,
0b00001110,
0b11111111,
0b00001110,
0b00001100,
0b00001000
)*/,x2+2,116);
g.setColor(more?g.theme.fg:g.theme.bg).fillPoly([104,220,136,220,120,228]);
g.flip();
},
select : function() {
var item = items[menuItems[options.selected]];
if ("function" == typeof item) item(l);
else if ("object" == typeof item) {
// if a number, go into 'edit mode'
if ("number" == typeof item.value)
l.selectEdit = l.selectEdit?undefined:item;
else { // else just toggle bools
if ("boolean" == typeof item.value) item.value=!item.value;
if (item.onchange) item.onchange(item.value);
}
l.draw();
}
},
move : function(dir) {
var item = l.selectEdit;
if (item) {
item = l.selectEdit;
item.value -= (dir||1)*(item.step||1);
if (item.min!==undefined && item.value<item.min) item.value = item.wrap ? item.max : item.min;
if (item.max!==undefined && item.value>item.max) item.value = item.wrap ? item.min : item.max;
if (item.onchange) item.onchange(item.value);
l.draw(options.selected,options.selected);
} else {
var lastSelected=options.selected;
options.selected = (dir+options.selected+menuItems.length)%menuItems.length;
l.draw(Math.min(lastSelected,options.selected), Math.max(lastSelected,options.selected));
}
}
};
l.draw();
Bangle.setUI("updown",dir => {
if (dir) l.move(dir);
else l.select();
});
return l;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwyBC/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AFE+rwBSAAU2j02js1/oBC7oBBlu9AIWdluclt8AIMlrgBCngBCjgBBjn7AIXbAIW7AIMUzYBFLv5ddMJ5d/LqJfeLv5fdLv5fQMJhd/LqQA/AH4A/AH4A/AH4A/AH4A/AAM+rwBSAAU2j02js1/oBC7oBBlu9AIWdluclt8AIMlrgBCngBCjgBBjn7AIXbAIW7AIMUzYBFLv5ddMJ5d/LqJfeLv5fdLv5fQMJhd/LqQA/AH4A/AH4A/AH4A/AH4A/AAM+rwBSAAU2j02js1/oBC7oBBlu9AIWdluclt8AIMlrgBCngBCjgBBjn7AIXbAIW7AIMUzYBFLv5ddMJ5d/LqJfeLv5fdLv5fQMJhd/LqQA/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/ADIA=="))