mirror of https://github.com/nealey/TwatchFonts
Colors specified in HTML now
No longer keeping a big array of color presets.
This commit is contained in:
parent
e2cfe1dbf7
commit
2d0563bf37
95
appinfo.json
95
appinfo.json
|
@ -1,17 +1,25 @@
|
|||
{
|
||||
"appKeys": {
|
||||
"align": 1,
|
||||
"font": 2,
|
||||
"theme": 0
|
||||
"color_bg": 1,
|
||||
"color_date": 2,
|
||||
"color_time": 3,
|
||||
"font": 0
|
||||
},
|
||||
"capabilities": [
|
||||
""
|
||||
"configurable"
|
||||
],
|
||||
"companyName": "dartcatcher@gmail.com",
|
||||
"longName": "Twatch Fonts",
|
||||
"projectType": "native",
|
||||
"resources": {
|
||||
"media": [
|
||||
{
|
||||
"file": "images/icon.png",
|
||||
"menuIcon": true,
|
||||
"name": "ICON",
|
||||
"targetPlatforms": null,
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[\uf10b]",
|
||||
"file": "fonts/fontawesome.ttf",
|
||||
|
@ -20,12 +28,10 @@
|
|||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/Ubuntu-Bold.ttf",
|
||||
"name": "FONT_UBUNTU_B_64",
|
||||
"targetPlatforms": [
|
||||
"chalk"
|
||||
],
|
||||
"characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
|
||||
"file": "fonts/Ubuntu-Regular.ttf",
|
||||
"name": "FONT_UBUNTU_R_28",
|
||||
"targetPlatforms": null,
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
|
@ -38,13 +44,41 @@
|
|||
],
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/Ubuntu-Bold.ttf",
|
||||
"name": "FONT_UBUNTU_B_64",
|
||||
"targetPlatforms": [
|
||||
"chalk"
|
||||
],
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
|
||||
"file": "fonts/Ubuntu-Regular.ttf",
|
||||
"name": "FONT_UBUNTU_R_28",
|
||||
"file": "fonts/Helvetica-Regular.ttf",
|
||||
"name": "FONT_HELVETICA_R_28",
|
||||
"targetPlatforms": null,
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/Helvetica-Bold.ttf",
|
||||
"name": "FONT_HELVETICA_B_48",
|
||||
"targetPlatforms": [
|
||||
"aplite",
|
||||
"basalt"
|
||||
],
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/Helvetica-Bold.ttf",
|
||||
"name": "FONT_HELVETICA_B_64",
|
||||
"targetPlatforms": [
|
||||
"chalk"
|
||||
],
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
|
||||
"file": "fonts/AveriaSerif-Regular.ttf",
|
||||
|
@ -52,15 +86,6 @@
|
|||
"targetPlatforms": null,
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/AveriaSerif-Bold.ttf",
|
||||
"name": "FONT_AVERIA_B_64",
|
||||
"targetPlatforms": [
|
||||
"chalk"
|
||||
],
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/AveriaSerif-Bold.ttf",
|
||||
|
@ -71,38 +96,14 @@
|
|||
],
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"file": "images/icon.png",
|
||||
"menuIcon": true,
|
||||
"name": "ICON",
|
||||
"targetPlatforms": null,
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
|
||||
"file": "fonts/Helvetica-Regular.ttf",
|
||||
"name": "FONT_HELVETICA_R_28",
|
||||
"targetPlatforms": null,
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/Helvetica-Bold.ttf",
|
||||
"name": "FONT_HELVETICA_B_64",
|
||||
"file": "fonts/AveriaSerif-Bold.ttf",
|
||||
"name": "FONT_AVERIA_B_64",
|
||||
"targetPlatforms": [
|
||||
"chalk"
|
||||
],
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[0-9:]",
|
||||
"file": "fonts/Helvetica-Bold.ttf",
|
||||
"name": "FONT_HELVETICA_B_48",
|
||||
"targetPlatforms": [
|
||||
"aplite",
|
||||
"basalt"
|
||||
],
|
||||
"type": "font"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
25
src/main.c
25
src/main.c
|
@ -68,8 +68,10 @@ static void main_window_load(Window *window) {
|
|||
}
|
||||
|
||||
static void restore() {
|
||||
int sel_theme = 0;
|
||||
int sel_font = 0;
|
||||
uint32_t color_bg = 0x000000;
|
||||
uint32_t color_date = 0xffffff;
|
||||
uint32_t color_time = 0xffffff;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < KEY_LAST; i += 1) {
|
||||
|
@ -78,19 +80,25 @@ static void restore() {
|
|||
}
|
||||
|
||||
switch (i) {
|
||||
case KEY_THEME:
|
||||
sel_theme = persist_read_int(i);
|
||||
break;
|
||||
case KEY_FONT:
|
||||
sel_font = persist_read_int(i);
|
||||
break;
|
||||
case KEY_COLOR_BG:
|
||||
color_bg = persist_read_int(i);
|
||||
break;
|
||||
case KEY_COLOR_DATE:
|
||||
color_date = persist_read_int(i);
|
||||
break;
|
||||
case KEY_COLOR_TIME:
|
||||
color_time = persist_read_int(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window_set_background_color(s_main_window, *themes[sel_theme][0]);
|
||||
text_layer_set_text_color(s_date_layer, *themes[sel_theme][1]);
|
||||
text_layer_set_text_color(s_time_layer, *themes[sel_theme][2]);
|
||||
text_layer_set_text_color(s_alert_layer, *themes[sel_theme][2]);
|
||||
window_set_background_color(s_main_window, GColorFromHEX(color_bg));
|
||||
text_layer_set_text_color(s_date_layer, GColorFromHEX(color_date));
|
||||
text_layer_set_text_color(s_time_layer, GColorFromHEX(color_time));
|
||||
text_layer_set_text_color(s_alert_layer, GColorFromHEX(color_time));
|
||||
|
||||
text_layer_set_font(s_date_layer, fonts_load_custom_font(resource_get_handle(fonts[sel_font][0])));
|
||||
text_layer_set_font(s_time_layer, fonts_load_custom_font(resource_get_handle(fonts[sel_font][1])));
|
||||
|
@ -107,6 +115,7 @@ static void in_received_handler(DictionaryIterator *rec, void *context) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// They're all ints! Yay!
|
||||
persist_write_int(i, cur->value->int32);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,23 +18,23 @@ Pebble.addEventListener("showConfiguration", function() {
|
|||
Pebble.openURL('http://woozle.org/neale/misc/twatch-config/fonts.html');
|
||||
});
|
||||
|
||||
var themes = {"Dark": 0,
|
||||
"Light": 1,
|
||||
"Green": 2};
|
||||
var aligns = {"Left": 0,
|
||||
"Center": 1,
|
||||
"Right": 2};
|
||||
var fonts = {"Helvetica": 0,
|
||||
"Avería": 1,
|
||||
"Ubuntu": 2};
|
||||
|
||||
Pebble.addEventListener("webviewclosed", function(e) {
|
||||
console.log("configuration closed");
|
||||
console.log("configuration closed:" + decodeURIComponent(e.response));
|
||||
// webview closed
|
||||
var options = JSON.parse(decodeURIComponent(e.response));
|
||||
options.theme = themes[options.theme];
|
||||
options.align = aligns[options.align];
|
||||
options.font = fonts[options.font];
|
||||
console.log("Options = " + options.theme + options.align + options.font);
|
||||
Pebble.sendAppMessage(options, appMessageAck, appMessageNak);
|
||||
var colors = options.theme.split(",");
|
||||
var out = {};
|
||||
console.log(options.theme);
|
||||
|
||||
out.color_bg = parseInt(colors[0], 16);
|
||||
out.color_date = parseInt(colors[1], 16);
|
||||
out.color_time = parseInt(colors[2], 16);
|
||||
out.font = fonts[options.font];
|
||||
|
||||
console.log(colors[1], out.color_date);
|
||||
Pebble.sendAppMessage(out, appMessageAck, appMessageNak);
|
||||
});
|
||||
|
|
|
@ -4,26 +4,13 @@
|
|||
#define NOZERO(s) ((*s == '0')?(s+1):s)
|
||||
|
||||
typedef enum {
|
||||
KEY_THEME = 0,
|
||||
KEY_ALIGN,
|
||||
KEY_FONT,
|
||||
KEY_FONT = 0,
|
||||
KEY_COLOR_BG,
|
||||
KEY_COLOR_DATE,
|
||||
KEY_COLOR_TIME,
|
||||
KEY_LAST
|
||||
} MessageKey;
|
||||
|
||||
enum {
|
||||
THEME_DARK = 0,
|
||||
THEME_LIGHT,
|
||||
THEME_GREEN,
|
||||
THEME_LAST
|
||||
};
|
||||
|
||||
enum {
|
||||
ALIGN_LEFT = 0,
|
||||
ALIGN_CENTER,
|
||||
ALIGN_RIGHT,
|
||||
ALIGN_LAST
|
||||
};
|
||||
|
||||
enum {
|
||||
FONT_HELVETICA = 0,
|
||||
FONT_AVERIA,
|
||||
|
@ -31,18 +18,6 @@ enum {
|
|||
FONT_LAST
|
||||
};
|
||||
|
||||
GColor8 *themes[THEME_LAST][3] = {
|
||||
{&GColorBlack, &GColorWhite, &GColorWhite},
|
||||
{&GColorWhite, &GColorBlack, &GColorBlack},
|
||||
{&GColorDarkGreen, &GColorWhite, &GColorWhite}
|
||||
};
|
||||
|
||||
GTextAlignment aligns[ALIGN_LAST] = {
|
||||
GTextAlignmentLeft,
|
||||
GTextAlignmentCenter,
|
||||
GTextAlignmentRight
|
||||
};
|
||||
|
||||
const int fonts[FONT_LAST][2] = {
|
||||
#ifdef PBL_RECT
|
||||
{RESOURCE_ID_FONT_HELVETICA_R_28, RESOURCE_ID_FONT_HELVETICA_B_48},
|
||||
|
|
Loading…
Reference in New Issue