Hide button bar on round watches; scale fonts based on display width; use fixed version of sleep icon that displays properly without AA

This commit is contained in:
2026-04-24 18:49:20 -04:00
parent 6d820e01fd
commit 8da2f9f1ef
3 changed files with 31 additions and 12 deletions

View File

@@ -59,7 +59,7 @@ static void update_sleep_time(time_t start, time_t end) {
}
static void button_bar_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, GColorLiberty);
graphics_context_set_fill_color(ctx, GColorPictonBlue);
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
}
@@ -69,14 +69,11 @@ static void sleep_bar_update_proc(Layer *layer, GContext *ctx) {
}
static void sleep_icon_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_antialiased(ctx, false);
gdraw_command_image_draw(ctx, s_sleep_icon, GPoint(0, 0));
}
static void main_window_load(Window *window) {
// button bar
s_button_bar_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - 25, 0, 25, PBL_DISPLAY_HEIGHT));
layer_set_update_proc(s_button_bar_layer, button_bar_update_proc);
// sleep bar
s_sleep_bar_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(49, 31)));
layer_set_update_proc(s_sleep_bar_layer, sleep_bar_update_proc);
@@ -88,7 +85,11 @@ static void main_window_load(Window *window) {
// sleep time
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(24, -2), PBL_DISPLAY_WIDTH, 30));
text_layer_set_background_color(s_sleep_time_layer, GColorClear);
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_GOTHIC_18_BOLD, FONT_KEY_GOTHIC_24_BOLD)));
#if PBL_DISPLAY_WIDTH >= 200
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
#else
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
#endif
text_layer_set_text_alignment(s_sleep_time_layer, GTextAlignmentCenter);
text_layer_set_text_color(s_sleep_time_layer, GColorWhite);
if (s_sleep_timestamp != 0) {
@@ -103,20 +104,28 @@ static void main_window_load(Window *window) {
// watched title
s_last_watched_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT / 2 - 24, PBL_DISPLAY_WIDTH - 4, PBL_DISPLAY_HEIGHT));
text_layer_set_background_color(s_last_watched_layer, GColorClear);
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
text_layer_set_text_color(s_last_watched_layer, GColorWhite);
#if PBL_DISPLAY_WIDTH >= 200
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
#else
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
#endif
if (s_sleep_data_accessible) {
text_layer_set_text(s_last_watched_layer, "N/A"); // default - will be updated before display
} else {
text_layer_set_text(s_last_watched_layer, "Sleep data inaccessible!\nEnsure Pebble Health is enabled.");
}
#if PBL_ROUND
text_layer_set_text_alignment(s_last_watched_layer, GTextAlignmentCenter);
#endif
// add layers as children to windows
Layer *window_layer = window_get_root_layer(window);
layer_add_child(window_layer, s_button_bar_layer);
#if PBL_ROUND
text_layer_set_text_alignment(s_last_watched_layer, GTextAlignmentCenter);
#else
// button bar
s_button_bar_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - 25, 0, 25, PBL_DISPLAY_HEIGHT));
layer_set_update_proc(s_button_bar_layer, button_bar_update_proc);
layer_add_child(window_layer, s_button_bar_layer);
#endif
layer_add_child(window_layer, s_sleep_bar_layer);
layer_add_child(window_layer, s_sleep_icon_layer);
layer_add_child(window_layer, text_layer_get_layer(s_sleep_time_layer));
@@ -134,6 +143,7 @@ static void main_window_unload(Window *window) {
static void init() {
// initialize window
s_main_window = window_create();
window_set_background_color(s_main_window, GColorBlack);
window_set_window_handlers(
s_main_window,
(WindowHandlers){.load = main_window_load, .unload = main_window_unload});