This commit is contained in:
Neale Pickett 2016-10-08 20:41:07 -06:00
parent 1cad85f483
commit 1ed68a4d41
6 changed files with 190 additions and 141 deletions

View File

@ -1,123 +0,0 @@
{
"appKeys": {
"color_bg": 1,
"color_date": 2,
"color_time": 3,
"font": 0
},
"capabilities": [
"configurable"
],
"companyName": "dartcatcher@gmail.com",
"enableMultiJS": false,
"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",
"name": "FONT_SYMBOLS_52",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
"file": "fonts/Ubuntu-Regular.ttf",
"name": "FONT_UBUNTU_R_28",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/Ubuntu-Bold.ttf",
"name": "FONT_UBUNTU_B_48",
"targetPlatforms": [
"aplite",
"basalt"
],
"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/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",
"name": "FONT_AVERIA_R_28",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/AveriaSerif-Bold.ttf",
"name": "FONT_AVERIA_B_48",
"targetPlatforms": [
"aplite",
"basalt"
],
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/AveriaSerif-Bold.ttf",
"name": "FONT_AVERIA_B_64",
"targetPlatforms": [
"chalk"
],
"type": "font"
}
]
},
"sdkVersion": "3",
"shortName": "Twatch Fonts",
"targetPlatforms": [
"aplite",
"basalt",
"chalk"
],
"uuid": "2dce4324-374b-4e5e-9b98-3275561118f3",
"versionLabel": "1.4",
"watchapp": {
"watchface": true
}
}

131
package.json Normal file
View File

