Skip to content

Commit d376a7a

Browse files
authored
Merge pull request espruino#3635 from micheledaros/master
tinyhead: change widget bg and fg colour so that widgets blend in with the rest of the clockface
2 parents 88e4625 + c605da6 commit d376a7a

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

apps/tinyheads/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
0.01: New app!
2+
0.02: Make the widget bar the same colour as the hair.

apps/tinyheads/app.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
// Read 12/24 from system settings
66
const is12Hour=(require("Storage").readJSON("setting.json",1)||{})["12hour"] || false;
77

8-
// Tinyhead features are stored at a resolution of 18x21, this scales them to the best fit for the Banglejs2 screen
9-
const scale=9;
8+
const scale=lib.appScale;
109

1110
const closedEyes = 25;
1211
const scaredEyes = 26;
@@ -22,7 +21,8 @@
2221
let helpShown = false;
2322
let tapCount = 0;
2423
let centerX, centerY, minuteHandLength, hourHandLength, handOutline;
25-
24+
let originalTheme = Object.assign({}, g.theme);
25+
2626
// Open the eyes and schedule the next blink
2727
let blinkOpen = function blinkOpen() {
2828
if (blinkTimeout) clearTimeout(blinkTimeout);
@@ -214,6 +214,9 @@
214214
};
215215

216216
let init = function init() {
217+
// change the system theme, so that the widget bar blends in with the clock face
218+
g.setTheme({bg:lib.settings.hairColour,fg:lib.settings.faceColour,dark:true}).clear();
219+
217220
Bangle.on('lock', lockHandler);
218221
Bangle.on('charging', chargingHandler);
219222
if (lib.settings.btStatusEyes) {
@@ -234,6 +237,7 @@
234237
// Go direct to feature select in settings on long screen press
235238
if (xy.type == 2) {
236239
eval(require("Storage").read("tinyheads.settings.js"))(()=> {
240+
g.setTheme(originalTheme);
237241
E.showMenu();
238242
init();
239243
}, true, helpShown);
@@ -251,6 +255,7 @@
251255
}
252256
},
253257
remove: function() {
258+
g.setTheme(originalTheme);
254259
// Clear timeouts and listeners for fast loading
255260
if (drawTimeout) clearTimeout(drawTimeout);
256261
if (blinkTimeout) clearTimeout(blinkTimeout);

apps/tinyheads/lib.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ exports.maxEyes = 25;
55
exports.faceW = 18;
66
exports.faceH = 21;
77

8+
// Scale used when showing the main clock screen.
9+
// Tinyhead features are stored at a resolution of 18x21, this scales them to the best fit for the Banglejs2 screen
10+
exports.appScale=9;
11+
12+
// Scale used when showing the face on the settings page.
13+
// It's smaller than on the clock itself, so that selection arrows can be shown down the sides
14+
exports.settingsScale=6;
15+
816
exports.settingsFile = 'tinyheads.json';
917

1018
let faceCanvas;
@@ -135,7 +143,14 @@ exports.drawFace = function(scale, eyesNum, mouthNum, peek, offset) {
135143
// Draw face
136144
let xOffset = (g.getWidth() - (exports.faceW * scale)) / 2;
137145
let yOffset = (offset ? offset : 0) + ((g.getHeight() - (exports.faceH * scale)) / 2);
138-
g.setBgColor(0, 0, 0);
146+
147+
// On the main screen, if the widgets are displayed, the background color matches the color of the hair and widget bar
148+
if (scale == exports.appScale && (exports.settings.showWidgets == 'on' || (exports.settings.showWidgets == 'unlock' && !Bangle.isLocked()))) {
149+
g.setBgColor(exports.settings.hairColour);
150+
} else {
151+
g.setBgColor(0, 0, 0);
152+
}
153+
139154
g.clearRect(Bangle.appRect);
140155
g.setClipRect(Bangle.appRect.x, Bangle.appRect.y, Bangle.appRect.x2, Bangle.appRect.y2);
141156

apps/tinyheads/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"shortName":"Tinyheads",
55
"icon": "app.png",
66
"screenshots" : [ { "url":"tinyhead1.png" }, {"url":"tinyhead2.png"}, {"url":"tinyhead3.png"}, {"url":"tinyhead4.png"}, {"url":"editing.png"} ],
7-
"version":"0.01",
7+
"version":"0.02",
88
"description": "Choose from a variety of hairstyles, eyes, noses, and mouths to customize your pixel art style Tinyhead.",
99
"readme":"README.md",
1010
"type": "clock",

apps/tinyheads/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
let featureColour = 'faceColour';
77
let colourSelectTimeout;
88

9-
let scale = 6; // Smaller scale than on the clock itself, so that selection arrows can be shown down the sides
9+
const scale = lib.settingsScale;
1010

1111
// 27 colours
1212
let colours = [

0 commit comments

Comments
 (0)