Fix widgets that clear too low, and make widget swipeOn have a 2px border at the bottom

pull/2803/head
Gordon Williams 2023-06-09 11:04:06 +01:00
parent 1c95dacc26
commit 6bdb7dc0ad
7 changed files with 10 additions and 8 deletions

View File

@ -1,2 +1,3 @@
0.01: New widget
0.02: Make color depend on level
0.03: Stop battery widget clearing too far down

View File

@ -1,7 +1,7 @@
{
"id": "widbatv",
"name": "Battery Level Widget (Vertical)",
"version": "0.02",
"version": "0.03",
"description": "Slim, vertical battery widget that only takes up 14px",
"icon": "widget.png",
"type": "widget",

View File

@ -12,7 +12,7 @@ WIDGETS["batv"]={area:"tr",width:14,draw:function() {
if (Bangle.isCharging()) {
g.setColor("#0f0").drawImage(atob("DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y);
} else {
g.clearRect(x,y,x+14,y+24);
g.clearRect(x,y,x+14,y+23);
g.setColor(g.theme.fg).fillRect(x+2,y+2,x+12,y+22).clearRect(x+4,y+4,x+10,y+20).fillRect(x+5,y+1,x+9,y+2);
var battery = E.getBattery();
if (battery < 20) {g.setColor("#f00");}

View File

@ -1,2 +1,3 @@
0.01: New Widget!
0.02: Now use an app ID (to avoid conflicts with clocks that also use ClockInfo)
0.02: Now use an app ID (to avoid conflicts with clocks that also use ClockInfo)
0.03: Fix widget clearing too far down

View File

@ -1,6 +1,6 @@
{ "id": "widclkinfo",
"name": "Clock Info Widget",
"version":"0.02",
"version":"0.03",
"description": "Use 'Clock Info' in the Widget bar. Tap on the widget to select, then drag up/down/left/right to choose what information is displayed.",
"icon": "widget.png",
"screenshots" : [ { "url":"screenshot.png" }],

View File

@ -32,7 +32,7 @@ if (!require("clock_info").loadCount) { // don't load if a clock_info was alread
// indicate focus - make background reddish
//if (clockInfoMenu.focus) g.setBgColor(g.blendColor(g.theme.bg, "#f00", 0.25));
if (clockInfoMenu.focus) g.setColor("#f00");
g.clearRect(o.x, o.y, o.x+o.w-1, o.y+o.h);
g.clearRect(o.x, o.y, o.x+o.w-1, o.y+o.h-1);
if (clockInfoInfo) {
var x = o.x;
if (clockInfoInfo.img) {

View File

@ -70,13 +70,13 @@ exports.swipeOn = function(autohide) {
// force app rect to be fullscreen
Bangle.appRect = { x: 0, y: 0, w: g.getWidth(), h: g.getHeight(), x2: g.getWidth()-1, y2: g.getHeight()-1 };
// setup offscreen graphics for widgets
let og = Graphics.createArrayBuffer(g.getWidth(),24,16,{msb:true});
let og = Graphics.createArrayBuffer(g.getWidth(),26,16,{msb:true});
og.theme = g.theme;
og._reset = og.reset;
og.reset = function() {
return this._reset().setColor(g.theme.fg).setBgColor(g.theme.bg);
};
og.reset().clearRect(0,0,og.getWidth(),og.getHeight());
og.reset().clearRect(0,0,og.getWidth(),23).fillRect(0,24,og.getWidth(),25);
let _g = g;
let offset = -24; // where on the screen are we? -24=hidden, 0=full visible
@ -146,4 +146,4 @@ exports.swipeOn = function(autohide) {
};
Bangle.on("swipe", exports.swipeHandler);
Bangle.drawWidgets();
};
};