Significant platform-specific design work (TODO: b&w support + shift sleep time GRect depending on if time or error)

This commit is contained in:
2026-04-26 02:50:53 -04:00
parent a64f24f60b
commit bd388a5646
3 changed files with 57 additions and 33 deletions

View File

@@ -38,14 +38,33 @@
{
"type": "raw",
"name": "PIN_ICON",
"file": "pin.pdc"
"file": "pin.pdc",
"targetPlatforms": [
"basalt",
"diorite",
"flint",
"emery"
]
},
{
"type": "raw",
"name": "PIN_ROUND_JELLYFIN_ICON",
"file": "pin_round_jellyfin.pdc",
"targetPlatforms": [
"chalk",
"gabbro"
]
}
]
},
"sdkVersion": "3",
"targetPlatforms": [
"basalt",
"diorite",
"chalk",
"emery"
"flint",
"emery",
"gabbro"
],
"uuid": "3097b48e-552c-4a78-92b2-566b9128640e",
"watchapp": {

Binary file not shown.

View File

@@ -71,37 +71,42 @@ 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);
graphics_context_set_antialiased(ctx, false);
gdraw_command_image_draw(ctx, s_sleep_icon, GPoint(0, 0));
}
static void pin_icon_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_antialiased(ctx, false);
gdraw_command_image_draw(ctx, s_pin_icon, GPoint(0, 0));
}
static void main_window_load(Window *window) {
// 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);
// sleep icon
s_sleep_icon_layer = layer_create(GRect(PBL_IF_ROUND_ELSE((PBL_DISPLAY_WIDTH / 2) - 13, 4), 4, PBL_DISPLAY_WIDTH, 50));
s_sleep_icon_layer = layer_create(GRect(PBL_IF_ROUND_ELSE((PBL_DISPLAY_WIDTH / 2) - 13, 4), 4, 25, 25));
layer_set_update_proc(s_sleep_icon_layer, sleep_icon_update_proc);
// pin icon
s_pin_icon_layer = layer_create(GRect(PBL_DISPLAY_WIDTH-25, (PBL_DISPLAY_HEIGHT/2)-13, 50, 50));
s_pin_icon_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - PBL_IF_ROUND_ELSE(27, 25), (PBL_DISPLAY_HEIGHT / 2) - 13, 25, 25));
layer_set_update_proc(s_pin_icon_layer, pin_icon_update_proc);
// 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);
#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
#if PBL_DISPLAY_WIDTH >= 200
s_sleep_bar_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(53, 31)));
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(21, -2), PBL_DISPLAY_WIDTH, 30));
s_last_watched_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT / 2 - 20, PBL_DISPLAY_WIDTH - 4, PBL_DISPLAY_HEIGHT));
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_layer_set_text_alignment(s_sleep_time_layer, GTextAlignmentCenter);
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
#else
s_sleep_bar_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(49, 31)));
s_sleep_time_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 31), PBL_IF_ROUND_ELSE(24, 6), PBL_DISPLAY_WIDTH, 30));
s_last_watched_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT / 2 - 17, PBL_DISPLAY_WIDTH - 4, PBL_DISPLAY_HEIGHT));
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_GOTHIC_18_BOLD, FONT_KEY_GOTHIC_14_BOLD)));
text_layer_set_text_alignment(s_sleep_time_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
#endif
// sleep time
text_layer_set_background_color(s_sleep_time_layer, GColorClear);
text_layer_set_text_color(s_sleep_time_layer, GColorWhite);
if (s_sleep_timestamp != 0) {
static char buffer[8];
@@ -112,15 +117,11 @@ static void main_window_load(Window *window) {
text_layer_set_text(s_sleep_time_layer, "No sleep last night");
}
// watched title
s_last_watched_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT / 2 - 24, PBL_DISPLAY_WIDTH - 4, PBL_DISPLAY_HEIGHT));
// misc. properties
layer_set_update_proc(s_sleep_bar_layer, sleep_bar_update_proc);
text_layer_set_background_color(s_last_watched_layer, GColorClear);
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 {
@@ -129,14 +130,14 @@ static void main_window_load(Window *window) {
// add layers as children to windows
Layer *window_layer = window_get_root_layer(window);
#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
#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_pin_icon_layer);
layer_add_child(window_layer, s_sleep_bar_layer);
layer_add_child(window_layer, s_sleep_icon_layer);
@@ -176,7 +177,11 @@ static void init() {
// load PDCs
s_sleep_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_SLEEP_ICON);
#if PBL_ROUND
s_pin_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_PIN_ROUND_JELLYFIN_ICON);
#else
s_pin_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_PIN_ICON);
#endif
window_stack_push(s_main_window, true);
}