@ -0,0 +1,131 @@
{
"author": "dartcatcher@gmail.com",
"dependencies": {},
"keywords": [],
"name": "twatch-fonts",
"pebble": {
"capabilities": [
"configurable"
],
"displayName": "Twatch Fonts",
"enableMultiJS": false,
"messageKeys": {
"color_bg": 1,
"color_date": 2,
"color_time": 3,
"font": 0
},
"projectType": "native",
"resources": {
"media": [
{
"file": "images/icon.png",
"menuIcon": true,
"name": "ICON",
"targetPlatforms": null,
"type": "bitmap"
},
{
"characterRegex": "[\uf10b]",
"file": "fonts/fontawesome.ttf",
"name": "FONT_SYMBOLS_52",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
"file": "fonts/Ubuntu-Regular.ttf",
"name": "FONT_UBUNTU_R_28",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/Ubuntu-Bold.ttf",
"name": "FONT_UBUNTU_B_64",
"targetPlatforms": [
"chalk"
],
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/Ubuntu-Bold.ttf",
"name": "FONT_UBUNTU_B_48",
"targetPlatforms": [
"aplite",
"basalt",
"diorite"
],
"type": "font"
},
{
"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",
"targetPlatforms": [
"chalk"
],
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/Helvetica-Bold.ttf",
"name": "FONT_HELVETICA_B_48",
"targetPlatforms": [
"aplite",
"basalt",
"diorite"
],
"type": "font"
},
{
"characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
"file": "fonts/AveriaSerif-Regular.ttf",
"name": "FONT_AVERIA_R_28",
"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",
"name": "FONT_AVERIA_B_48",
"targetPlatforms": [
"aplite",
"basalt",
"diorite"
],
"type": "font"
}
]
},
"sdkVersion": "3",
"targetPlatforms": [
"aplite",
"basalt",
"chalk",
"diorite"
],
"uuid": "2dce4324-374b-4e5e-9b98-3275561118f3",
"watchapp": {
"watchface": true
}
},
"version": "1.5.0"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 973 B

After

Width:  |  Height:  |  Size: 905 B

View File

@ -12,14 +12,16 @@ uint32_t color_bg = 0x000000;
uint32_t color_date = 0xffffff; uint32_t color_date = 0xffffff;
uint32_t color_time = 0xffffff; uint32_t color_time = 0xffffff;
#define TIME_H PBL_IF_RECT_ELSE(48, 64)
#define DATE_H 28
#define ICON_H 52
static void bt_handler(bool connected) { static void bt_handler(bool connected) {
bt_connected = connected; bt_connected = connected;
#ifndef PBL_ROUND
if (! bt_connected) { if (! bt_connected) {
vibes_double_pulse(); vibes_double_pulse();
} }
#endif
layer_mark_dirty(main_layer); layer_mark_dirty(main_layer);
} }
@ -56,23 +58,51 @@ static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
layer_mark_dirty(main_layer); layer_mark_dirty(main_layer);
} }
static void main_window_load(Window *window) { static void reposition(GRect bounds) {
main_layer = window_get_root_layer(window); int16_t bottom = bounds.origin.y + bounds.size.h;
int16_t margin_b = TIME_H + bounds.size.h/6;
int16_t margin_l = 7;
GRect r;
Layer *l;
#ifdef PBL_RECT r.origin.x = bounds.origin.x + margin_l;
s_date_layer = text_layer_create(GRect(8, 66, 128, 100)); r.origin.y = PBL_IF_RECT_ELSE(bottom - margin_b, (bottom - TIME_H)/2 - 10);
s_time_layer = text_layer_create(GRect(7, 92, 130, 76)); r.size.w = bounds.size.w - margin_l * 2;
s_alert_layer = text_layer_create(GRect(110, 7, 52, 52)); r.size.h = TIME_H * 5 / 4;
text_layer_set_text_alignment(s_date_layer, GTextAlignmentLeft);
text_layer_set_text_alignment(s_time_layer, GTextAlignmentLeft); // Time
#else l = text_layer_get_layer(s_time_layer);
s_date_layer = text_layer_create(GRect(0, 20, 180, 100)); layer_set_frame(l, r);
s_time_layer = text_layer_create(GRect(0, 48, 180, 76)); layer_mark_dirty(l);
s_alert_layer = text_layer_create(GRect(0, 120, 180, 52));
text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); // Date
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); l = text_layer_get_layer(s_date_layer);
text_layer_set_text_alignment(s_alert_layer, GTextAlignmentCenter); r.origin.y -= 26;
#endif r.origin.x += 1;
r.size.w -= 2;
layer_set_frame(l, r);
layer_mark_dirty(l);
// Alert
l = text_layer_get_layer(s_alert_layer);
r.origin.y = PBL_IF_RECT_ELSE(margin_l, bottom - ICON_H - margin_b);
layer_set_frame(l, r);
layer_mark_dirty(l);
}
static void main_window_load(Window *window) {
GRect main_frame;
main_layer = window_get_root_layer(window);
main_frame = layer_get_frame(main_layer);
s_date_layer = text_layer_create(main_frame);
s_time_layer = text_layer_create(main_frame);
s_alert_layer = text_layer_create(main_frame);
text_layer_set_text_alignment(s_date_layer, PBL_IF_RECT_ELSE(GTextAlignmentLeft, GTextAlignmentCenter));
text_layer_set_text_alignment(s_time_layer, PBL_IF_RECT_ELSE(GTextAlignmentLeft, GTextAlignmentCenter));
text_layer_set_text_alignment(s_alert_layer, PBL_IF_RECT_ELSE(GTextAlignmentRight, GTextAlignmentCenter));
reposition(main_frame);
text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_background_color(s_date_layer, GColorClear);
layer_add_child(main_layer, text_layer_get_layer(s_date_layer)); layer_add_child(main_layer, text_layer_get_layer(s_date_layer));
@ -109,6 +139,7 @@ static void restore() {
break; break;
} }
} }
APP_LOG(APP_LOG_LEVEL_DEBUG, "%x %06lx %06lx %06lx", sel_font, color_bg, color_date, color_time);
text_layer_set_text_color(s_date_layer, GColorFromHEX(color_date)); 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_time_layer, GColorFromHEX(color_time));
@ -120,6 +151,10 @@ static void restore() {
layer_mark_dirty(main_layer); layer_mark_dirty(main_layer);
} }
static void unobstructedAreaWillChange(GRect final_unobstructed_screen_area, void *context) {
reposition(final_unobstructed_screen_area);
}
static void in_received_handler(DictionaryIterator *rec, void *context) { static void in_received_handler(DictionaryIterator *rec, void *context) {
int i; int i;
@ -149,6 +184,10 @@ static void main_window_unload(Window *window) {
} }
static void init() { static void init() {
UnobstructedAreaHandlers uahandlers = {
.will_change = unobstructedAreaWillChange
};
s_main_window = window_create(); s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) { window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load, .load = main_window_load,
@ -165,6 +204,8 @@ static void init() {
app_message_register_inbox_dropped(in_dropped_handler); app_message_register_inbox_dropped(in_dropped_handler);
app_message_open(256, 64); app_message_open(256, 64);
unobstructed_area_service_subscribe(uahandlers, NULL);
// Prevent starting blank // Prevent starting blank
time_t now = time(NULL); time_t now = time(NULL);
struct tm *t = localtime(&now); struct tm *t = localtime(&now);