mirror of https://github.com/nealey/FontFace
Make it white
This commit is contained in:
parent
ef1bf03f81
commit
b1493e608c
27
src/main.c
27
src/main.c
|
@ -1,11 +1,20 @@
|
|||
#include "pebble.h"
|
||||
|
||||
#define WHITE
|
||||
#ifdef WHITE
|
||||
#define BG GColorWhite
|
||||
#define FG GColorBlack
|
||||
#else
|
||||
#define BG GColorBlack
|
||||
#define FG GColorWhite
|
||||
#endif
|
||||
|
||||
static Window *s_main_window;
|
||||
static TextLayer *s_date_layer, *s_time_layer;
|
||||
static Layer *s_line_layer;
|
||||
|
||||
static void line_layer_update_callback(Layer *layer, GContext* ctx) {
|
||||
graphics_context_set_fill_color(ctx, GColorWhite);
|
||||
graphics_context_set_fill_color(ctx, FG);
|
||||
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
|
||||
}
|
||||
|
||||
|
@ -19,9 +28,9 @@ static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
|
|||
|
||||
char *time_format;
|
||||
if (clock_is_24h_style()) {
|
||||
time_format = "%R";
|
||||
time_format = "%k:%M";
|
||||
} else {
|
||||
time_format = "%I:%M";
|
||||
time_format = "%l:%M";
|
||||
}
|
||||
strftime(s_time_text, sizeof(s_time_text), time_format, tick_time);
|
||||
|
||||
|
@ -29,20 +38,24 @@ static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
|
|||
if (!clock_is_24h_style() && (s_time_text[0] == '0')) {
|
||||
memmove(s_time_text, &s_time_text[1], sizeof(s_time_text) - 1);
|
||||
}
|
||||
if (s_time_text[0] == ' ') {
|
||||
text_layer_set_text(s_time_layer, s_time_text + 1);
|
||||
} else {
|
||||
text_layer_set_text(s_time_layer, s_time_text);
|
||||
}
|
||||
}
|
||||
|
||||
static void main_window_load(Window *window) {
|
||||
Layer *window_layer = window_get_root_layer(window);
|
||||
|
||||
s_date_layer = text_layer_create(GRect(8, 66, 136, 100));
|
||||
text_layer_set_text_color(s_date_layer, GColorWhite);
|
||||
text_layer_set_text_color(s_date_layer, FG);
|
||||
text_layer_set_background_color(s_date_layer, GColorClear);
|
||||
text_layer_set_font(s_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_HELVETICA_R_28)));
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
|
||||
|
||||
s_time_layer = text_layer_create(GRect(7, 92, 137, 76));
|
||||
text_layer_set_text_color(s_time_layer, GColorWhite);
|
||||
text_layer_set_text_color(s_time_layer, FG);
|
||||
text_layer_set_background_color(s_time_layer, GColorClear);
|
||||
text_layer_set_font(s_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_HELVETICA_B_48)));
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
|
||||
|
@ -57,7 +70,7 @@ static void main_window_unload(Window *window) {
|
|||
|
||||
static void init() {
|
||||
s_main_window = window_create();
|
||||
window_set_background_color(s_main_window, GColorBlack);
|
||||
window_set_background_color(s_main_window, BG);
|
||||
window_set_window_handlers(s_main_window, (WindowHandlers) {
|
||||
.load = main_window_load,
|
||||
.unload = main_window_unload,
|
||||
|
@ -70,6 +83,8 @@ static void init() {
|
|||
time_t now = time(NULL);
|
||||
struct tm *t = localtime(&now);
|
||||
handle_minute_tick(t, MINUTE_UNIT);
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
}
|
||||
|
||||
static void deinit() {
|
||||
|
|
Loading…
Reference in New Issue