mirror of https://github.com/nealey/Twatch
Fix rendering of 24
This commit is contained in:
parent
f7a6a5bb0b
commit
7eee8dc814
|
@ -7,7 +7,14 @@
|
||||||
"longName": "Twatch",
|
"longName": "Twatch",
|
||||||
"projectType": "native",
|
"projectType": "native",
|
||||||
"resources": {
|
"resources": {
|
||||||
"media": []
|
"media": [
|
||||||
|
{
|
||||||
|
"characterRegex": "[12345689]",
|
||||||
|
"file": "fonts/AveriaSerifLibre-Regular.ttf",
|
||||||
|
"name": "FONT_48",
|
||||||
|
"type": "font"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sdkVersion": "3",
|
"sdkVersion": "3",
|
||||||
"shortName": "Twatch",
|
"shortName": "Twatch",
|
||||||
|
|
22
src/main.c
22
src/main.c
|
@ -47,7 +47,7 @@ static void bg_update_proc(Layer *layer, GContext *ctx) {
|
||||||
time(&epoch);
|
time(&epoch);
|
||||||
now = localtime(&epoch);
|
now = localtime(&epoch);
|
||||||
|
|
||||||
if (now->tm_hour > 12) {
|
if ((now->tm_hour > 12) || (now->tm_hour == 0)) {
|
||||||
hour += 12;
|
hour += 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,10 @@ static void handle_second_tick(struct tm *tick_time, TimeUnits units_changed) {
|
||||||
layer_mark_dirty(window_get_root_layer(window));
|
layer_mark_dirty(window_get_root_layer(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NUM_HEIGHT 42
|
#define NUM_HEIGHT 50
|
||||||
#define NUM_WIDTH 50
|
#define NUM_WIDTH 54
|
||||||
|
#define BASELINE_OFFSET -7
|
||||||
|
#define NUM_FONT RESOURCE_ID_FONT_48
|
||||||
|
|
||||||
static void window_load(Window *window) {
|
static void window_load(Window *window) {
|
||||||
Layer *window_layer = window_get_root_layer(window);
|
Layer *window_layer = window_get_root_layer(window);
|
||||||
|
@ -131,19 +133,19 @@ static void window_load(Window *window) {
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
x = 140 - (NUM_WIDTH); y = 80 - (NUM_HEIGHT/2);
|
x = 140 - (NUM_WIDTH); y = 80 - (NUM_HEIGHT/2) + BASELINE_OFFSET;
|
||||||
align = GTextAlignmentRight;
|
align = GTextAlignmentRight;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
x = 72 - (NUM_WIDTH/2); y = 122;
|
x = 72 - (NUM_WIDTH/2); y = 122 + BASELINE_OFFSET;
|
||||||
align = GTextAlignmentCenter;
|
align = GTextAlignmentCenter;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
x = 4; y = 80 - (NUM_HEIGHT/2);
|
x = 4; y = 80 - (NUM_HEIGHT/2) + BASELINE_OFFSET;
|
||||||
align = GTextAlignmentLeft;
|
align = GTextAlignmentLeft;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
x = 72 - (NUM_WIDTH/2); y = 4;
|
x = 72 - (NUM_WIDTH/2); y = BASELINE_OFFSET;
|
||||||
align = GTextAlignmentCenter;
|
align = GTextAlignmentCenter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +154,7 @@ static void window_load(Window *window) {
|
||||||
text_layer_set_text_alignment(s_hour_label[i], align);
|
text_layer_set_text_alignment(s_hour_label[i], align);
|
||||||
text_layer_set_background_color(s_hour_label[i], BG);
|
text_layer_set_background_color(s_hour_label[i], BG);
|
||||||
text_layer_set_text_color(s_hour_label[i], FG);
|
text_layer_set_text_color(s_hour_label[i], FG);
|
||||||
text_layer_set_font(s_hour_label[i], fonts_get_system_font(FONT_KEY_BITHAM_42_MEDIUM_NUMBERS));
|
text_layer_set_font(s_hour_label[i], fonts_load_custom_font(resource_get_handle(NUM_FONT)));
|
||||||
|
|
||||||
layer_add_child(s_simple_bg_layer, text_layer_get_layer(s_hour_label[i]));
|
layer_add_child(s_simple_bg_layer, text_layer_get_layer(s_hour_label[i]));
|
||||||
}
|
}
|
||||||
|
@ -170,10 +172,10 @@ static void window_load(Window *window) {
|
||||||
|
|
||||||
layer_add_child(s_date_layer, text_layer_get_layer(s_mon_label));
|
layer_add_child(s_date_layer, text_layer_get_layer(s_mon_label));
|
||||||
|
|
||||||
s_day_label = text_layer_create(GRect(121, 123, 20, 24));
|
s_day_label = text_layer_create(GRect(121, 122, 20, 24));
|
||||||
text_layer_set_text_alignment(s_day_label, GTextAlignmentRight);
|
text_layer_set_text_alignment(s_day_label, GTextAlignmentRight);
|
||||||
text_layer_set_text(s_day_label, s_day_buffer);
|
text_layer_set_text(s_day_label, s_day_buffer);
|
||||||
text_layer_set_background_color(s_day_label, BG);
|
text_layer_set_background_color(s_day_label, GColorClear);
|
||||||
text_layer_set_text_color(s_day_label, FG);
|
text_layer_set_text_color(s_day_label, FG);
|
||||||
text_layer_set_font(s_day_label, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
text_layer_set_font(s_day_label, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
||||||
|
|
||||||
|
|
24
src/twatch.h
24
src/twatch.h
|
@ -1,24 +1,9 @@
|
||||||
#include <pebble.h>
|
#include <pebble.h>
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define NUM_CLOCK_TICKS 11
|
#define NUM_CLOCK_TICKS 8
|
||||||
|
|
||||||
static const struct GPathInfo ANALOG_BG_POINTS[] = {
|
static const struct GPathInfo ANALOG_BG_POINTS[] = {
|
||||||
{ 4,
|
|
||||||
(GPoint []) {
|
|
||||||
{68, 0},
|
|
||||||
{71, 0},
|
|
||||||
{71, 12},
|
|
||||||
{68, 12}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ 4, (GPoint []){
|
|
||||||
{72, 0},
|
|
||||||
{75, 0},
|
|
||||||
{75, 12},
|
|
||||||
{72, 12}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ 4, (GPoint []){
|
{ 4, (GPoint []){
|
||||||
{112, 10},
|
{112, 10},
|
||||||
{114, 12},
|
{114, 12},
|
||||||
|
@ -47,13 +32,6 @@ static const struct GPathInfo ANALOG_BG_POINTS[] = {
|
||||||
{106, 147}
|
{106, 147}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ 4, (GPoint []){
|
|
||||||
{70, 155},
|
|
||||||
{73, 155},
|
|
||||||
{73, 167},
|
|
||||||
{70, 167}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ 4, (GPoint []){
|
{ 4, (GPoint []){
|
||||||
{32, 10},
|
{32, 10},
|
||||||
{30, 12},
|
{30, 12},
|
||||||
|
|
Loading…
Reference in New Issue